Skip to content

fix(pymongo): support database semconv migration#4682

Open
popsiclelmlm wants to merge 1 commit into
open-telemetry:mainfrom
popsiclelmlm:codex/pymongo-semconv-migration
Open

fix(pymongo): support database semconv migration#4682
popsiclelmlm wants to merge 1 commit into
open-telemetry:mainfrom
popsiclelmlm:codex/pymongo-semconv-migration

Conversation

@popsiclelmlm

@popsiclelmlm popsiclelmlm commented Jun 10, 2026

Copy link
Copy Markdown

Description

Fixes #1629

Summary

Adds database semantic convention migration support to the PyMongo instrumentation.

Reproduction

With OTEL_SEMCONV_STABILITY_OPT_IN=database, PyMongo spans still emitted the legacy database span attributes such as db.system, db.name, and db.statement, and the tracer schema URL stayed at 1.11.0.

Root cause

The PyMongo instrumentation set legacy database attributes directly and used a hard-coded legacy schema URL instead of the shared semantic convention migration helpers.

Changes

  • Initialize the database semconv opt-in mode for PyMongo command tracing.
  • Use the shared database semconv helpers for db.system, database name, and statement attributes.
  • Set the tracer schema URL from the database semconv opt-in mode.
  • Add tests for default, database, and database/dup modes.

Tests

  • .venv/bin/python -m tox -e py314-test-instrumentation-pymongo
  • .venv/bin/python -m tox -e lint-instrumentation-pymongo
  • .tox/lint-instrumentation-pymongo/bin/ruff check instrumentation/opentelemetry-instrumentation-pymongo/src/opentelemetry/instrumentation/pymongo/__init__.py instrumentation/opentelemetry-instrumentation-pymongo/tests/test_pymongo.py

Screenshots/Logs

Not applicable; this is a tracing attribute behavior change covered by unit tests.

Type of change

  • 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

Does This PR Require a Core Repo Change?

  • Yes. - Link to PR:
  • No.

Checklist:

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

@popsiclelmlm popsiclelmlm force-pushed the codex/pymongo-semconv-migration branch from a331835 to 0acc3cd Compare June 10, 2026 05:35
@popsiclelmlm popsiclelmlm requested a review from a team as a code owner June 10, 2026 05:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

Make sure pymongo instrumentation follows semantic conventions

1 participant