-
Notifications
You must be signed in to change notification settings - Fork 825
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
feat(trace): named tracer factory prototype 2 #434
Conversation
} | ||
|
||
// @todo | ||
// addSpanProcessor(spanProcessor: SpanProcessor): void { } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I take it that this would be applied to all tracers in the set and to all new tracers created afterwards?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, correct.
Codecov Report
@@ Coverage Diff @@
## master #434 +/- ##
==========================================
- Coverage 95.88% 95.87% -0.02%
==========================================
Files 108 108
Lines 5347 5333 -14
Branches 433 435 +2
==========================================
- Hits 5127 5113 -14
Misses 220 220
|
Are there good reasons for the redundancy between |
LGTM |
The duplication between class AbstractTracerFactory<T extends types.Tracer> implements types.TracerFactory {
private static _singletonInstance: types.TracerFactory;
private readonly _tracers: Map<String, T> = new Map();
protected abstract create(): T;
getTracer(name: string = "", version?: string): T {
const key = name + (version != undefined ? version : "");
if (this._tracers.has(key)) return this._tracers.get(key)!;
const tracer = this.create();
this._tracers.set(key, tracer);
return tracer;
}
static get instance(): types.TracerFactory {
return this._singletonInstance || (this._singletonInstance = new this());
}
}
class NodeTracerFactory extends AbstractTracerFactory<NodeTracer> {
protected create() {
return new NodeTracer();
}
}
class BasicTracerFactory extends AbstractTracerFactory<BasicTracer> {
protected create() {
return new BasicTracer();
}
} |
Closing this in favor of #420 |
Which problem is this PR solving?
Original PR: feature(trace): adds named tracer factory #420
This is my take (just a prototype) on named tracers for Implement Named Tracers #403.
The factories (
TracerFactory
andMeterFactory
) need to be a singleton object as ubiquitous points to requestTracer
andMeter
instances.I just updated the basic example to show the actual usage.
/cc @bg451