-
Notifications
You must be signed in to change notification settings - Fork 0
Closed
Description
We have something like
someWorker, outputQueue, _ := work.NewTransformer(
"this does some work",
intputQueue,
func(in Input) (*Output, error) {
return doSomething(in)
},
transformer.WithErrorQueue(errQueue),
transformer.WithWorkerPoolSize(conf.Parallelism),
transformer.WithSpanName("some work"),
)I would like to have a way to access the OTEL span inside the doSomething function, so that I can attach some span metrics to it. My proposal would be to achieve this via context package with something like this
someWorker, outputQueue, _ := work.NewTransformer(
"this does some work",
intputQueue,
func(ctx context.Context, in Input) (*Output, error) {
return doSomething(ctx, in)
},
transformer.WithErrorQueue(errQueue),
transformer.WithWorkerPoolSize(conf.Parallelism),
transformer.WithSpanName("some work"),
)In doSomething we get the tracer like
func doSomething(ctx context.Context, in Input) (*Output, error) {
span := trace.SpanFromContext(ctx)
// attach attributes and events to span
}Metadata
Metadata
Assignees
Labels
No labels