open-telemetry / open-telemetry/opentelemetry-python-contrib
Sqlite3 uninstrumentation does not work properly
@shalevr is already working on this.
Since Feb 22, 2023.
- Dominant language
- Python
- Stars
- 1.1k
- Forks
- 1.1k
- Avg merge
- 4d 15h
- Merged PRs (30d)
- 16
Description
Describe your environment
Python 3.9
Steps to reproduce
Spans keep being created after I call uninsturment:
import sqlite3
from opentelemetry.instrumentation.sqlite3 import SQLite3Instrumentor
SQLite3Instrumentor().instrument()
cnx = sqlite3.connect(":memory:")
self.memory_exporter.clear()
SQLite3Instrumentor().uninstrument()
stmt = "CREATE TABLE IF NOT EXISTS test (id integer)"
cursor = cnx.cursor()
cursor.execute(stmt)
spans = self.memory_exporter.get_finished_spans()
self.assertEqual(len(spans), 0)
But if I move the sqlite3.connect after the uninsturment, like this:
SQLite3Instrumentor().instrument()
self.memory_exporter.clear()
SQLite3Instrumentor().uninstrument()
stmt = "CREATE TABLE IF NOT EXISTS test (id integer)"
cnx = sqlite3.connect(":memory:")
cursor = cnx.cursor()
cursor.execute(stmt)
spans = self.memory_exporter.get_finished_spans()
self.assertEqual(len(spans), 0)
it works as expected.
The problem is when instrumented sqlite3.connect returns "get_traced_connection_proxy"
and after uninstument i still use the same connection that I opened before and the hooks still work
What is the expected behavior?
spans will not create after call uninstrument
What is the actual behavior?
still get spans after uninstument
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.