-
Notifications
You must be signed in to change notification settings - Fork 533
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(pg): add requireParentSpan option #1199
Conversation
I accidentally duplicated the feature (with a slightly different implementation) in #1211, I closed that one and am willing to help with this one, how can I be useful? From just the looks of it, the code changes make sense, if anything, maybe the test coverage could be better for |
Looks like the CLA isn't signed. Please sign it.
code reviews are always helpful |
plugins/node/opentelemetry-instrumentation-pg/src/instrumentation.ts
Outdated
Show resolved
Hide resolved
Co-authored-by: Henri Normak <henri.normak@gmail.com>
@henrinormak Thanks so much for your comments. It's my first time working with the opentelemetry code, and your comments were very helpful. |
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.
Other instrumentations call this feature requireParentSpan
- see dataloader, ioredis or redis for example. If I'm not mistaken, and it is the same feature, we should call it with the same name for ease of use.
We often implement it slightly different as well - short-circuiting into the original function if the option is enabled and there's no parent. Not saying this implementation should be changed, but just interested in your thoughts about whether it would be viable option here and if there's any benefits going with either approach.
Thanks, @henrinormak, for the quality review. These are super helpful.
I would also prefer that naming and approach, although I don't have a strong preference, TBH, when I read the PR description, I mistakenly thought it was named like this in the referred other instrumentations as well. |
I'm a little confused -- it's called
I'm new to opentelemetry, but my understanding is that the approach I used here (copied from instrumentation-http) is creating a placeholder span with an invalid context so that it is eventually discarded. However, child spans can be attached to this placeholder span. That way, if there are some child spans generated as a result of some |
I think it was because you named the PR
I believe Rauno was refering to the usage of the non-recording span, which is used in the http instrumentation to still propagate context for outgoing requests without creating a span locally, i'm not sure we need this as we don't propagate the context to pg itself but i agree that it doesn't hurt anything to do so |
Which problem is this PR solving?
The current pg autoinstrumentation creates spans for any postgres connection or query, even if this is not part of an active context. This generates a large number of extraneous spans that we don't care about, and opentelemetry currently doesn't have good support for filtering these out.
Short description of the changes
This PR adds a
requireParentTrace
configuration option that will prevent the autoinstrumentation from generating root-level traces. Similar options already exist in instrumentation-http, instrumentation-ioredis, instrumentation-mongoose, and others.The implementation is based on the implementation in opentelemetry-instrumentation-http.
Checklist
npm run test-all-versions
for the edited package(s) on the latest commit if applicable.