Skip to content

Commit 6ebd7d7

Browse files
herin049xrmx
authored andcommitted
opentelemetry-instrumentation-cassandra: Replace SpanAttributes with semconv constants for DB attributes (open-telemetry#4055)
* refactor: Replace SpanAttributes with semconv constants for DB attributes * update CHANGELOG.md * fix missing SpanAttributes removal * Update CHANGELOG.md --------- Co-authored-by: Riccardo Magliocchetti <riccardo.magliocchetti@gmail.com>
1 parent c224fe8 commit 6ebd7d7

2 files changed

Lines changed: 14 additions & 5 deletions

File tree

  • instrumentation/opentelemetry-instrumentation-cassandra/src/opentelemetry/instrumentation/cassandra

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
4848
([#4056](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/4056))
4949
- `opentelemetry-instrumentation-confluent-kafka`: Replace SpanAttributes with semconv constants where applicable
5050
([#4057](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/4057))
51+
- `opentelemetry-instrumentation-cassandra`: Replace SpanAttributes with semconv constants for DB attributes
52+
([#4055](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/4055))
5153

5254
## Version 1.39.0/0.60b0 (2025-12-03)
5355

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

0 commit comments

Comments
 (0)