-
Notifications
You must be signed in to change notification settings - Fork 538
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: router instrumentation #458
feat: router instrumentation #458
Conversation
Codecov Report
@@ Coverage Diff @@
## main #458 +/- ##
=======================================
Coverage 95.26% 95.26%
=======================================
Files 140 140
Lines 8399 8399
Branches 815 815
=======================================
Hits 8001 8001
Misses 398 398 |
8c5cb3a
to
da8b175
Compare
plugins/node/opentelemetry-instrumentation-router/src/version.ts
Outdated
Show resolved
Hide resolved
plugins/node/opentelemetry-instrumentation-router/test/index.test.ts
Outdated
Show resolved
Hide resolved
plugins/node/opentelemetry-instrumentation-router/src/instrumentation.ts
Show resolved
Hide resolved
plugins/node/opentelemetry-instrumentation-router/test/index.test.ts
Outdated
Show resolved
Hide resolved
plugins/node/opentelemetry-instrumentation-router/src/instrumentation.ts
Outdated
Show resolved
Hide resolved
3a7d6ae
to
ffa6735
Compare
Please avoid force push after 1st review, it is impossible to track changes |
Co-authored-by: Bartlomiej Obecny <[email protected]>
Doesn't necessarily belong here, but I'll just add it since I did the same for the package in hand.
plugins/node/opentelemetry-instrumentation-router/src/instrumentation.ts
Outdated
Show resolved
Hide resolved
plugins/node/opentelemetry-instrumentation-router/src/instrumentation.ts
Outdated
Show resolved
Hide resolved
plugins/node/opentelemetry-instrumentation-router/src/instrumentation.ts
Outdated
Show resolved
Hide resolved
|
||
utils.renameHttpSpan(parentSpan, layer.method, route); | ||
// make sure spans are ended at least when response is finished | ||
res.prependOnceListener('finish', () => span.end()); |
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.
|
||
utils.renameHttpSpan(parentSpan, layer.method, route); | ||
// make sure spans are ended at least when response is finished | ||
res.prependOnceListener('finish', () => span.end()); |
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 couldn't find the discussion in #416 but ending twice the span isn't technically a noop because its log a warning to the diag logger.
Now that isn't enabled by default isn't a problem for all users but i suspect it will for people having it enabled (see #107 or open-telemetry/opentelemetry-js#2126 for exemple).
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, thanks for the changes
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, agree that renameHttpSpanName
was a bit much.
const deepRouter = new Router(); | ||
|
||
deepRouter.use('/hello', helloRouter); | ||
router.use('/deep', deepRouter); |
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 like the thinking behind this test (setup)!
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
@open-telemetry/javascript-maintainers Can this be merged now? |
Which problem is this PR solving?
This adds auto instrumentation for pillarjs/router, which is almost identical to the router implementation used in Express.
Ideally, if possible, those two instrumentations should share code(thoughts on that?), but this is not currently the case because
Short description of the changes
Instead of wrapping each handler passed to the router, I'm patching two functions on
Layer
to plug into the core of the routers work.