in pkg/tracing/transaction.go [51:78]
func Span(ctx *context.Context) func() {
if apm.TransactionFromContext(*ctx) == nil {
// no transaction in the context implicates disabled tracing, exiting early to avoid unnecessary work
return func() {}
}
pc, _, _, ok := runtime.Caller(1)
name := "unknown_function"
if ok {
f := runtime.FuncForPC(pc)
name = f.Name()
// cut module and package name, leave only func name
lastDot := strings.LastIndex(name, ".")
// if something went wrong and dot is not present or last, let's not crash the operator and use full name instead
if 0 <= lastDot && lastDot < len(name)-1 {
name = name[lastDot+1:]
}
}
span, newCtx := apm.StartSpan(*ctx, name, "app")
*ctx = newCtx
return func() {
span.End()
}
}