Skip to content

Commit 41fe101

Browse files
authored
Merge branch 'main' into botocore-span-attributes-removal
2 parents 61c8f24 + 3188f36 commit 41fe101

18 files changed

Lines changed: 453 additions & 131 deletions

File tree

CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2727
([#3938](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3938))
2828
- `opentelemetry-instrumentation-aiohttp-server`: Support passing `TracerProvider` when instrumenting.
2929
([#3819](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3819))
30+
- `opentelemetry-instrumentation-system-metrics`: Add support for the `OTEL_PYTHON_SYSTEM_METRICS_EXCLUDED_METRICS` environment variable
31+
([#3959](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3959))
3032
- `opentelemetry-instrumentation-httpx`: add ability to capture custom headers
3133
([#4047](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/4047))
3234

@@ -46,6 +48,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
4648
([#4059](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/4059))
4749
- `opentelemetry-instrumentation-botocore`: Replace SpanAttributes with semconv constants where applicable
4850
([#4063](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/4063))
51+
- `opentelemetry-instrumentation-celery`: Replace SpanAttributes with semconv constants where applicable
52+
([#4056](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/4056))
53+
- `opentelemetry-instrumentation-confluent-kafka`: Replace SpanAttributes with semconv constants where applicable
54+
([#4057](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/4057))
55+
- `opentelemetry-instrumentation-cassandra`: Replace SpanAttributes with semconv constants for DB attributes
56+
([#4055](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/4055))
57+
- `opentelemetry-instrumentation-falcon`: Replace SpanAttributes with semconv constants
58+
([#4066](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/4066))
59+
- `opentelemetry-instrumentation-pika`: Replace SpanAttributes with semconv constants for net attributes
60+
([#4068](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/4068))
61+
- `opentelemetry-instrumentation-mysqlclient`: Replace SpanAttributes with semconv constants
62+
([#4067](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/4067))
4963

5064
## Version 1.39.0/0.60b0 (2025-12-03)
5165

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ See the [public meeting notes](https://docs.google.com/document/d/18w8zOBm_mbety
88
for a summary description of past meetings. To request edit access, join the
99
meeting or get in touch on [Slack](https://cloud-native.slack.com/archives/C01PD4HUVBL).
1010

11-
See to the [community membership document](https://github.com/open-telemetry/community/blob/main/community-membership.md)
11+
See the [community membership document](https://github.com/open-telemetry/community/blob/main/community-membership.md)
1212
on how to become a [**Member**](https://github.com/open-telemetry/community/blob/main/community-membership.md#member),
1313
[**Approver**](https://github.com/open-telemetry/community/blob/main/community-membership.md#approver)
1414
and [**Maintainer**](https://github.com/open-telemetry/community/blob/main/community-membership.md#maintainer).

docs/instrumentation/system_metrics/system_metrics.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,8 @@ OpenTelemetry system metrics Instrumentation
55
:members:
66
:undoc-members:
77
:show-inheritance:
8+
9+
.. automodule:: opentelemetry.instrumentation.system_metrics.environment_variables
10+
:members:
11+
:undoc-members:
12+
:show-inheritance:

instrumentation/opentelemetry-instrumentation-cassandra/src/opentelemetry/instrumentation/cassandra/__init__.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,14 @@
4747
from opentelemetry.instrumentation.cassandra.version import __version__
4848
from opentelemetry.instrumentation.instrumentor import BaseInstrumentor
4949
from opentelemetry.instrumentation.utils import unwrap
50-
from opentelemetry.semconv.trace import SpanAttributes
50+
from opentelemetry.semconv._incubating.attributes.db_attributes import (
51+
DB_NAME,
52+
DB_STATEMENT,
53+
DB_SYSTEM,
54+
)
55+
from opentelemetry.semconv._incubating.attributes.net_attributes import (
56+
NET_PEER_NAME,
57+
)
5158

5259

5360
def _instrument(tracer_provider, include_db_statement=False):
@@ -68,16 +75,16 @@ def _traced_execute_async(func, instance, args, kwargs):
6875
name, kind=trace.SpanKind.CLIENT
6976
) as span:
7077
if span.is_recording():
71-
span.set_attribute(SpanAttributes.DB_NAME, instance.keyspace)
72-
span.set_attribute(SpanAttributes.DB_SYSTEM, "cassandra")
78+
span.set_attribute(DB_NAME, instance.keyspace)
79+
span.set_attribute(DB_SYSTEM, "cassandra")
7380
span.set_attribute(
74-
SpanAttributes.NET_PEER_NAME,
81+
NET_PEER_NAME,
7582
instance.cluster.contact_points,
7683
)
7784

7885
if include_db_statement:
7986
query = args[0]
80-
span.set_attribute(SpanAttributes.DB_STATEMENT, str(query))
87+
span.set_attribute(DB_STATEMENT, str(query))
8188

8289
response = func(*args, **kwargs)
8390
return response

instrumentation/opentelemetry-instrumentation-celery/src/opentelemetry/instrumentation/celery/__init__.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,9 @@ def add(x, y):
7676
from opentelemetry.metrics import get_meter
7777
from opentelemetry.propagate import extract, inject
7878
from opentelemetry.propagators.textmap import Getter
79-
from opentelemetry.semconv.trace import SpanAttributes
79+
from opentelemetry.semconv._incubating.attributes.messaging_attributes import (
80+
MESSAGING_MESSAGE_ID,
81+
)
8082
from opentelemetry.trace.status import Status, StatusCode
8183

8284
if VERSION >= (4, 0, 1):
@@ -240,7 +242,7 @@ def _trace_before_publish(self, *args, **kwargs):
240242
# apply some attributes here because most of the data is not available
241243
if span.is_recording():
242244
span.set_attribute(_TASK_TAG_KEY, _TASK_APPLY_ASYNC)
243-
span.set_attribute(SpanAttributes.MESSAGING_MESSAGE_ID, task_id)
245+
span.set_attribute(MESSAGING_MESSAGE_ID, task_id)
244246
span.set_attribute(_TASK_NAME_KEY, task_name)
245247
utils.set_attributes_from_context(span, kwargs)
246248

instrumentation/opentelemetry-instrumentation-celery/src/opentelemetry/instrumentation/celery/utils.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020
from celery import registry # pylint: disable=no-name-in-module
2121
from celery.app.task import Task
2222

23+
from opentelemetry.semconv._incubating.attributes.messaging_attributes import (
24+
MESSAGING_MESSAGE_ID,
25+
)
2326
from opentelemetry.semconv.trace import SpanAttributes
2427
from opentelemetry.trace import Span
2528

@@ -98,7 +101,7 @@ def set_attributes_from_context(span, context):
98101
value = str(value)
99102

100103
elif key == "id":
101-
attribute_name = SpanAttributes.MESSAGING_MESSAGE_ID
104+
attribute_name = MESSAGING_MESSAGE_ID
102105

103106
elif key == "correlation_id":
104107
attribute_name = SpanAttributes.MESSAGING_CONVERSATION_ID

instrumentation/opentelemetry-instrumentation-celery/tests/test_tasks.py

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,22 @@
2020
from opentelemetry import baggage, context
2121
from opentelemetry.instrumentation.celery import CeleryInstrumentor, utils
2222
from opentelemetry.instrumentation.utils import unwrap
23+
from opentelemetry.semconv.attributes.exception_attributes import (
24+
EXCEPTION_MESSAGE,
25+
EXCEPTION_STACKTRACE,
26+
EXCEPTION_TYPE,
27+
)
2328
from opentelemetry.semconv.trace import SpanAttributes
2429
from opentelemetry.test.test_base import TestBase
2530
from opentelemetry.trace import SpanKind, StatusCode
2631

27-
from .celery_test_tasks import app, task_add, task_raises, task_returns_baggage
32+
from .celery_test_tasks import (
33+
CustomError,
34+
app,
35+
task_add,
36+
task_raises,
37+
task_returns_baggage,
38+
)
2839

2940

3041
class TestCeleryInstrumentation(TestBase):
@@ -127,15 +138,15 @@ def test_task_raises(self):
127138
self.assertEqual(1, len(consumer.events))
128139
event = consumer.events[0]
129140

130-
self.assertIn(SpanAttributes.EXCEPTION_STACKTRACE, event.attributes)
141+
self.assertIn(EXCEPTION_STACKTRACE, event.attributes)
131142

132-
# TODO: use plain assertEqual after 1.25 is released (https://github.com/open-telemetry/opentelemetry-python/pull/3837)
133-
self.assertIn(
134-
"CustomError", event.attributes[SpanAttributes.EXCEPTION_TYPE]
143+
self.assertEqual(
144+
f"{CustomError.__module__}.{CustomError.__qualname__}",
145+
event.attributes[EXCEPTION_TYPE],
135146
)
136147

137148
self.assertEqual(
138-
event.attributes[SpanAttributes.EXCEPTION_MESSAGE],
149+
event.attributes[EXCEPTION_MESSAGE],
139150
"The task failed!",
140151
)
141152

instrumentation/opentelemetry-instrumentation-celery/tests/test_utils.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020
from opentelemetry import trace as trace_api
2121
from opentelemetry.instrumentation.celery import utils
2222
from opentelemetry.sdk import trace
23+
from opentelemetry.semconv._incubating.attributes.messaging_attributes import (
24+
MESSAGING_MESSAGE_ID,
25+
)
2326
from opentelemetry.semconv.trace import SpanAttributes
2427

2528

@@ -47,7 +50,7 @@ def test_set_attributes_from_context(self):
4750
utils.set_attributes_from_context(span, context)
4851

4952
self.assertEqual(
50-
span.attributes.get(SpanAttributes.MESSAGING_MESSAGE_ID),
53+
span.attributes.get(MESSAGING_MESSAGE_ID),
5154
"44b7f305",
5255
)
5356
self.assertEqual(

instrumentation/opentelemetry-instrumentation-confluent-kafka/src/opentelemetry/instrumentation/confluent_kafka/__init__.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,9 @@ def instrument_consumer(consumer: Consumer, tracer_provider=None)
110110
from opentelemetry import context, propagate, trace
111111
from opentelemetry.instrumentation.instrumentor import BaseInstrumentor
112112
from opentelemetry.instrumentation.utils import unwrap
113-
from opentelemetry.semconv.trace import MessagingOperationValues
113+
from opentelemetry.semconv._incubating.attributes.messaging_attributes import (
114+
MessagingOperationTypeValues,
115+
)
114116
from opentelemetry.trace import Tracer
115117

116118
from .package import _instruments
@@ -363,7 +365,7 @@ def wrap_produce(func, instance, tracer, args, kwargs):
363365
_enrich_span(
364366
span,
365367
topic,
366-
operation=MessagingOperationValues.RECEIVE,
368+
operation=MessagingOperationTypeValues.RECEIVE,
367369
) # Replace
368370
propagate.inject(
369371
headers,
@@ -387,7 +389,7 @@ def wrap_poll(func, instance, tracer, args, kwargs):
387389
record.topic(),
388390
record.partition(),
389391
record.offset(),
390-
operation=MessagingOperationValues.PROCESS,
392+
operation=MessagingOperationTypeValues.PROCESS,
391393
)
392394
instance._current_context_token = context.attach(
393395
trace.set_span_in_context(instance._current_consume_span)
@@ -409,7 +411,7 @@ def wrap_consume(func, instance, tracer, args, kwargs):
409411
_enrich_span(
410412
instance._current_consume_span,
411413
records[0].topic(),
412-
operation=MessagingOperationValues.PROCESS,
414+
operation=MessagingOperationTypeValues.PROCESS,
413415
)
414416

415417
instance._current_context_token = context.attach(

instrumentation/opentelemetry-instrumentation-confluent-kafka/src/opentelemetry/instrumentation/confluent_kafka/utils.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,14 @@
33

44
from opentelemetry import context, propagate
55
from opentelemetry.propagators import textmap
6+
from opentelemetry.semconv._incubating.attributes.messaging_attributes import (
7+
MESSAGING_MESSAGE_ID,
8+
MESSAGING_OPERATION,
9+
MESSAGING_SYSTEM,
10+
MessagingOperationTypeValues,
11+
)
612
from opentelemetry.semconv.trace import (
713
MessagingDestinationKindValues,
8-
MessagingOperationValues,
914
SpanAttributes,
1015
)
1116
from opentelemetry.trace import Link, SpanKind
@@ -115,12 +120,12 @@ def _enrich_span(
115120
topic,
116121
partition: Optional[int] = None,
117122
offset: Optional[int] = None,
118-
operation: Optional[MessagingOperationValues] = None,
123+
operation: Optional[MessagingOperationTypeValues] = None,
119124
):
120125
if not span.is_recording():
121126
return
122127

123-
span.set_attribute(SpanAttributes.MESSAGING_SYSTEM, "kafka")
128+
span.set_attribute(MESSAGING_SYSTEM, "kafka")
124129
span.set_attribute(SpanAttributes.MESSAGING_DESTINATION, topic)
125130

126131
if partition is not None:
@@ -132,15 +137,15 @@ def _enrich_span(
132137
)
133138

134139
if operation:
135-
span.set_attribute(SpanAttributes.MESSAGING_OPERATION, operation.value)
140+
span.set_attribute(MESSAGING_OPERATION, operation.value)
136141
else:
137142
span.set_attribute(SpanAttributes.MESSAGING_TEMP_DESTINATION, True)
138143

139144
# https://stackoverflow.com/questions/65935155/identify-and-find-specific-message-in-kafka-topic
140145
# A message within Kafka is uniquely defined by its topic name, topic partition and offset.
141146
if partition is not None and offset is not None and topic:
142147
span.set_attribute(
143-
SpanAttributes.MESSAGING_MESSAGE_ID,
148+
MESSAGING_MESSAGE_ID,
144149
f"{topic}.{partition}.{offset}",
145150
)
146151

0 commit comments

Comments
 (0)