Skip to content

docs: add instrumentation naming convention to contributing guide - #4754

Closed
krrishapatel wants to merge 1 commit into
open-telemetry:mainfrom
krrishapatel:docs/instrumentation-naming-convention
Closed

docs: add instrumentation naming convention to contributing guide#4754
krrishapatel wants to merge 1 commit into
open-telemetry:mainfrom
krrishapatel:docs/instrumentation-naming-convention

Conversation

@krrishapatel

Copy link
Copy Markdown

Description

Adds a note to the instrumentation guidelines section of CONTRIBUTING.md documenting that instrumentations should use their top-level package name (e.g. "opentelemetry.instrumentation.requests") as a fixed string when obtaining a tracer or meter, rather than __name__.

Fixes #910

Type of change

  • This change requires a documentation update

How Has This Been Tested?

Documentation-only change.

Does This PR Require a Core Repo Change?

  • No.

Assisted-by: Claude Opus 4.6

@krrishapatel
krrishapatel requested a review from a team as a code owner June 28, 2026 02:56

@xrmx xrmx left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This contains unrelated changes

@github-project-automation github-project-automation Bot moved this to Reviewed PRs that need fixes in Python PR digest Jul 2, 2026
Add a note under the instrumentation guidelines that tracers and meters
should be obtained using the top-level instrumentation package name as a
fixed string (e.g. "opentelemetry.instrumentation.requests") rather than
__name__, which varies by submodule.

Assisted-by: Claude Opus 4.6
@krrishapatel
krrishapatel force-pushed the docs/instrumentation-naming-convention branch from 65484c8 to dd792c1 Compare July 2, 2026 19:38
@krrishapatel

Copy link
Copy Markdown
Author

@xrmx Rebased to remove the unrelated change — this now only touches CONTRIBUTING.md. Mind taking another look?

@github-actions

Copy link
Copy Markdown

This PR has been automatically marked as stale because it has not had any activity for 14 days. It will be closed if no further activity occurs within 14 days of this comment.
If you're still working on this, please add a comment or push new commits.

@github-actions github-actions Bot added the Stale label Jul 30, 2026
@krrishapatel

Copy link
Copy Markdown
Author

Closing this myself — the guidance as written is wrong, and I should have checked it against the codebase before proposing it.

I went back through the shipped instrumentations, and 35 of them pass __name__ to get_tracer, including requests, django, and flask. So this PR was telling new contributors to avoid the convention that the repo overwhelmingly follows.

The reason __name__ is correct there is that these calls live in the package's top-level __init__.py, where __name__ already evaluates to the canonical name, e.g. in opentelemetry-instrumentation-requests/src/opentelemetry/instrumentation/requests/__init__.py it is exactly "opentelemetry.instrumentation.requests". There is nothing to fix in that case.

The narrower thing I was actually reacting to is real but rare: when get_tracer is called from a submodule, __name__ picks up the submodule path instead of the package name. There are two such spots in shipped code:

  • opentelemetry-instrumentation-pika/src/opentelemetry/instrumentation/pika/pika_instrumentor.py:202
  • opentelemetry-instrumentation-aiohttp-server/src/opentelemetry/instrumentation/aiohttp_server/__init__.py:434 (this one is in an __init__.py, so it is fine)

That is a two-line observation about one package, not a contributing-guide checklist item, so it does not justify this PR. If maintainers think the pika case is worth normalizing I am happy to open a small targeted PR for it, but I would rather ask first than add another unsolicited one.

Apologies for the noise on this and on #4753. @xrmx your "unrelated changes" review was the correct call on the original version, and I should have validated the underlying claim rather than just trimming the diff.

@github-project-automation github-project-automation Bot moved this from Reviewed PRs that need fixes to Done in Python PR digest Aug 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Add note to contributing guide about instrumentation name

2 participants