elastic / apm-agent-go

https://www.elastic.co/guide/en/apm/agent/go/current/index.html
Apache License 2.0
413 stars 190 forks source link

apmotel compile error with newer version of otel libraries #1603

Closed kruskall closed 2 months ago

kruskall commented 2 months ago

Describe the bug

Projects using both apmotel and otel libraries won't be able to update the otel libraries because of a compile error with apmotel.

Example failure:

https://github.com/elastic/apm-server/pull/12924

 Error: ../../../go/pkg/mod/go.elastic.co/apm/module/apmotel/v2@v2.5.0/tracer.go:67:19: impossible type assertion: trace.SpanFromContext(ctx).(*span)
    *span does not implement trace.Span (missing method AddLink)
Error: ../../../go/pkg/mod/go.elastic.co/apm/module/apmotel/v2@v2.5.0/tracer.go:96:38: cannot use s (variable of type *span) as trace.Span value in argument to trace.ContextWithSpan: *span does not implement trace.Span (missing method AddLink)
Error: ../../../go/pkg/mod/go.elastic.co/apm/module/apmotel/v2@v2.5.0/tracer.go:96:42: cannot use s (variable of type *span) as trace.Span value in return statement: *span does not implement trace.Span (missing method AddLink)
Error: ../../../go/pkg/mod/go.elastic.co/apm/module/apmotel/v2@v2.5.0/tracer.go:116:36: cannot use s (variable of type *span) as trace.Span value in argument to trace.ContextWithSpan: *span does not implement trace.Span (missing method AddLink)
Error: ../../../go/pkg/mod/go.elastic.co/apm/module/apmotel/v2@v2.5.0/tracer.go:116:40: cannot use s (variable of type *span) as trace.Span value in return statement: *span does not implement trace.Span (missing method AddLink)
Error: ../../../go/pkg/mod/go.elastic.co/apm/module/apmotel/v2@v2.5.0/wrapper.go:53:36: cannot use &span{…} (value of type *span) as trace.Span value in argument to trace.ContextWithSpan: *span does not implement trace.Span (missing method AddLink)
Error: ../../../go/pkg/mod/go.elastic.co/apm/module/apmotel/v2@v2.5.0/wrapper.go:73:36: cannot use &span{…} (value of type *span) as trace.Span value in argument to trace.ContextWithSpan: *span does not implement trace.Span (missing method AddLink) (compile)

To Reproduce Steps to reproduce the behavior:

  1. create a project
  2. use apmotel and otel libs 1.21+
  3. run any go command (test, build, etc.)
  4. See error

Expected behavior No error

dmathieu commented 2 months ago

We need to add a (noop because we don't handle links) AddLink method to spans. https://github.com/open-telemetry/opentelemetry-go/pull/5032