-
Notifications
You must be signed in to change notification settings - Fork 572
ref: Move OTel setup out of integrations/opentelemetry/
#4277
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 37 commits
4b3284c
7741c64
cf28b7b
f34b066
841bd02
38f6886
2a554c3
5d6e318
89ae39e
8819373
3f02f56
db2f1b6
38b051e
5d9dc58
5e26e54
c29719c
ea89a5a
1c93520
67d3117
33709ef
3c52872
b10193d
6858c98
5b3376d
d16e026
94ba998
29500ac
3a2b671
2e5e4ff
c06464e
74bad19
cc517fe
0d337be
a25e3c3
21c0f6b
43d85d6
9085d7b
3fcbeee
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 |
|---|---|---|
|
|
@@ -29,7 +29,7 @@ jobs: | |
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| python-version: ["3.7","3.8","3.9","3.10","3.11","3.12","3.13"] | ||
| python-version: ["3.7","3.8","3.10","3.11","3.12","3.13"] | ||
| os: [ubuntu-22.04] | ||
| steps: | ||
| - uses: actions/[email protected] | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -35,6 +35,7 @@ | |
| from sentry_sdk.integrations.dedupe import DedupeIntegration | ||
| from sentry_sdk.sessions import SessionFlusher | ||
| from sentry_sdk.envelope import Envelope | ||
|
|
||
| from sentry_sdk.profiler.continuous_profiler import setup_continuous_profiler | ||
| from sentry_sdk.profiler.transaction_profiler import ( | ||
| has_profiling_enabled, | ||
|
|
@@ -392,6 +393,13 @@ def _capture_envelope(envelope): | |
| except Exception as e: | ||
| logger.debug("Can not set up continuous profiler. (%s)", e) | ||
|
|
||
| from sentry_sdk.opentelemetry.integration import ( | ||
|
||
| patch_readable_span, | ||
| setup_sentry_tracing, | ||
| ) | ||
|
|
||
| patch_readable_span() | ||
| setup_sentry_tracing() | ||
| finally: | ||
| _client_init_debug.set(old_debug) | ||
|
|
||
|
|
||
This file was deleted.
|
Member
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. [suggestion] We should call this file something other than
Contributor
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. Suggestions welcome -- I think going with 'integration' would still be ok since we're integrating with OTel in that file but I agree it can be confusing to folks.
Member
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. Agreed naming is hard – maybe we can call it I just think
Contributor
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 also considered
Contributor
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. Called it |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| from opentelemetry import trace | ||
| from opentelemetry.propagate import set_global_textmap | ||
| from opentelemetry.sdk.trace import TracerProvider, Span, ReadableSpan | ||
|
|
||
| from sentry_sdk.opentelemetry import ( | ||
| SentryPropagator, | ||
| SentrySampler, | ||
| SentrySpanProcessor, | ||
| ) | ||
|
|
||
|
|
||
| def patch_readable_span(): | ||
| # type: () -> None | ||
| """ | ||
| We need to pass through sentry specific metadata/objects from Span to ReadableSpan | ||
| to work with them consistently in the SpanProcessor. | ||
| """ | ||
| old_readable_span = Span._readable_span | ||
|
|
||
| def sentry_patched_readable_span(self): | ||
| # type: (Span) -> ReadableSpan | ||
| readable_span = old_readable_span(self) | ||
| readable_span._sentry_meta = getattr(self, "_sentry_meta", {}) # type: ignore[attr-defined] | ||
| return readable_span | ||
|
|
||
| Span._readable_span = sentry_patched_readable_span # type: ignore[method-assign] | ||
|
|
||
|
|
||
| def setup_sentry_tracing(): | ||
| # type: () -> None | ||
| provider = TracerProvider(sampler=SentrySampler()) | ||
| provider.add_span_processor(SentrySpanProcessor()) | ||
| trace.set_tracer_provider(provider) | ||
|
|
||
| set_global_textmap(SentryPropagator()) |
Uh oh!
There was an error while loading. Please reload this page.