Skip to content

Commit

Permalink
Adds NoOpTracerProvider test case for pymysql instrumentation (#2581)
Browse files Browse the repository at this point in the history
  • Loading branch information
shwejanraj authored Jun 21, 2024
1 parent a166208 commit 593f86f
Showing 1 changed file with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import pymysql

import opentelemetry.instrumentation.pymysql
from opentelemetry import trace as trace_api
from opentelemetry.instrumentation.pymysql import PyMySQLInstrumentor
from opentelemetry.sdk import resources
from opentelemetry.test.test_base import TestBase
Expand Down Expand Up @@ -78,6 +79,20 @@ def test_custom_tracer_provider(self, mock_connect):

self.assertIs(span.resource, resource)

@mock.patch("pymysql.connect")
# pylint: disable=unused-argument
def test_no_op_tracer_provider(self, mock_connect):
PyMySQLInstrumentor().instrument(
tracer_provider=trace_api.NoOpTracerProvider()
)
cnx = pymysql.connect(database="test")
cursor = cnx.cursor()
query = "SELECT * FROM test"
cursor.execute(query)

spans_list = self.memory_exporter.get_finished_spans()
self.assertEqual(len(spans_list), 0)

@mock.patch("pymysql.connect")
# pylint: disable=unused-argument
def test_instrument_connection(self, mock_connect):
Expand Down

0 comments on commit 593f86f

Please sign in to comment.