Skip to content

Commit

Permalink
feat(opentelemetry): Add entry point for SentryPropagator (#3086)
Browse files Browse the repository at this point in the history
Add entry point for sentry_sdk.integrations.opentelemetry.SentryPropagator.
This makes possible to configure opentelemetry using environment variables
and add SentryPropagator to existing ones instead of replace them.

Closes #3085

Co-authored-by: Neel Shah <neel.shah@sentry.io>
  • Loading branch information
mender and sl0thentr0py committed Jul 1, 2024
1 parent eab218c commit 407f651
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
5 changes: 5 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,11 @@ def get_file_text(file_name):
"starlite": ["starlite>=1.48"],
"tornado": ["tornado>=6"],
},
entry_points={
"opentelemetry_propagator": [
"sentry=sentry_sdk.integrations.opentelemetry:SentryPropagator"
]
},
classifiers=[
"Development Status :: 5 - Production/Stable",
"Environment :: Web Environment",
Expand Down
17 changes: 17 additions & 0 deletions tests/integrations/opentelemetry/test_entry_points.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import importlib
import os
from unittest.mock import patch

from opentelemetry import propagate
from sentry_sdk.integrations.opentelemetry import SentryPropagator


def test_propagator_loaded_if_mentioned_in_environment_variable():
try:
with patch.dict(os.environ, {"OTEL_PROPAGATORS": "sentry"}):
importlib.reload(propagate)

assert len(propagate.propagators) == 1
assert isinstance(propagate.propagators[0], SentryPropagator)
finally:
importlib.reload(propagate)

0 comments on commit 407f651

Please sign in to comment.