OpenTelemetry (OTLP)
Learn about using OTLP to automatically send OpenTelemetry Traces to Sentry.
The OTLP integration configures the Sentry SDK to automatically send trace data instrumented by an OpenTelemetry SDK to Sentry's OpenTelemetry Protocol ingestion endpoint.
Add the following gems to your Gemfile:
gem "sentry-ruby"
gem "sentry-opentelemetry"
gem "opentelemetry-sdk"
gem "opentelemetry-exporter-otlp"
# Add any OpenTelemetry instrumentation gems you need, for example:
gem "opentelemetry-instrumentation-all"
Then run:
bundle install
You need to configure both the OpenTelemetry and Sentry SDKs to get trace data.
For the OpenTelemetry SDK, you need to configure instrumentation you want to capture.
OpenTelemetry::SDK.configure do |c|
c.use_all # or configure specific instrumentations
end
For the Sentry SDK, enable the OTLP integration in your existing configuration.
Sentry.init do |config|
config.dsn = "___PUBLIC_DSN___"
# Add data like request headers and IP for users, if applicable;
# see https://docs.sentry.io/platforms/ruby/data-management/data-collected/ for more info
config.send_default_pii = true
config.otlp.enabled = true
end
Under the hood, the OTLP integration sets up the following parts:
- A
SpanExporterthat automatically configures the OTLP ingestion endpoint from your Sentry DSN. This enables tracing in Sentry. Note: Do not also set up tracing via the Ruby SDK (i.e. do not settraces_sample_rateorinstrumenter). - A
Propagatorthat ensures distributed tracing works - Trace/Span linking for all other Sentry events such as Errors, Logs, Crons and Metrics
You can configure the following options on config.otlp:
enabled:Enable the OTLP integration, defaults to
false.setup_otlp_traces_exporter:Automatically configure an Exporter to send OTLP traces to the right project from the DSN, defaults to
true.Set to
falseif using a custom collector or to set up the TracerProvider manually.setup_propagator:Automatically configure the Sentry Propagator for Distributed Tracing, defaults to
true.Set to
falseto configure propagators manually or to disable propagation.
- Ruby: 2.7+
- sentry-ruby: 6.4.0+
- opentelemetry-sdk: 1.0+
Our documentation is open source and available on GitHub. Your contributions are welcome, whether fixing a typo (drat!) or suggesting an update ("yeah, this would be better").