-
Notifications
You must be signed in to change notification settings - Fork 47
feat: debug log global registrations and logger overwrites #63
feat: debug log global registrations and logger overwrites #63
Conversation
... that's to assure we really did register it, not only attempted. Any short-circuits will be logged as well, so the debug would be unneccessary in those cases.
e987ff2
to
a842976
Compare
a842976
to
15f4a08
Compare
Codecov Report
@@ Coverage Diff @@
## main open-telemetry/opentelemetry-js-api#63 +/- ##
==========================================
+ Coverage 94.66% 94.72% +0.06%
==========================================
Files 42 42
Lines 562 569 +7
Branches 94 96 +2
==========================================
+ Hits 532 539 +7
Misses 30 30
Continue to review full report at Codecov.
|
Really like this idea. Can be frustrating for users when they think they are loading a diag logger but it gets overwritten. Maybe it would be even worth getting the stack when it is overwritten? // use string as fallback in case stack can't be generated
const stack = new Error().stack ?? "<failed to generate stacktrace>"
oldLogger.warn(`A new DiagLogger was registered which overwrites this logger from ${stack}`); |
Having a stack is a really good idea as well. I'll add that here for now to keep the focus of the PR. Although... whenever I see variables in log messages I see a lost opportunity to structure the log entry:
EDIT I took the first point to discussions: #77 EDIT2 Thinking further about the global stack trace option made me think it's too much of an implementation/maintenance burden(stack traces should probably be manipulated if they are generated outside of the actual function we want to point to) for very little gain if we have structured logging. |
… into feat/add-global-debugging
… into feat/add-global-debugging
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, thx for changes
Currently, there's no visibility to global registration which is a relatively important operation.
For example, there's no way to know if a logger has been overwritten or not which might mean the successive log messages/errors from other parts of the API might not be appearing without the developer's knowledge.
To relieve that, a few log statements were added:
warn
log line about the event.debug
log line is created with the type and version.It relieves the immediate pain described in open-telemetry/opentelemetry-js#3313