mirror of
https://github.com/open-telemetry/opentelemetry-python-contrib.git
synced 2025-07-30 13:43:03 +08:00
feat: respect supress_instrumentation functionality in dbapi instrumentation (#3460)
* respect supress_instrumentation * update CHANGELOG * fix link * update CHANGELOG --------- Co-authored-by: Emídio Neto <9735060+emdneto@users.noreply.github.com>
This commit is contained in:
@ -21,6 +21,7 @@ from unittest import mock
|
||||
from opentelemetry import context
|
||||
from opentelemetry import trace as trace_api
|
||||
from opentelemetry.instrumentation import dbapi
|
||||
from opentelemetry.instrumentation.utils import suppress_instrumentation
|
||||
from opentelemetry.sdk import resources
|
||||
from opentelemetry.semconv.trace import SpanAttributes
|
||||
from opentelemetry.test.test_base import TestBase
|
||||
@ -243,6 +244,21 @@ class TestDBApiIntegration(TestBase):
|
||||
spans_list = self.memory_exporter.get_finished_spans()
|
||||
self.assertEqual(len(spans_list), 0)
|
||||
|
||||
def test_suppress_instrumentation(self):
|
||||
db_integration = dbapi.DatabaseApiIntegration(
|
||||
"instrumenting_module_test_name",
|
||||
"testcomponent",
|
||||
)
|
||||
mock_connection = db_integration.wrapped_connection(
|
||||
mock_connect, {}, {}
|
||||
)
|
||||
with suppress_instrumentation():
|
||||
cursor = mock_connection.cursor()
|
||||
cursor.execute("Test query", ("param1Value", False))
|
||||
|
||||
spans_list = self.memory_exporter.get_finished_spans()
|
||||
self.assertEqual(len(spans_list), 0)
|
||||
|
||||
def test_executemany(self):
|
||||
db_integration = dbapi.DatabaseApiIntegration(
|
||||
"instrumenting_module_test_name", "testcomponent"
|
||||
|
Reference in New Issue
Block a user