-
Notifications
You must be signed in to change notification settings - Fork 624
feat(instrumentation-ioredis): add request hook #415
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(instrumentation-ioredis): add request hook #415
Conversation
|
Is there semconv spec for this? |
no, this is why we allow the user to specify the attribute name and not using hardcoded value |
Codecov Report
@@ Coverage Diff @@
## main #415 +/- ##
==========================================
+ Coverage 95.21% 95.23% +0.01%
==========================================
Files 133 133
Lines 8178 8223 +45
Branches 804 807 +3
==========================================
+ Hits 7787 7831 +44
- Misses 391 392 +1
|
|
There used to be a semconv for the |
It could be great. Do you mean the general opentelemetry specification? or convention only for the javascript? |
I mean the opentelemetry specification |
|
plugins/node/opentelemetry-instrumentation-ioredis/src/ioredis.ts
Outdated
Show resolved
Hide resolved
plugins/node/opentelemetry-instrumentation-ioredis/src/utils.ts
Outdated
Show resolved
Hide resolved
|
I think it might take time for this feature to enter spec. |
|
@blumamir sorry for slow response i was out for part of last week.
I'm not sure what exactly you mean by this. The current implementation looks fine to me and I was about to approve actually (pending broken tests) before I saw this comment. Do you mean like this? class IoredisInstrumentation extends ... {
// ...
// register a hook to add custom attributes to spans
onRequest((req: Request, span: Span) => void): void;
} |
I was thinking to add it to the hook function parameters like this: export interface IORedisInstrumentationConfig extends InstrumentationConfig {
requestHook?: (span: Span, ioredisVersion: string, /** other params */) => void;
}and then instrumentation user can write hook that adds the span attribute under whatever name he desires: new IORedisInstrumentation({
requestHook: (span: Span, ioredisVersion: string) => {
span.setAttribute('whatever.name.user.want', ioredisVersion);
}
});Hope the syntax is right, I wrote it here without validating it. I'm ok with both the |
|
Would actually make sense to make it on instrumentation level a general hook ?. |
Think this is quite dependent on each instrumentation I think in terms of what would be useful (http instrumentation hook might need the request object, mysql hook might need the query and the connection). If only the span is sent to the hook, it might not be enough information for the user to add the things that are important to them. |
|
whoops @dyladan I think I edited yr response, fixed :/
Yea but we can think of general implementation in instrumentation and if you need more information from certain instrumentation then extend it I'm not saying we have to do it now, but to avoid adding more less the same to many instrumentations we can think if creating some general and simply add more info in specific instrumentations. The advantage would be that you will have one hook that exists always, so it will be easier to unify things |
|
I think it most likely can be done in a mostly general way |
|
@obecny - if we can generalize it that would be awesome. In the past, I was experimenting with collecting stack trace per span (to help correlate the span to the code), and I did it with "require-in-the-middle" patching the tracer |
Maybe create some observer / subscriber / interceptor solution (in tracer / provider) that would allow to make such things. In the worst scenario basically patching our tracer startSpan, but I didn't analyse it deeply yet. I know this can be done and could be quite useful for end users. |
|
@blumamir with regards to I think this is the best approach I would just change one thing The reason is that it will be easier to add / change things in future and to avoid having too many params being added as next param. I can imagine someone else would be willing to export more data one day. |
@obecny Cool I think it's a good approach as well. Thank you for reviewing. |
|
@obecny - Update the PR to work with hooks like you suggested |
|
The failing checks are not related to this PR |
obecny
left a comment
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, just the name of interface should start with IO not the Io, the rest are minor
plugins/node/opentelemetry-instrumentation-ioredis/src/types.ts
Outdated
Show resolved
Hide resolved
obecny
left a comment
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
…y-js-contrib into ioredis-module-version-attribute-name
…y-js-contrib into ioredis-module-version-attribute-name
Which problem is this PR solving?
fixes #411
ioredisinstrumentation: support capturing the instrumentedioredispackage version and set it as span attribute.Short description of the changes