func()

in lambda/rapidcore/standalone/telemetry/tracer.go [130:152]


func (t *StandaloneTracer) BuildTracingHeader() func(ctx context.Context) string {
	// extract root trace ID and parent from context and build the tracing header
	return func(ctx context.Context) string {
		var parent string
		var ok bool

		if parent, ok = ctx.Value(telemetry.DocumentIDKey).(string); !ok || parent == "" {
			return t.invoke.TraceID
		}

		if t.rootTraceID == "" || t.sampled == "" {
			return ""
		}

		var tracingHeader = "Root=%s;Parent=%s;Sampled=%s"

		if t.lineage == "" {
			return fmt.Sprintf(tracingHeader, t.rootTraceID, parent, t.sampled)
		}

		return fmt.Sprintf(tracingHeader+";Lineage=%s", t.rootTraceID, parent, t.sampled, t.lineage)
	}
}