Open
Description
Describe your environment
OS: (e.g, Ubuntu)
Python version: (e.g., Python 3.8.10)
Package version: (e.g., 0.46.0)
What happened?
The default sqlite3.Cursor
is not instrumented.
Steps to Reproduce
import sqlite3
from opentelemetry.instrumentation.sqlite3 import SQLite3Instrumentor
import logfire
logfire.configure()
SQLite3Instrumentor().instrument()
cnx = sqlite3.connect(':memory:')
cnx.execute('CREATE TABLE test (testField INTEGER)')
cnx.close()
Expected Result
I would expect a span to be created for the table creation.
Actual Result
The span was not created.
Instead, if you do...
import sqlite3
from opentelemetry.instrumentation.sqlite3 import SQLite3Instrumentor
import logfire
logfire.configure()
SQLite3Instrumentor().instrument()
cnx = sqlite3.connect(':memory:')
cursor = cnx.cursor()
cursor.execute('CREATE TABLE test (testField INTEGER)')
cursor.close()
cnx.close()
Additional context
The documentation should be updated... The code there doesn't run as is...
https://opentelemetry-python-contrib.readthedocs.io/en/latest/instrumentation/sqlite3/sqlite3.html
It should create the table first!
Would you like to implement a fix?
None
PRs
- Update sqlite3 instrumentor doc about explicit cursors #3088
- Todo: implement wrap of
connection.execute
Activity