DB and HTTP semantic convention stability migration for SQLAlchemy#4110
Open
tammy-baylis-swi wants to merge 35 commits intoopen-telemetry:mainfrom
Open
DB and HTTP semantic convention stability migration for SQLAlchemy#4110tammy-baylis-swi wants to merge 35 commits intoopen-telemetry:mainfrom
tammy-baylis-swi wants to merge 35 commits intoopen-telemetry:mainfrom
Conversation
...ntelemetry-instrumentation-sqlalchemy/src/opentelemetry/instrumentation/sqlalchemy/engine.py
Outdated
Show resolved
Hide resolved
6 tasks
herin049
reviewed
Jan 24, 2026
...ntelemetry-instrumentation-sqlalchemy/src/opentelemetry/instrumentation/sqlalchemy/engine.py
Outdated
Show resolved
Hide resolved
...ntelemetry-instrumentation-sqlalchemy/src/opentelemetry/instrumentation/sqlalchemy/engine.py
Outdated
Show resolved
Hide resolved
herin049
reviewed
Feb 9, 2026
...elemetry-instrumentation-sqlalchemy/src/opentelemetry/instrumentation/sqlalchemy/__init__.py
Outdated
Show resolved
Hide resolved
...ntelemetry-instrumentation-sqlalchemy/src/opentelemetry/instrumentation/sqlalchemy/engine.py
Outdated
Show resolved
Hide resolved
herin049
approved these changes
Feb 9, 2026
opentelemetry-instrumentation/src/opentelemetry/instrumentation/_semconv.py
Show resolved
Hide resolved
opentelemetry-instrumentation/src/opentelemetry/instrumentation/_semconv.py
Show resolved
Hide resolved
...ntelemetry-instrumentation-sqlalchemy/src/opentelemetry/instrumentation/sqlalchemy/engine.py
Show resolved
Hide resolved
...ntelemetry-instrumentation-sqlalchemy/src/opentelemetry/instrumentation/sqlalchemy/engine.py
Show resolved
Hide resolved
MikeGoldsmith
approved these changes
Feb 25, 2026
Contributor
Author
|
@open-telemetry/python-maintainers May I get a review please? |
xrmx
reviewed
Mar 12, 2026
...elemetry-instrumentation-sqlalchemy/src/opentelemetry/instrumentation/sqlalchemy/__init__.py
Show resolved
Hide resolved
| from opentelemetry.trace.status import Status, StatusCode | ||
|
|
||
|
|
||
| def _get_db_name_from_cursor_or_conn(vendor, conn, cursor): |
Contributor
There was a problem hiding this comment.
Question: why have we started looking also in the connection?
Contributor
Author
There was a problem hiding this comment.
It's more robust to deal with the different DBs that SQLAlchemy can connect to, namely sqlite where connection is more reliable than cursor. It's also a general update from the roundabout way mentioned in this thread. It's a bit extra for a semconv update but might as well since we're changing attributes values anyway.
11 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Add SQLAlchemy instrumentor support for when
OTEL_SEMCONV_STABILITY_OPT_INincludesThis changes the
SQLComment in span attributefeature if opted in. Inclusion of sqlcomment on query span would be ondb.statementand/ordb.query.textattribute if default, "database", or "database/dup".To make the changes cleaner: adds sqlalchemy helper
_get_db_name_from_cursorto pull directly instead of having a condition to check attributes taken originally from cursor (see this conversation).For reusability by other instrumentors later: this PR adds schema url helpers to
_semconv.pyfor choosing the latest appropriate version when an instrumentor uses multiple signal types (http, db, genai).Adds
_set_db_operationto_semconv.py. This adds SQLAlchemy instrumentor setting ofdb.operationand/ordb.operation.nameattributes -- this was only done for span name before.Fixes #2679
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
Does This PR Require a Core Repo Change?
Checklist:
See contributing.md for styleguide, changelog guidelines, and more.