Skip to content

DB and HTTP semantic convention stability migration for SQLAlchemy#4110

Merged
xrmx merged 38 commits intoopen-telemetry:mainfrom
tammy-baylis-swi:sqlalchemy-semconv-opt-in
Apr 1, 2026
Merged

DB and HTTP semantic convention stability migration for SQLAlchemy#4110
xrmx merged 38 commits intoopen-telemetry:mainfrom
tammy-baylis-swi:sqlalchemy-semconv-opt-in

Conversation

@tammy-baylis-swi
Copy link
Copy Markdown
Contributor

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

Description

Add SQLAlchemy instrumentor support for when OTEL_SEMCONV_STABILITY_OPT_IN includes

  • "database" or "database/dup"
  • "http" or "http/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".

To make the changes cleaner: adds sqlalchemy helper _get_db_name_from_cursor to 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.py for choosing the latest appropriate version when an instrumentor uses multiple signal types (http, db, genai).

Adds _set_db_operation to _semconv.py. This adds SQLAlchemy instrumentor setting of db.operation and/or db.operation.name attributes -- this was only done for span name before.

Fixes #2679

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

@tammy-baylis-swi tammy-baylis-swi marked this pull request as ready for review January 22, 2026 23:47
@tammy-baylis-swi tammy-baylis-swi requested a review from a team as a code owner January 22, 2026 23:47
@tammy-baylis-swi tammy-baylis-swi changed the title DB semantic convention stability migration for SQLAlchemy DB and HTTP semantic convention stability migration for SQLAlchemy Jan 26, 2026
@tammy-baylis-swi tammy-baylis-swi moved this to Ready for review in Python PR digest Jan 26, 2026
Copy link
Copy Markdown
Member

@MikeGoldsmith MikeGoldsmith left a comment

Choose a reason for hiding this comment

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

Overall looks good 👍🏻

Comment thread opentelemetry-instrumentation/tests/test_semconv.py Outdated
@tammy-baylis-swi tammy-baylis-swi moved this from Ready for review to Approved PRs in Python PR digest Feb 25, 2026
@tammy-baylis-swi
Copy link
Copy Markdown
Contributor Author

@open-telemetry/python-maintainers May I get a review please?

@xrmx xrmx enabled auto-merge (squash) April 1, 2026 15:15
@xrmx xrmx merged commit d22bf39 into open-telemetry:main Apr 1, 2026
860 checks passed
@github-project-automation github-project-automation Bot moved this from Approved PRs to Done in Python PR digest Apr 1, 2026
@tammy-baylis-swi tammy-baylis-swi deleted the sqlalchemy-semconv-opt-in branch April 2, 2026 00:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

opentelemetry-instrumentation-sqlalchemy: semantic convention stability migration

4 participants