Skip to content

Default SQLite3 cursor is not instrumented  #3082

Open
@Kludex

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions