|
31 | 31 | ElasticsearchInstrumentor,
|
32 | 32 | )
|
33 | 33 | from opentelemetry.instrumentation.elasticsearch.utils import sanitize_body
|
34 |
| -from opentelemetry.semconv.trace import SpanAttributes |
| 34 | +from opentelemetry.semconv._incubating.attributes.db_attributes import ( |
| 35 | + DB_STATEMENT, |
| 36 | + DB_SYSTEM, |
| 37 | +) |
35 | 38 | from opentelemetry.test.test_base import TestBase
|
36 | 39 | from opentelemetry.trace import StatusCode
|
37 | 40 |
|
@@ -76,15 +79,15 @@ def get_elasticsearch_client(*args, **kwargs):
|
76 | 79 | )
|
77 | 80 | class TestElasticsearchIntegration(TestBase):
|
78 | 81 | search_attributes = {
|
79 |
| - SpanAttributes.DB_SYSTEM: "elasticsearch", |
| 82 | + DB_SYSTEM: "elasticsearch", |
80 | 83 | "elasticsearch.url": "/test-index/_search",
|
81 | 84 | "elasticsearch.method": helpers.dsl_search_method,
|
82 | 85 | "elasticsearch.target": "test-index",
|
83 |
| - SpanAttributes.DB_STATEMENT: str({"query": {"bool": {"filter": "?"}}}), |
| 86 | + DB_STATEMENT: str({"query": {"bool": {"filter": "?"}}}), |
84 | 87 | }
|
85 | 88 |
|
86 | 89 | create_attributes = {
|
87 |
| - SpanAttributes.DB_SYSTEM: "elasticsearch", |
| 90 | + DB_SYSTEM: "elasticsearch", |
88 | 91 | "elasticsearch.url": "/test-index",
|
89 | 92 | "elasticsearch.method": "HEAD",
|
90 | 93 | }
|
@@ -361,13 +364,13 @@ def test_dsl_create(self, request_mock):
|
361 | 364 | )
|
362 | 365 |
|
363 | 366 | attributes = {
|
364 |
| - SpanAttributes.DB_SYSTEM: "elasticsearch", |
| 367 | + DB_SYSTEM: "elasticsearch", |
365 | 368 | "elasticsearch.url": "/test-index",
|
366 | 369 | "elasticsearch.method": "PUT",
|
367 | 370 | }
|
368 | 371 | self.assertSpanHasAttributes(span2, attributes)
|
369 | 372 | self.assertEqual(
|
370 |
| - literal_eval(span2.attributes[SpanAttributes.DB_STATEMENT]), |
| 373 | + literal_eval(span2.attributes[DB_STATEMENT]), |
371 | 374 | helpers.dsl_create_statement,
|
372 | 375 | )
|
373 | 376 |
|
@@ -408,13 +411,13 @@ def test_dsl_index(self, request_mock):
|
408 | 411 | span = spans[0]
|
409 | 412 | self.assertEqual(span.name, helpers.dsl_index_span_name)
|
410 | 413 | attributes = {
|
411 |
| - SpanAttributes.DB_SYSTEM: "elasticsearch", |
| 414 | + DB_SYSTEM: "elasticsearch", |
412 | 415 | "elasticsearch.url": helpers.dsl_index_url,
|
413 | 416 | "elasticsearch.method": "PUT",
|
414 | 417 | }
|
415 | 418 | self.assertSpanHasAttributes(span, attributes)
|
416 | 419 | self.assertEqual(
|
417 |
| - literal_eval(span.attributes[SpanAttributes.DB_STATEMENT]), |
| 420 | + literal_eval(span.attributes[DB_STATEMENT]), |
418 | 421 | {
|
419 | 422 | "body": "A few words here, a few words there",
|
420 | 423 | "title": "About searching",
|
|
0 commit comments