Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
([#4056](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/4056))
- `opentelemetry-instrumentation-confluent-kafka`: Replace SpanAttributes with semconv constants where applicable
([#4057](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/4057))
- `opentelemetry-instrumentation-cassandra`: Replace SpanAttributes with semconv constants for DB attributes
([#4055](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/4055))

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,14 @@
from opentelemetry.instrumentation.cassandra.version import __version__
from opentelemetry.instrumentation.instrumentor import BaseInstrumentor
from opentelemetry.instrumentation.utils import unwrap
from opentelemetry.semconv.trace import SpanAttributes
from opentelemetry.semconv._incubating.attributes.db_attributes import (
DB_NAME,
DB_STATEMENT,
DB_SYSTEM,
)
from opentelemetry.semconv._incubating.attributes.net_attributes import (
NET_PEER_NAME,
)


def _instrument(tracer_provider, include_db_statement=False):
Expand All @@ -68,16 +75,16 @@ def _traced_execute_async(func, instance, args, kwargs):
name, kind=trace.SpanKind.CLIENT
) as span:
if span.is_recording():
span.set_attribute(SpanAttributes.DB_NAME, instance.keyspace)
span.set_attribute(SpanAttributes.DB_SYSTEM, "cassandra")
span.set_attribute(DB_NAME, instance.keyspace)
span.set_attribute(DB_SYSTEM, "cassandra")
span.set_attribute(
SpanAttributes.NET_PEER_NAME,
NET_PEER_NAME,
instance.cluster.contact_points,
)

if include_db_statement:
query = args[0]
span.set_attribute(SpanAttributes.DB_STATEMENT, str(query))
span.set_attribute(DB_STATEMENT, str(query))

response = func(*args, **kwargs)
return response
Expand Down