We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
trace.SpanFromContext
Describe the bug
The OTel bridge have the same problem that the opentracing bridge once faced (#235 and opentracing/opentracing-go#192)
apm’s native transaction can't be retrieved by Otel’s trace.SpanFromContext(https://github.com/open-telemetry/opentelemetry-go/blob/b2246d58650bc6db04459353843250ee3bba77fc/trace/context.go#L48).
Since goredis (https://github.com/redis/go-redis/blob/dc8c93ba66777b8f9866542b47cd102f591b5984/extra/redisotel/tracing.go#L90) and maybe other libs use trace.SpanFromContext before starting a Span, currently it is not possible to mix native apm instrumentation with those lib’s OTel instrumentation.
To Reproduce
package main import ( "context" "fmt" "go.elastic.co/apm/module/apmotel/v2" "go.elastic.co/apm/v2" "go.elastic.co/apm/v2/apmtest" "go.opentelemetry.io/otel" "go.opentelemetry.io/otel/trace" ) func main() { tracer := apmtest.NewRecordingTracer() provider, err := apmotel.NewTracerProvider(apmotel.WithAPMTracer(tracer.Tracer)) if err != nil { panic(err) } otel.SetTracerProvider(provider) ctx := context.Background() tx := tracer.StartTransaction("test1", "test") ctx = apm.ContextWithTransaction(ctx, tx) fmt.Printf("apm transaction: %#v\n", apm.TransactionFromContext(ctx)) sp := trace.SpanFromContext(ctx) fmt.Printf("OTel span: %#v\n", sp) // expect to not be otel trace.noopSpan{} }
Expected behavior
Should be able to retrieve Span using Otel’s trace.SpanFromContext from an apm transaction.
The text was updated successfully, but these errors were encountered:
Thanks for opening this issue @wzy9607, I agree this would be ideal - I have added it to our backlog of things to look into.
Sorry, something went wrong.
I found that apm.TransactionFromContext、apm.SpanFromContext also can't retrieve an Otel span started with by apmotel tracer.
apm.TransactionFromContext
apm.SpanFromContext
apmotel
package main import ( "context" "fmt" "go.elastic.co/apm/module/apmotel/v2" "go.elastic.co/apm/v2" "go.elastic.co/apm/v2/apmtest" "go.opentelemetry.io/otel" "go.opentelemetry.io/otel/trace" ) func main() { tracer := apmtest.NewRecordingTracer() provider, err := apmotel.NewTracerProvider(apmotel.WithAPMTracer(tracer.Tracer)) if err != nil { panic(err) } otel.SetTracerProvider(provider) ctx := context.Background() ctx, _ = otel.Tracer("test").Start(ctx, "test1") fmt.Printf("apm transaction: %#v\n", apm.TransactionFromContext(ctx)) // expect to not be (*apm.Transaction)(nil) fmt.Printf("apm span: %#v\n", apm.SpanFromContext(ctx)) // expect to not be (*apm.Span)(nil) fmt.Printf("OTel span: %#v\n", trace.SpanFromContext(ctx)) // is &apmotel.span, as expected }
This should be fully fixed by #1450.
dmathieu
Successfully merging a pull request may close this issue.
Describe the bug
The OTel bridge have the same problem that the opentracing bridge once faced (#235 and opentracing/opentracing-go#192)
apm’s native transaction can't be retrieved by Otel’s
trace.SpanFromContext
(https://github.com/open-telemetry/opentelemetry-go/blob/b2246d58650bc6db04459353843250ee3bba77fc/trace/context.go#L48).Since goredis (https://github.com/redis/go-redis/blob/dc8c93ba66777b8f9866542b47cd102f591b5984/extra/redisotel/tracing.go#L90) and maybe other libs use
trace.SpanFromContext
before starting a Span,currently it is not possible to mix native apm instrumentation with those lib’s OTel instrumentation.
To Reproduce
Expected behavior
Should be able to retrieve Span using Otel’s
trace.SpanFromContext
from an apm transaction.The text was updated successfully, but these errors were encountered: