Skip to content

Commit be02830

Browse files
committed
add flag to suppress downstream instrumentation
1 parent fed9a0f commit be02830

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

instrumentation/faraday/lib/opentelemetry/instrumentation/faraday/instrumentation.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ class Instrumentation < OpenTelemetry::Instrumentation::Base
2828

2929
option :span_kind, default: :client, validate: %i[client internal]
3030
option :peer_service, default: nil, validate: :string
31+
option :suppress_internal_instrumentation, default: false, validate: :boolean
3132

3233
private
3334

instrumentation/faraday/lib/opentelemetry/instrumentation/faraday/middlewares/tracer_middleware.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,13 @@ def call(env)
4040
) do |span|
4141
OpenTelemetry.propagation.inject(env.request_headers)
4242

43-
app.call(env).on_complete { |resp| trace_response(span, resp.status) }
43+
if config[:suppress_internal_instrumentation]
44+
OpenTelemetry::Common::Utilities.untraced do
45+
app.call(env).on_complete { |resp| trace_response(span, resp.status) }
46+
end
47+
else
48+
app.call(env).on_complete { |resp| trace_response(span, resp.status) }
49+
end
4450
rescue ::Faraday::Error => e
4551
trace_response(span, e.response[:status]) if e.response
4652

0 commit comments

Comments
 (0)