feat(tracing): Add utils for OpenTelemetry tracing and event logging
This commit is contained in:
parent
505bc3b522
commit
9512cd10bc
20
internal/utils/tracing.go
Normal file
20
internal/utils/tracing.go
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
package utils
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
log "github.com/sirupsen/logrus"
|
||||||
|
"go.opentelemetry.io/otel/trace"
|
||||||
|
)
|
||||||
|
|
||||||
|
func SetupTracing(ctx context.Context, tracer trace.Tracer, tracerName string) (context.Context, trace.Span, *log.Entry) {
|
||||||
|
ctx, span := tracer.Start(ctx, tracerName)
|
||||||
|
localLogger := log.WithContext(ctx)
|
||||||
|
|
||||||
|
return ctx, span, localLogger
|
||||||
|
}
|
||||||
|
|
||||||
|
func HandleEvent(span trace.Span, logger *log.Entry, eventName string) {
|
||||||
|
logger.Debug(eventName)
|
||||||
|
span.AddEvent(eventName)
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user