Skip to content

Commit c5ec903

Browse files
Update opentelemetry conventions
1 parent 44cbf67 commit c5ec903

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

elasticsearch/_otel.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,9 @@ def span(
7777
otel_span.set_attribute("http.request.method", method)
7878
otel_span.set_attribute("db.system", "elasticsearch")
7979
if endpoint_id is not None:
80-
otel_span.set_attribute("db.operation", endpoint_id)
80+
otel_span.set_attribute("db.operation.name", endpoint_id)
8181
for key, value in path_parts.items():
82-
otel_span.set_attribute(f"db.elasticsearch.path_parts.{key}", value)
82+
otel_span.set_attribute(f"db.operation.parameter.{key}", value)
8383

8484
yield OpenTelemetrySpan(
8585
otel_span,
@@ -94,8 +94,8 @@ def helpers_span(self, span_name: str) -> Generator[OpenTelemetrySpan, None, Non
9494
return
9595

9696
with self.tracer.start_as_current_span(span_name) as otel_span:
97-
otel_span.set_attribute("db.system", "elasticsearch")
98-
otel_span.set_attribute("db.operation", span_name)
97+
otel_span.set_attribute("db.system.name", "elasticsearch")
98+
otel_span.set_attribute("db.operation.name", span_name)
9999
# Without a request method, Elastic APM does not display the traces
100100
otel_span.set_attribute("http.request.method", "null")
101101
yield OpenTelemetrySpan(otel_span)

test_elasticsearch/test_otel.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def test_minimal_span():
6868
assert spans[0].name == "GET"
6969
assert spans[0].attributes == {
7070
"http.request.method": "GET",
71-
"db.system": "elasticsearch",
71+
"db.system.name": "elasticsearch",
7272
}
7373

7474

@@ -92,11 +92,11 @@ def test_detailed_span():
9292
assert spans[0].name == "ml.open_job"
9393
assert spans[0].attributes == {
9494
"http.request.method": "GET",
95-
"db.system": "elasticsearch",
96-
"db.operation": "ml.open_job",
97-
"db.elasticsearch.path_parts.job_id": "my-job",
98-
"db.elasticsearch.cluster.name": "e9106fc68e3044f0b1475b04bf4ffd5f",
99-
"db.elasticsearch.node.name": "instance-0000000001",
95+
"db.system.name": "elasticsearch",
96+
"db.operation.name": "ml.open_job",
97+
"db.operation.parameter.job_id": "my-job",
98+
"db.namespace": "e9106fc68e3044f0b1475b04bf4ffd5f",
99+
"elasticsearch.node.name": "instance-0000000001",
100100
}
101101

102102

0 commit comments

Comments
 (0)