-
Notifications
You must be signed in to change notification settings - Fork 196
feat: suppress internal spans with Faraday instrumentation #1506
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,7 +40,13 @@ def call(env) | |
) do |span| | ||
OpenTelemetry.propagation.inject(env.request_headers) | ||
|
||
app.call(env).on_complete { |resp| trace_response(span, resp.status) } | ||
if config[:suppress_internal_instrumentation] | ||
OpenTelemetry::Common::Utilities.untraced do | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe that using untraced will suppress instrumentation for all child spans. Is this what you want? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, currently Faraday will generate child spans for its under-the-hood Net::Http instrumentation which creates an additional dependency metric for each request. We want to give the customer the option (preferably default) to suppress this. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see now, I misunderstood your goals here. You only want to retain Faraday client spans and skip any driver generated spans. Is that correct? I think that may be an invalid combination here where if the Faraday span is configured to generate I wonder then if what we want here is separate middleware implementations as opposed to conditional checks I.e. replacing conditional logic with polymorphism. That would likely couple the span kind setting to this suppression setting. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are you referring to the configuration below?
This may not make sense, but I think flexibility to configure the options separately is better. Some users may also want client spans where the internal instrumentation isn't suppressed for better transparency, which discourages the coupling of the two settings. Also, why do you prefer the polymorphism approach when the conditional is simple enough? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The more configuration options we offer the more complex the instrumentations are to understand for our users. The combination of having an
Yes, I agree that this conditional check is a minimal implementation but I also believe that the instrumentation should do the minimal possible to achieve its goal. The config option cannot change for the life of the instrumentation so we are checking it with each request. Yes, it will likely be optimized away by a JIT at some point and it's just a quick check, but for now anything we can remove from the users request path we should consider doing. Keep in mind that my comment was more of a nitpick and not a blocker. |
||
app.call(env).on_complete { |resp| trace_response(span, resp.status) } | ||
end | ||
else | ||
app.call(env).on_complete { |resp| trace_response(span, resp.status) } | ||
end | ||
rescue ::Faraday::Error => e | ||
trace_response(span, e.response[:status]) if e.response | ||
|
||
|
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.
What about adding an option here like
:none
?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.
Could you elaborate on this? The current behavior of setting the flag to false will ensure no spans are suppressed.