-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
feat(otlp): Add python OTLP integration #15093
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
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 |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| --- | ||
| title: OpenTelemetry (OTLP) | ||
| description: "Learn about using OTLP to automatically send OpenTelemetry Traces to Sentry." | ||
| keywords: ["otlp", "otel", "opentelemetry"] | ||
| --- | ||
|
|
||
| The OTLP integration configures the Sentry SDK to automatically send trace data instrumented by an OpenTelemetry SDK to Sentry's [OpenTelemetry Protocol](https://opentelemetry.io/docs/specs/otel/protocol/) [ingestion endpoint](/concepts/otlp). | ||
|
|
||
| ## Install | ||
|
|
||
| Install `sentry-sdk` from PyPI with the `opentelemetry-otlp` extra. | ||
|
|
||
| ```bash {tabTitle:pip} | ||
| pip install "sentry-sdk[opentelemetry-otlp]" | ||
| ``` | ||
| ```bash {tabTitle:uv} | ||
| uv add "sentry-sdk[opentelemetry-otlp]" | ||
| ``` | ||
|
|
||
| ## Configure | ||
|
|
||
| You need to configure both the OpenTelemetry and Sentry SDKs to get trace data. | ||
|
|
||
| ### OpenTelemetry | ||
|
|
||
| For the OpenTelemetry SDK, you need to [configure instrumentation](https://opentelemetry.io/docs/languages/python/getting-started/#instrumentation) you want to capture. | ||
|
|
||
| ### Sentry | ||
|
|
||
| For the Sentry SDK, you simply need to enable our `OTLPIntegration` along with your existing configuration. | ||
|
|
||
| <OnboardingOptionButtons | ||
sl0thentr0py marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| options={["error-monitoring", "logs"]} | ||
| /> | ||
|
|
||
| ```python | ||
| import sentry_sdk | ||
| from sentry_sdk.integrations.otlp import OTLPIntegration | ||
|
|
||
| sentry_sdk.init( | ||
| dsn="___PUBLIC_DSN___", | ||
| # Add data like request headers and IP for users, if applicable; | ||
| # see https://docs.sentry.io/platforms/python/data-management/data-collected/ for more info | ||
| send_default_pii=True, | ||
| # ___PRODUCT_OPTION_START___ logs | ||
| # Enable logs to be sent to Sentry | ||
| enable_logs=True, | ||
| # ___PRODUCT_OPTION_END___ logs | ||
| integrations=[ | ||
| OTLPIntegration(), | ||
| ], | ||
| ) | ||
| ``` | ||
|
|
||
| ## Behavior | ||
|
|
||
| Under the hood, the `OTLPIntegration` will setup the following parts: | ||
|
|
||
| * A [`SpanExporter`](https://opentelemetry.io/docs/concepts/components/#exporters) that will automatically setup the OTLP ingestion endpoint from your Sentry DSN. This enables tracing in Sentry. **Note:** _Do not_ also set up tracing via the Python SDK. | ||
| * A [`Propagator`](https://opentelemetry.io/docs/concepts/context-propagation/#propagation) that ensures [distributed tracing](/concepts/key-terms/tracing/distributed-tracing/) works | ||
| * Trace/Span linking for all other Sentry events such as Errors, Logs, Crons and Metrics | ||
|
Contributor
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. Does it make sense to call out that Logs, Crons, and Metrics require additional config?
Member
Author
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 wouldn't call that out on this line since this is more like a under-the-hood how it works section titled |
||
|
|
||
| ## Supported Versions | ||
|
|
||
| - Python: 3.7+ | ||
| - opentelemetry-distro: 0.35b0+ | ||
Uh oh!
There was an error while loading. Please reload this page.