func NewStandaloneTracer()

in lambda/rapidcore/standalone/telemetry/tracer.go [181:216]


func NewStandaloneTracer(api *StandaloneEventsAPI) *StandaloneTracer {
	startCaptureFn := func(ctx context.Context, i *interop.Invoke, segmentName string, timestamp int64) {
		root, parent, sampled, _ := telemetry.ParseTracingHeader(i.TraceID)
		if isTracingEnabled(root, parent, sampled) {
			e := TracingEvent{
				Message:     "START",
				TraceID:     root,
				SegmentName: segmentName,
				SegmentID:   parent,
				Timestamp:   timestamp / int64(time.Millisecond),
			}
			api.LogTrace(e)
			log.WithFields(logrus.Fields{"trace": e}).Info("sandbox trace")
		}
	}

	endCaptureFn := func(ctx context.Context, i *interop.Invoke, segmentName string, timestamp int64) {
		root, parent, sampled, _ := telemetry.ParseTracingHeader(i.TraceID)
		if isTracingEnabled(root, parent, sampled) {
			e := TracingEvent{
				Message:     "END",
				TraceID:     root,
				SegmentName: "",
				SegmentID:   parent,
				Timestamp:   timestamp / int64(time.Millisecond),
			}
			api.LogTrace(e)
			log.WithFields(logrus.Fields{"trace": e}).Info("sandbox trace")
		}
	}

	return &StandaloneTracer{
		startFunction: startCaptureFn,
		endFunction:   endCaptureFn,
	}
}