Skip to content

Conversation

@tammy-baylis-swi
Copy link
Contributor

@tammy-baylis-swi tammy-baylis-swi commented Jan 20, 2026

Description

Add DB-API instrumentor support for when OTEL_SEMCONV_STABILITY_OPT_IN includes "database" or "database/dup".

This changes the SQLComment in span attribute feature if opted in. Inclusion of sqlcomment on query span would be on db.statement and/or db.query.text attribute if default, "database", or "database/dup".

These instrumentors inherit DB-API's wrap_connect and/or instrument_connection, and therefore also gain support for semconv migration automatically:

  1. mysql
  2. mysqlclient
  3. psycopg2
  4. psycopg
  5. pymssql
  6. pymysql
  7. sqlite3

Fixes #2929 #2678 #2928 #2931 #2932 #2933 #2934

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

  • Added unit tests

Does This PR Require a Core Repo Change?

  • Yes. - Link to PR:
  • No.

Checklist:

See contributing.md for styleguide, changelog guidelines, and more.

  • Followed the style guidelines of this project
  • Changelogs have been updated
  • Unit tests have been added
  • Documentation has been updated

try:
result[key] = int(value)
except ValueError:
except (ValueError, TypeError):
Copy link
Contributor Author

@tammy-baylis-swi tammy-baylis-swi Jan 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure why A failure started happening in this PR instead of in #4108 with tox -e py3*-test-opentelemetry-instrumentation-aiopg because of aiopg instrumentor dependency on this. Example run with error:

TypeError: int() argument must be a string, a bytes-like object or a real number, not 'Mock'

@tammy-baylis-swi tammy-baylis-swi marked this pull request as ready for review January 22, 2026 21:43
@tammy-baylis-swi tammy-baylis-swi requested a review from a team as a code owner January 22, 2026 21:43
@tammy-baylis-swi tammy-baylis-swi changed the title DB semantic convention stability migration for DB-API DB semantic convention stability migration for DB-API and 7 inheriting db client instrumentors Jan 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

opentelemetry-instrumentation-dbapi: semantic convention stability migration

1 participant