-
Notifications
You must be signed in to change notification settings - Fork 821
New issue
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
Implement Named Tracers #403
Comments
This is turning out to be a much bigger code change than expected, especially around the node SDK. Following the specification instructions, I started by adding a getTracer(name?: string, version?: string) {
return globalTracerFactoryDelegate.getTracer(name, string);
} so that, ergonomically, existing code feels the same. However, for the node and basic tracer code, a kind of ugly issue rears its head when it comes to sharing exporters among tracers created by the tracer factory. Let's say that we have a simple sdk factory: class BasicTracerFactory implements types.TracerFactory {
constructor(config: BasicTracerConfig) {
this._defaultConfig = config;
this._defaultTracer = new BasicTracer(config);
}
getTracer(name?: string, version?: string) {
return this._defaultTracer
}
} If we add an exporter, all we have to do is getTracer(name? : string, version?: string) {
if (name) {
// this would probably be more like a get or create tracer operation
return new BasicTracer({ name: name, config...})
}
return this._defaultTracer;
} span processors added via Instead of using a factory, I propose adding a new method to Thoughts @open-telemetry/node-approvers @draffensperger @dyladan> |
@bg451 would you expect span processors added via |
@dyladan Yeah I would. The person using |
This just feels like deviating from the spec a little too much for me. Could the tracer factory return a wrapper class around the global tracer that implemented naming but delegated everything else to the wrapped tracer? FWIW the ruby implementation also would not satisfy your constraint open-telemetry/opentelemetry-ruby#114. I didn't find another OpenTelemetry language that has implemented named tracers/meters yet. Reading through their PR conversation and the associated issue, it seems pretty clear that they don't understand the need for named tracers or what they may be used for. The OTEP and associated spec PR is really unhelpful in this regard. Maybe @z1c0 can be of some help here since he wrote the OTEP and the spec around it. I must admit the named tracers/meters spec left me with more questions than answers and it seems I am not the only one. |
The otep provides an example of something similar in the Prior art section:
My understanding of named tracers is that traditionally 3rd party libraries ould instrument themselves with opentracing and use the global tracer. This way, users could also get visibility of what was happening in their dependencies. There was this tag in opentracing called component that would specify where the instrumentation was, so all spans created in and by gRPC or express or node-mongodb-native would have the tag edit: |
I think this is worth bringing up to the specification because it is really not clear what the desired side effects are. |
Why is it not ideal? If tracers are moving one level down by becoming namespaced (instead of being a singleton), then exporters naturally have to move one level up, to the factory. |
Can we simply allow two things so you would be able to inject the exporter during the initialisation, but we can add function to tracer to update this at any given time too in case you want to use a different exporter later. |
I think it is probably worth bringing up with spec. Even if we decide what we want, the spec should make it more clear than it does. If the spec isn't cleared up, then different implementations may have different behaviors as we already see with the Ruby PR implementing in a naive way that would not share span processors among multiple tracers. Aconst defaultTracer = TracerFactory.getTracer().addSpanProcessor(p1);
const httpTracer = TracerFactory.getTracer('http'); // Should this tracer contain p1? Bconst httpTracer = TracerFactory.getTracer('http').addSpanProcessor(p1);
const defaultTracer = TracerFactory.getTracer(); // Should this tracer contain p1? Cconst defaultTracer = TracerFactory.getTracer();
const httpTracer = TracerFactory.getTracer('http');
defaultTracer.addSpanProcessor(p1)
// should httpTracer contain p1?
|
All 3 are incorrect. |
As @yurishkuro said, all 3 are incorrect.
Maybe the .NET implementation helps (open-telemetry/opentelemetry-dotnet#239) |
Thank you @z1c0 that's what I thought but I wanted to make sure. Perhaps the spec should mention that setting span processor moves to the factory in order to minimize confusion between implementations. In this case, the ruby implementation needs to be amended. The current version (https://github.com/open-telemetry/opentelemetry-ruby/blob/7122835f6cc874e02d75e94078dafce6cbb4a99c/sdk/lib/opentelemetry/sdk/trace/tracer_factory.rb) does not have a mechanism to set the span processor on the tracer factory. |
Thanks @dyladan, I can see how this causes confusion. |
I personally like the That said, I agree we should discuss this in the spec. Being the first language to implement this also feels tricky since we are the first real tester of it. |
@draffensperger Ruby and .NET also have implemented but Ruby is a very minimal implementation. .NET was implemented by the OTEP and spec writer.
|
If I understand correctly in my case it should look like this
instead of what I like much more and I think is more intuitive and natural for js
ConsoleExporter - just a simple exporter to show spans in console nothing fancy so far |
Okay I'm going to continue forward with the factory approach, but I agree with @obecny that the exporter should go into the configuration of the tracer. |
I don't see any reason that both can't work. That would be a question for specification though. I think @z1c0 is going to bring it up with them, but maybe we should make an issue to track these types of questions. |
The question where these configurations objects need to go, seems to be highly controversial. I think we need to be very clear in the specification on this, so I created an issue in the specification repository. We should continue this discussion there: open-telemetry/opentelemetry-specification#304 |
Named Tracer is implemented via #582, closing this one. Will open a separate issue for Named Meter. |
Signed-off-by: Andrea Di Giorgi <[email protected]>
Co-authored-by: Valentin Marchaud <[email protected]>
The "Named Tracers and Meters" RFC (https://github.com/open-telemetry/oteps/blob/master/text/0016-named-tracers.md) has been approved and was added to the specification (open-telemetry/opentelemetry-specification#264).
Please make sure to also update the documentation if necessary (tracer, meter creation).
OpenTelemetry language repositories now need to implement this mechanisms.
The text was updated successfully, but these errors were encountered: