Skip to content
Merged
Show file tree
Hide file tree
Changes from 37 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
4b3284c
ref: Move sampler out of integrations/opentelemetry
sentrivana Apr 9, 2025
7741c64
ref: Move span processor out from integrations
sentrivana Apr 9, 2025
cf28b7b
ref: Move propagator out of integrations
sentrivana Apr 9, 2025
f34b066
forgot one
sentrivana Apr 9, 2025
841bd02
move to opentelemetry
sentrivana Apr 10, 2025
38f6886
Merge branch 'potel-base' into ivana/move-sampler-from-integration
sentrivana Apr 10, 2025
2a554c3
move to opentelemetry/
sentrivana Apr 10, 2025
5d6e318
alphabet
sentrivana Apr 10, 2025
89ae39e
move to opentelemetry/
sentrivana Apr 10, 2025
8819373
fix setup.py
sentrivana Apr 10, 2025
3f02f56
Merge branch 'potel-base' into ivana/potel/move-span-processor-out-of…
sentrivana Apr 10, 2025
db2f1b6
formatting
sentrivana Apr 10, 2025
38b051e
Merge branch 'ivana/potel/move-span-processor-out-of-integration' int…
sentrivana Apr 10, 2025
5d9dc58
ref: Move contextvars_context out of integrations
sentrivana Apr 10, 2025
5e26e54
remove comment
sentrivana Apr 10, 2025
c29719c
ref: Move utils, consts out of integrations/opentelemetry/
sentrivana Apr 10, 2025
ea89a5a
get rid of circ deps
sentrivana Apr 10, 2025
1c93520
fix test
sentrivana Apr 10, 2025
67d3117
.
sentrivana Apr 10, 2025
33709ef
.
sentrivana Apr 10, 2025
3c52872
make apidocs happy
sentrivana Apr 10, 2025
b10193d
Merge branch 'potel-base' into ivana/potel/move-span-processor-out-of…
sentrivana Apr 10, 2025
6858c98
ref: Move otel scope out of `integrations/opentelemetry/`
sentrivana Apr 10, 2025
5b3376d
Merge branch 'ivana/potel/move-span-processor-out-of-integration' int…
sentrivana Apr 10, 2025
d16e026
Merge branch 'ivana/potel/move-propagator' into ivana/potel/move-cont…
sentrivana Apr 10, 2025
94ba998
Merge branch 'ivana/potel/move-context-sync' into ivana/potel/move-mo…
sentrivana Apr 10, 2025
29500ac
Merge branch 'ivana/potel/move-more-otel-stuff' into ivana/potel/move…
sentrivana Apr 10, 2025
3a2b671
.
sentrivana Apr 10, 2025
2e5e4ff
ref: Move integration out of `opentelemetry/integrations/`
sentrivana Apr 10, 2025
c06464e
delete integrations/opentelemetry
sentrivana Apr 10, 2025
74bad19
move tests too
sentrivana Apr 10, 2025
cc517fe
remove test targets
sentrivana Apr 10, 2025
0d337be
move
sentrivana Apr 10, 2025
a25e3c3
Merge branch 'potel-base' into ivana/potel/move-integration
sentrivana Apr 14, 2025
21c0f6b
extra newline
sentrivana Apr 14, 2025
43d85d6
.
sentrivana Apr 14, 2025
9085d7b
.
sentrivana Apr 14, 2025
3fcbeee
rename to tracing
sentrivana Apr 15, 2025
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
2 changes: 1 addition & 1 deletion .github/workflows/test-integrations-misc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
14 changes: 0 additions & 14 deletions scripts/populate_tox/tox.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,6 @@ envlist =
{py3.9,py3.11,py3.12}-openai-latest
{py3.9,py3.11,py3.12}-openai-notiktoken

# OpenTelemetry (OTel)
{py3.7,py3.9,py3.12,py3.13}-opentelemetry

# OpenTelemetry Experimental (POTel)
{py3.8,py3.9,py3.10,py3.11,py3.12,py3.13}-potel

# pure_eval
{py3.7,py3.12,py3.13}-pure_eval

Expand Down Expand Up @@ -310,12 +304,6 @@ deps =
openai-latest: tiktoken~=0.6.0
openai-notiktoken: openai

# OpenTelemetry (OTel)
opentelemetry: opentelemetry-distro

# OpenTelemetry Experimental (POTel)
potel: -e .[opentelemetry-experimental]

# pure_eval
pure_eval: pure_eval

Expand Down Expand Up @@ -441,8 +429,6 @@ setenv =
loguru: TESTPATH=tests/integrations/loguru
openai: TESTPATH=tests/integrations/openai
openfeature: TESTPATH=tests/integrations/openfeature
opentelemetry: TESTPATH=tests/integrations/opentelemetry
potel: TESTPATH=tests/integrations/opentelemetry
pure_eval: TESTPATH=tests/integrations/pure_eval
pymongo: TESTPATH=tests/integrations/pymongo
pyramid: TESTPATH=tests/integrations/pyramid
Expand Down
8 changes: 8 additions & 0 deletions sentry_sdk/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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 (
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This inline import is not great but having this on the top level causes Sphinx to fail and I've already spent too much time trying to fix this. (Ideas welcome)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have two possible ideas:

  • Import the sentry_sdk.opentelemetry.integration module at the top, then call the methods on the module
  • Move the import to the bottom of the file in a "circular imports" section (I believe we have used this pattern elsewhere before, so it is likely preferable to an inline import if possible to do)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Neither of those works, unfortunately. They lead to more Sphinx errors.

patch_readable_span,
setup_sentry_tracing,
)

patch_readable_span()
setup_sentry_tracing()
finally:
_client_init_debug.set(old_debug)

Expand Down
1 change: 0 additions & 1 deletion sentry_sdk/integrations/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ def iter_default_integrations(with_auto_enabling_integrations):
"sentry_sdk.integrations.excepthook.ExcepthookIntegration",
"sentry_sdk.integrations.logging.LoggingIntegration",
"sentry_sdk.integrations.modules.ModulesIntegration",
"sentry_sdk.integrations.opentelemetry.integration.OpenTelemetryIntegration",
"sentry_sdk.integrations.stdlib.StdlibIntegration",
"sentry_sdk.integrations.threading.ThreadingIntegration",
]
Expand Down
Empty file.
80 changes: 0 additions & 80 deletions sentry_sdk/integrations/opentelemetry/integration.py

This file was deleted.

35 changes: 35 additions & 0 deletions sentry_sdk/opentelemetry/integration.py
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[suggestion] We should call this file something other than integration.py, since Opentelemetry is part of the SDK now, and no longer an integration.

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed naming is hard – maybe we can call it setup or something like that, given that it sets up the link with Otel?

I just think integration is particularly confusing here. While it is true that we "integrate" with Opentelemetry, the terminology is confusing because in the SDK codebase, "integration" usually means an optional integration with a library like FastAPI, Celery, etc.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also considered setup but having a setup.py file is also not great 🫠

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Called it tracing.py now since it sets up OTel tracing

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())
16 changes: 1 addition & 15 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
# The file (and all resulting CI YAMLs) then need to be regenerated via
# "scripts/generate-test-files.sh".
#
# Last generated: 2025-04-10T12:24:07.555804+00:00
# Last generated: 2025-04-10T13:32:09.968256+00:00

[tox]
requires =
Expand Down Expand Up @@ -107,12 +107,6 @@ envlist =
{py3.9,py3.11,py3.12}-openai-latest
{py3.9,py3.11,py3.12}-openai-notiktoken

# OpenTelemetry (OTel)
{py3.7,py3.9,py3.12,py3.13}-opentelemetry

# OpenTelemetry Experimental (POTel)
{py3.8,py3.9,py3.10,py3.11,py3.12,py3.13}-potel

# pure_eval
{py3.7,py3.12,py3.13}-pure_eval

Expand Down Expand Up @@ -435,12 +429,6 @@ deps =
openai-latest: tiktoken~=0.6.0
openai-notiktoken: openai

# OpenTelemetry (OTel)
opentelemetry: opentelemetry-distro

# OpenTelemetry Experimental (POTel)
potel: -e .[opentelemetry-experimental]

# pure_eval
pure_eval: pure_eval

Expand Down Expand Up @@ -757,8 +745,6 @@ setenv =
loguru: TESTPATH=tests/integrations/loguru
openai: TESTPATH=tests/integrations/openai
openfeature: TESTPATH=tests/integrations/openfeature
opentelemetry: TESTPATH=tests/integrations/opentelemetry
potel: TESTPATH=tests/integrations/opentelemetry
pure_eval: TESTPATH=tests/integrations/pure_eval
pymongo: TESTPATH=tests/integrations/pymongo
pyramid: TESTPATH=tests/integrations/pyramid
Expand Down
Loading