-
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
Named Tracers / Tracer Registry #582
Named Tracers / Tracer Registry #582
Conversation
Codecov Report
@@ Coverage Diff @@
## master #582 +/- ##
==========================================
+ Coverage 89.77% 89.85% +0.08%
==========================================
Files 215 214 -1
Lines 10137 10183 +46
Branches 936 933 -3
==========================================
+ Hits 9100 9150 +50
+ Misses 1037 1033 -4
|
…entelemetry-js into tracer-registry
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.
All of the comments I made during our essentially in person review were addressed, so ya went through this again and left a few comments but this LGTM. There's definitely a question of what to do with the tracer name and version but that's a separate issue.
Updated to be up-to-date with current spec https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/api-tracing.md#obtaining-a-tracer where name is required. When/if #345 merges we can revisit. It is easier to make name optional later than it is to make it required later. I'm removing the draft tag from this so we can begin the formal review process but other SIGs have already merged their named tracer implementations. |
#651 is merged now, could you please make this PR ready for review. Thanks :) |
Should be good to review now |
lint & docs is failing because david.dm is down again. It is not an actual failure. |
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.
lgtm, great work!
Please, resolve the conflicts. @open-telemetry/javascript-approvers This is relatively big and important change, we need more reviews for this. |
@mayurkale22 done |
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.
There is one thing which confuses me a lot
.getTracer('default’)
is the name required or can I use
.getTracer()
Do I always have to provide the default
name and if that is the case should the registry has the static value then. Or if I don’t need to provide the name then I would rather remove default
from all examples. If the default
is required I would still remove it and make it default name when nothing is provided.
Other than that looks fine
@@ -71,6 +71,7 @@ docs | |||
|
|||
#lerna | |||
.changelog | |||
package.json.lerna_backup |
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.
is this intentional ?
+1 I agreed. As per the specs: In case an invalid name (null or empty string) is specified, a working default Tracer implementation as a fallback is returned. With this, we can remove |
As @dyladan is on vacation for a week, I was thinking to merge this one and handle @obecny's recommendation/suggestion (#582 (review)) in the separate PR. @obecny WDYT? |
@mayurkale22 fine for me |
* feat: spike of named tracer registry * chore: mysql/mongo tracer registry support * fix: lint * chore: add getTracer back * chore: change default tracer name to empty string * fix: lint * chore: update examples for registry * chore(tracer-registry): make name required * chore: lint * chore: update examples for required tracer name * chore: remove unused tracer delegate * chore: remove references to basic tracer * chore: remove references to NodeTracer * chore: update xhr for tracer registry * chore: update tracer names to match package names * chore: add version script to all packages * chore: update plugins to use version script * chore: add jsdoc to noop tracer registry * chore: update ioredis for tracer registry * chore: update pg pool for tracer registry * fix: lint * chore: fix tests * chore: lint * chore: lint Co-authored-by: Mayur Kale <[email protected]>
Initial spike of spec/#354
Do not merge until the spec is finalized.
Which problem is this PR solving?
Open questions from spec
Short description of the changes
There is now only 1 type of Tracer. BasicTracer/WebTracer/NodeTracer are gone. The platform specific logic is moved into their respective registries.
BasicTracerRegistry
This is the base class for web and node tracer registries. It maintains span processors and all created tracers. Calling
getTracer(name, version)
will get the tracer with the given name and version, creating it if required. The default name is the empty string. The default version is'*'
getTracer('', '*')
is equivalent togetTracer()
getTracer('mysql', '*')
is equivalent togetTracer('mysql')
getTracer
with the same inputs twice will return the same tracergetTracer('mysql')
will return the same tracer asgetTracer('mysql', '*')
but NOT the same tracer asgetTracer('mysql', '0.2.0')
NodeTracerRegistry
BasicTracerRegistry
AsyncHooksScopeManager
by defaultWebTracerRegistry
BasicTracerRegistry
StackScopeManager
by defaultPlugins
Plugins are now expected to call
super
with a name and version. This is the name and version of the telemetry itself, NOT the name and version of the module being instrumented. For example, the mysql plugin callssuper('opentelemetry.mysql', '0.2.0')
.BasePlugin.enable
now expects aTracerRegistry
where it previously expected aTracer
. When a span is created by a tracer, it injects itself the same way it previously did, but delegates calls togetActiveSpanProcessor
to theTracerRegistry
that created it. In this way, span processors that are registered with aTracerRegistry
after a plugin has been enabled are still called by new spans.Core
initGlobalTracer
has been replaced byinitGlobalTracerRegistry
.getGlobalTracerRegistry
now exists to access the global tracer registry.getTracer
still exists and returns a tracer from the current global tracer registry.Tracer Options
The tracer registry is initialized with the same options that tracers were previously initialized with. It is possible to get a tracer with different options by passing an options object as a third argument to
getTracer
(const tracerWithLogger = registry.getTracer('mysql', '0.2.0', { logger });
). The global getTracer function does not have a third tracer options parameter and you will need to callregistry.getTracer
if you want that functionality.