Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add NoOpTracerProvider test cases for sqllite3 instrumentation #2709

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -100,3 +100,24 @@ def test_callproc(self):
):
self._cursor.callproc("test", ())
self.validate_spans("test")

def test_noop_tracer_provider(self):
"""Should not create any spans when using NoOpTracerProvider"""
SQLite3Instrumentor().uninstrument()
SQLite3Instrumentor().instrument(tracer_provider=trace_api.get_tracer_provider())
self._tracer = trace_api.get_tracer(__name__)
self._create_tables()

stmt = "CREATE TABLE IF NOT EXISTS test (id integer)"
with self._tracer.start_as_current_span("rootSpan"):
self._cursor.execute(stmt)

stmt = "INSERT INTO test (id) VALUES (?)"
data = [("1",), ("2",), ("3",)]
with self._tracer.start_as_current_span("rootSpan"):
self._cursor.executemany(stmt, data)

with self._tracer.start_as_current_span("rootSpan"), self.assertRaises(Exception):
self._cursor.callproc("test", ())


Loading