Skip to content

Commit 23a49e8

Browse files
committed
Merge branch 'potel-base' of github.com:getsentry/sentry-python into potel-base
2 parents bca9881 + bd94010 commit 23a49e8

File tree

5 files changed

+40
-7
lines changed

5 files changed

+40
-7
lines changed

requirements-aws-lambda-layer.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ urllib3
55
# https://github.com/boto/botocore/blob/develop/setup.cfg
66
# So we pin this here to make our Lambda layer work with
77
# Lambda Function using Python 3.7+
8-
urllib3<1.27
8+
urllib3<1.27; python_version < "3.10"
99

1010
opentelemetry-distro>=0.35b0

sentry_sdk/opentelemetry/consts.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,13 @@
2121
OTEL_SENTRY_CONTEXT = "otel"
2222
SPAN_ORIGIN = "auto.otel"
2323

24+
# resource semconv attributes
25+
# Not all of these are stable yet, so defining them here rather than importing.
26+
# https://github.com/open-telemetry/semantic-conventions/blob/main/docs/resource/README.md#service
27+
RESOURCE_SERVICE_NAME = "service.name"
28+
RESOURCE_SERVICE_NAMESPACE = "service.namespace"
29+
RESOURCE_SERVICE_VERSION = "service.version"
30+
2431

2532
class SentrySpanAttribute:
2633
DESCRIPTION = "sentry.description"

sentry_sdk/opentelemetry/tracing.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,20 @@
11
from __future__ import annotations
22
from opentelemetry import trace
33
from opentelemetry.propagate import set_global_textmap
4+
from opentelemetry.sdk.resources import Resource
45
from opentelemetry.sdk.trace import TracerProvider, Span, ReadableSpan
56

7+
from sentry_sdk.consts import VERSION
68
from sentry_sdk.opentelemetry import (
79
SentryPropagator,
810
SentrySampler,
911
SentrySpanProcessor,
1012
)
13+
from sentry_sdk.opentelemetry.consts import (
14+
RESOURCE_SERVICE_NAME,
15+
RESOURCE_SERVICE_NAMESPACE,
16+
RESOURCE_SERVICE_VERSION,
17+
)
1118
from sentry_sdk.utils import logger
1219

1320

@@ -38,7 +45,16 @@ def setup_sentry_tracing() -> None:
3845

3946
else:
4047
logger.debug("[Tracing] No TracerProvider set, creating a new one")
41-
tracer_provider = TracerProvider(sampler=SentrySampler())
48+
tracer_provider = TracerProvider(
49+
sampler=SentrySampler(),
50+
resource=Resource.create(
51+
{
52+
RESOURCE_SERVICE_NAME: "sentry-python",
53+
RESOURCE_SERVICE_VERSION: VERSION,
54+
RESOURCE_SERVICE_NAMESPACE: "sentry",
55+
}
56+
),
57+
)
4258
trace.set_tracer_provider(tracer_provider)
4359

4460
try:

tests/opentelemetry/test_potel.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from opentelemetry import trace
33

44
import sentry_sdk
5-
from sentry_sdk.consts import SPANSTATUS
5+
from sentry_sdk.consts import SPANSTATUS, VERSION
66
from tests.conftest import ApproxDict
77

88

@@ -361,3 +361,13 @@ def test_potel_span_status(status_in, status_out):
361361
span.set_status(status_in)
362362

363363
assert span.status == status_out
364+
365+
366+
def test_otel_resource(sentry_init):
367+
sentry_init()
368+
369+
tracer_provider = trace.get_tracer_provider()
370+
resource_attrs = tracer_provider.resource.attributes
371+
assert resource_attrs["service.name"] == "sentry-python"
372+
assert resource_attrs["service.namespace"] == "sentry"
373+
assert resource_attrs["service.version"] == VERSION

tox.ini

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ envlist =
144144
{py3.8,py3.10,py3.11}-huggingface_hub-v0.22.2
145145
{py3.8,py3.11,py3.12}-huggingface_hub-v0.26.5
146146
{py3.8,py3.12,py3.13}-huggingface_hub-v0.30.2
147-
{py3.8,py3.12,py3.13}-huggingface_hub-v0.33.1
147+
{py3.8,py3.12,py3.13}-huggingface_hub-v0.33.2
148148

149149

150150
# ~~~ DBs ~~~
@@ -505,7 +505,7 @@ deps =
505505
huggingface_hub-v0.22.2: huggingface_hub==0.22.2
506506
huggingface_hub-v0.26.5: huggingface_hub==0.26.5
507507
huggingface_hub-v0.30.2: huggingface_hub==0.30.2
508-
huggingface_hub-v0.33.1: huggingface_hub==0.33.1
508+
huggingface_hub-v0.33.2: huggingface_hub==0.33.2
509509

510510

511511
# ~~~ DBs ~~~
@@ -616,7 +616,7 @@ deps =
616616
django-v3.2.25: django==3.2.25
617617
django-v4.2.23: django==4.2.23
618618
django-v5.0.14: django==5.0.14
619-
django-v5.2.3: django==5.2.3
619+
django-v5.2.4: django==5.2.4
620620
django: channels[daphne]
621621
django: psycopg2-binary
622622
django: djangorestframework
@@ -632,7 +632,7 @@ deps =
632632
django-v3.2.25: pytest-asyncio
633633
django-v4.2.23: pytest-asyncio
634634
django-v5.0.14: pytest-asyncio
635-
django-v5.2.3: pytest-asyncio
635+
django-v5.2.4: pytest-asyncio
636636
django-v2.0.13: djangorestframework>=3.0,<4.0
637637
django-v2.0.13: Werkzeug<2.1.0
638638
django-v2.2.28: djangorestframework>=3.0,<4.0

0 commit comments

Comments
 (0)