Skip to content

Commit

Permalink
Merge branch 'main' into patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
a-cid authored Jun 21, 2024
2 parents 7802ade + 593f86f commit f3024bc
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 f3024bc

Please sign in to comment.