Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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 @@ -116,6 +116,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
([#3681](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3681))
- `opentelemetry-instrumentation-flask`: Fix exemplars generation for `http.server.request.duration` and `http.server.duration` metrics
([#3912](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3912))
- `opentelemetry-instrumentation-cassandra`: Replace SpanAttributes with semconv constants for DB attributes
([#4055](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/4055))

### Added

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


Expand All @@ -68,16 +73,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,
Comment thread
xrmx marked this conversation as resolved.
Outdated
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