Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion instrumentation/faraday/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ To install the instrumentation, call `use` with the name of the instrumentation.

```ruby
OpenTelemetry::SDK.configure do |c|
c.use 'OpenTelemetry::Instrumentation::Faraday'
c.use 'OpenTelemetry::Instrumentation::Faraday', {
enable_internal_instrumentation: false
}
end
```

Expand All @@ -30,6 +32,11 @@ OpenTelemetry::SDK.configure do |c|
end
```

### Configuration options
This instrumentation offers the following configuration options:
* `enable_internal_instrumentation` (default: `false`): When set to `true`, any spans with
span kind of `internal` are included in traces.

## Examples

Example usage of faraday can be seen in the [`./example/faraday.rb` file](https://github.com/open-telemetry/opentelemetry-ruby-contrib/blob/main/instrumentation/faraday/example/faraday.rb)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class Instrumentation < OpenTelemetry::Instrumentation::Base

option :span_kind, default: :client, validate: %i[client internal]
option :peer_service, default: nil, validate: :string
option :enable_internal_instrumentation, default: false, validate: :boolean

private

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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[:enable_internal_instrumentation] == false
OpenTelemetry::Common::Utilities.untraced do
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

Expand Down