open-telemetry / open-telemetry/opentelemetry-python-contrib

Enabling statement capture with an environment variable in pymongo

Open
#2,437 0 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature-request
Dominant language
Python
Stars
1.1k
Forks
1.1k
Avg merge
4d 15h
Merged PRs (30d)
16

Description

We would like to capture statements with pymongo instrumentation by relying on auto-instrumentation only with no changes to the code. It is technically possible with the existing instrumentation library but by default it has capture_statement=False, hence auto-instrumented code does not capture statements. This is contrary to sqlalchemy where statements get captured by default.

It would be nice to at least make this possible with an environment variable, e.g. OTEL_PYTHON_PYMONGO_STATEMENT_CAPTURE=true. I went through OTel spec and some examples but I couldn't find an existing example or a similar implementation.

Would such a change be considered for merging into main branch?

In general, I think for all DB-like instrumentation libraries such a flag could be a nice addition.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the existing pymongo instrumentation and its capture_statement option, then compare how SQLAlchemy instrumentation handles statement capture by default. Check the auto-instrumentation path and its tests for environment-based configuration. Done means an environment variable such as OTEL_PYTHON_PYMONGO_STATEMENT_CAPTURE enables statement capture without application code changes.

Written by the indexing model from the issue text.

Assessment

Tech stack
mongodb, python
Domain
databases, observability-sre
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.