|
20 | 20 | from opentelemetry import trace as trace_api
|
21 | 21 | from opentelemetry.instrumentation.mysql import MySQLInstrumentor
|
22 | 22 | from opentelemetry.sdk import resources
|
23 |
| -from opentelemetry.semconv.trace import SpanAttributes |
| 23 | +from opentelemetry.semconv._incubating.attributes.db_attributes import ( |
| 24 | + DB_STATEMENT, |
| 25 | +) |
24 | 26 | from opentelemetry.test.test_base import TestBase
|
25 | 27 |
|
26 | 28 |
|
@@ -157,7 +159,7 @@ def test_instrument_connection_with_dbapi_sqlcomment_enabled(self):
|
157 | 159 | f"Select 1 /*db_driver='mysql.connector%%3Afoobar',dbapi_level='123',dbapi_threadsafety='123',driver_paramstyle='test',mysql_client_version='foobaz',traceparent='00-{trace_id}-{span_id}-01'*/;",
|
158 | 160 | )
|
159 | 161 | self.assertEqual(
|
160 |
| - span.attributes[SpanAttributes.DB_STATEMENT], |
| 162 | + span.attributes[DB_STATEMENT], |
161 | 163 | "Select 1;",
|
162 | 164 | )
|
163 | 165 |
|
@@ -196,7 +198,7 @@ def test_instrument_connection_with_dbapi_sqlcomment_enabled_stmt_enabled(
|
196 | 198 | f"Select 1 /*db_driver='mysql.connector%%3Afoobar',dbapi_level='123',dbapi_threadsafety='123',driver_paramstyle='test',mysql_client_version='foobaz',traceparent='00-{trace_id}-{span_id}-01'*/;",
|
197 | 199 | )
|
198 | 200 | self.assertEqual(
|
199 |
| - span.attributes[SpanAttributes.DB_STATEMENT], |
| 201 | + span.attributes[DB_STATEMENT], |
200 | 202 | f"Select 1 /*db_driver='mysql.connector%%3Afoobar',dbapi_level='123',dbapi_threadsafety='123',driver_paramstyle='test',mysql_client_version='foobaz',traceparent='00-{trace_id}-{span_id}-01'*/;",
|
201 | 203 | )
|
202 | 204 |
|
@@ -239,7 +241,7 @@ def test_instrument_connection_with_dbapi_sqlcomment_enabled_with_options(
|
239 | 241 | f"Select 1 /*db_driver='mysql.connector%%3Afoobar',dbapi_threadsafety='123',mysql_client_version='foobaz',traceparent='00-{trace_id}-{span_id}-01'*/;",
|
240 | 242 | )
|
241 | 243 | self.assertEqual(
|
242 |
| - span.attributes[SpanAttributes.DB_STATEMENT], |
| 244 | + span.attributes[DB_STATEMENT], |
243 | 245 | "Select 1;",
|
244 | 246 | )
|
245 | 247 |
|
@@ -274,7 +276,7 @@ def test_instrument_connection_with_dbapi_sqlcomment_not_enabled_default(
|
274 | 276 | spans_list = self.memory_exporter.get_finished_spans()
|
275 | 277 | span = spans_list[0]
|
276 | 278 | self.assertEqual(
|
277 |
| - span.attributes[SpanAttributes.DB_STATEMENT], |
| 279 | + span.attributes[DB_STATEMENT], |
278 | 280 | "Select 1;",
|
279 | 281 | )
|
280 | 282 |
|
@@ -332,7 +334,7 @@ def test_instrument_with_dbapi_sqlcomment_enabled(
|
332 | 334 | f"Select 1 /*db_driver='mysql.connector%%3Afoobar',dbapi_level='123',dbapi_threadsafety='123',driver_paramstyle='test',mysql_client_version='foobaz',traceparent='00-{trace_id}-{span_id}-01'*/;",
|
333 | 335 | )
|
334 | 336 | self.assertEqual(
|
335 |
| - span.attributes[SpanAttributes.DB_STATEMENT], |
| 337 | + span.attributes[DB_STATEMENT], |
336 | 338 | "Select 1;",
|
337 | 339 | )
|
338 | 340 |
|
@@ -373,7 +375,7 @@ def test_instrument_with_dbapi_sqlcomment_enabled_stmt_enabled(
|
373 | 375 | f"Select 1 /*db_driver='mysql.connector%%3Afoobar',dbapi_level='123',dbapi_threadsafety='123',driver_paramstyle='test',mysql_client_version='foobaz',traceparent='00-{trace_id}-{span_id}-01'*/;",
|
374 | 376 | )
|
375 | 377 | self.assertEqual(
|
376 |
| - span.attributes[SpanAttributes.DB_STATEMENT], |
| 378 | + span.attributes[DB_STATEMENT], |
377 | 379 | f"Select 1 /*db_driver='mysql.connector%%3Afoobar',dbapi_level='123',dbapi_threadsafety='123',driver_paramstyle='test',mysql_client_version='foobaz',traceparent='00-{trace_id}-{span_id}-01'*/;",
|
378 | 380 | )
|
379 | 381 |
|
@@ -418,7 +420,7 @@ def test_instrument_with_dbapi_sqlcomment_enabled_with_options(
|
418 | 420 | f"Select 1 /*db_driver='mysql.connector%%3Afoobar',dbapi_threadsafety='123',mysql_client_version='foobaz',traceparent='00-{trace_id}-{span_id}-01'*/;",
|
419 | 421 | )
|
420 | 422 | self.assertEqual(
|
421 |
| - span.attributes[SpanAttributes.DB_STATEMENT], |
| 423 | + span.attributes[DB_STATEMENT], |
422 | 424 | "Select 1;",
|
423 | 425 | )
|
424 | 426 |
|
@@ -453,7 +455,7 @@ def test_instrument_with_dbapi_sqlcomment_not_enabled_default(
|
453 | 455 | spans_list = self.memory_exporter.get_finished_spans()
|
454 | 456 | span = spans_list[0]
|
455 | 457 | self.assertEqual(
|
456 |
| - span.attributes[SpanAttributes.DB_STATEMENT], |
| 458 | + span.attributes[DB_STATEMENT], |
457 | 459 | "Select 1;",
|
458 | 460 | )
|
459 | 461 |
|
|
0 commit comments