-
Notifications
You must be signed in to change notification settings - Fork 316
RFC: Add an extension to Tracer interface for custom go context creation #220
Conversation
Are you referring to an adapter that supports the OpenTracing API but internally is implemented with OpenTelemetry SDK? I think I understand the reason for this proposal (OTel SDK method requires Context as argument), but it doesn't seem like it would make any difference since the typical OpenTracing instrumentation is not going to use the new Ext1 API. |
If adapter returns OpenTracing Span that wraps OTel span, and OpenTracing traditional instrumentation then stores that span in Context, then it may still be compatible with future use. Maybe there needs to be a method in OTel that accepts parent span directly, instead of always going through Context (that method could be in a separate migration-specific interface). |
Yes. For now it's available as a PR in open-telemetry/opentelemetry-go#98
My impression was that while the root span might be created with the tracer.CreateSpan, then the children spans are created by
Do you mean something like following in OpenTelemetry? type TracerMigration interface {
Tracer
StartWithSpan(parent Span, name string, o ...SpanOption) Span
} There might be a weakness in it that OTel won't be able to store whatever it wants in the go context created (like current span) by |
Yes , like that interface (only it doesn't need to embed Tracer). Also, I'm not sure what the plans are, but storing more things in the context than the Span doesn't sound like a good idea. |
Re StartSpanFromContext helper functions - they are just that, helpers. I've seen plenty of instrumentation that doesn't use those. I personally tend to avoid them because they depend on global tracer, which is a bad and infectious pattern. |
I thought about it some more and think we can probably avoid any changes in opentracing to get the shim support we need for OTel. I think there are four cases, where the parent span equals OTr or OTel, and where the start API equals OTr or OTel. The OTr->OTr and OTel->OTel cases should be trivial. For an OTel start with an OTr parent, we have the For an OTr start with an OTel parent, we have to use I haven't thought exhaustively through the cases, but this may be feasible. |
The new TracerContextWithSpanExtension interface provides a way to hook into the ContextWithSpan function, so the implementation can put some extra information to the context. The opentracing to opentelemetry bridge needs the context to set the current opentelemetry span, so the opentelemetry API in the layer below the one using opentracing can still get the right parent span.
So the implementation can still affect the way the go context is set up.
9e8b5fd
to
60fbc08
Compare
Codecov Report
@@ Coverage Diff @@
## master #220 +/- ##
=========================================
Coverage ? 59.54%
=========================================
Files ? 14
Lines ? 833
Branches ? 0
=========================================
Hits ? 496
Misses ? 297
Partials ? 40
Continue to review full report at Codecov.
|
This extension API is used internally, not by end-user code. When upgrading to OTel, this OT dependency will be brought in automatically. We need not bump the minor version number in the next release, even, but this code (or something similar) is necessary to support the OTel bridge. |
In the opentracing to opentelemetry bridge we need to have an access to the go context when creating the span (see https://github.com/open-telemetry/opentelemetry-go/blob/eed647d11f57d72d7cfa3e1d25721e21e4a0c833/api/trace/api.go#L29-L30)
This new interface adds the
StartSpanWithContext
function, so the vendor can implement it in their own way.Still not sure if this is the final extension we may need for the bridge, but that's the starter.
cc: @jmacd