Skip to content

asyncio: fix environment variables not appearing in docs#4261

Merged
xrmx merged 6 commits intoopen-telemetry:mainfrom
srikaaviya:fix-asyncio-env-var-docs
Mar 2, 2026
Merged

asyncio: fix environment variables not appearing in docs#4261
xrmx merged 6 commits intoopen-telemetry:mainfrom
srikaaviya:fix-asyncio-env-var-docs

Conversation

@srikaaviya
Copy link
Copy Markdown
Contributor

Description

Fix the docstrings in environment_variables.py so they are correctly picked up by Sphinx autodoc for Read the Docs.

Previously the docstrings were placed above the variable assignments, which Sphinx cannot parse. Moved them below and added the required '.. envvar::' directives, consistent with how other packages (e.g. opentelemetry-instrumentation) document their environment variables.

Fixes #4256

Type of change

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

Ran tox lint locally:

  • tox -e lint-instrumentation-asyncio → 10.00/10
  • pre-commit run on modified files → Passed

Does This PR Require a Core Repo Change?

  • No.

Checklist:

  • Followed the style guidelines of this project
  • Changelogs have been updated

Fix the docstrings in environment_variables.py so they are correctly
picked up by Sphinx autodoc for Read the Docs.

Previously the docstrings were placed above the variable assignments,
which Sphinx cannot parse. Moved them below and added the
required '.. envvar::' directives, consistent with how other
packages (e.g. opentelemetry-instrumentation) document their
environment variables.

Fixes open-telemetry#4256
@srikaaviya srikaaviya requested a review from a team as a code owner February 25, 2026 15:46
@srikaaviya srikaaviya changed the title asyncio: fix environment variables not in docs asyncio: fix environment variables not appearing in docs Feb 25, 2026
@tammy-baylis-swi tammy-baylis-swi moved this to Approved PRs that need fixes in Python PR digest Feb 25, 2026
@tammy-baylis-swi tammy-baylis-swi moved this from Approved PRs that need fixes to Easy to review / merge / close in Python PR digest Feb 25, 2026
@tammy-baylis-swi tammy-baylis-swi requested a review from a team February 25, 2026 22:46
Copy link
Copy Markdown
Contributor

@xrmx xrmx left a comment

Choose a reason for hiding this comment

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

@srikaaviya Have you checked that this is enough to fix it? This is a genuine question since building docs locally has always been painful for me 😅

@srikaaviya
Copy link
Copy Markdown
Contributor Author

srikaaviya commented Feb 26, 2026

Have you checked that this is enough to fix it?

@xrmx I tried building the docs locally earlier but ran into some missing C-extension dependencies. I'll get those installed and verify the env vars appear correctly, then update you.

@srikaaviya
Copy link
Copy Markdown
Contributor Author

srikaaviya commented Feb 26, 2026

@xrmx Thanks for the heads up on checking it locally.

During my local testing, I realized Sphinx was actually ignoring the
(environment_variables.py) submodule when generating the page, meaning the variables still weren't rendering.

To fix this properly, I moved the .. envvar:: docstrings directly into the asyncio/init.py module docstring (as followed by logging and fastapi instrumentations). I've verified locally (screenshot attached)

(Side note: I noticed while investigating this, that the system_metrics package's environment variables are currently broken on the live RTD site as well for a similar reason. Just thought I'd flag it!)

Screenshot 2026-02-26 at 2 49 59 PM

@xrmx
Copy link
Copy Markdown
Contributor

xrmx commented Feb 27, 2026

If you keep the documentation in environment_variables, does adding the following snippet work?

diff --git a/docs/instrumentation/asyncio/asyncio.rst b/docs/instrumentation/asyncio/asyncio.rst
index 4cbcc70f0..3aabdd8ec 100644
--- a/docs/instrumentation/asyncio/asyncio.rst
+++ b/docs/instrumentation/asyncio/asyncio.rst
@@ -5,3 +5,8 @@ OpenTelemetry asyncio Instrumentation
     :members:
     :undoc-members:
     :show-inheritance:
+
+.. automodule:: opentelemetry.instrumentation.asyncio.environment_variables
+    :members:
+    :undoc-members:
+    :show-inheritance:

@srikaaviya
Copy link
Copy Markdown
Contributor Author

@xrmx Actually, I had already tested adding the 2nd automodule — it didn't work. After your suggestion, I realized the issue might be the placement of the docstrings. So i moved .. envvar:: entries to a module-level docstring at the top of environment_variables.py and it worked! Let me know if this commit helps.

Copy link
Copy Markdown
Contributor

@xrmx xrmx left a comment

Choose a reason for hiding this comment

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

Thanks!

@xrmx xrmx moved this from Easy to review / merge / close to Approved PRs in Python PR digest Mar 2, 2026
@xrmx xrmx enabled auto-merge (squash) March 2, 2026 08:44
@xrmx xrmx merged commit 3fcabc3 into open-telemetry:main Mar 2, 2026
771 checks passed
@github-project-automation github-project-automation bot moved this from Approved PRs to Done in Python PR digest Mar 2, 2026
shuningc pushed a commit to shuningc/opentelemetry-python-contrib that referenced this pull request Mar 5, 2026
…try#4261)

* asyncio: fix environment variables not in docs

Fix the docstrings in environment_variables.py so they are correctly
picked up by Sphinx autodoc for Read the Docs.

Previously the docstrings were placed above the variable assignments,
which Sphinx cannot parse. Moved them below and added the
required '.. envvar::' directives, consistent with how other
packages (e.g. opentelemetry-instrumentation) document their
environment variables.

Fixes open-telemetry#4256

* Fix typo from 'determines' to 'determine'

* Apply suggestion from @xrmx

* asyncio: move environment_variables docs to __init__ module docstring for sphinx

* asyncio: keep envvar docs in environment_variables.py with module-level docstring

---------

Co-authored-by: Riccardo Magliocchetti <riccardo.magliocchetti@gmail.com>
sightseeker added a commit to sightseeker/opentelemetry-python-contrib that referenced this pull request Mar 11, 2026
…try#4261)

* asyncio: fix environment variables not in docs

Fix the docstrings in environment_variables.py so they are correctly
picked up by Sphinx autodoc for Read the Docs.

Previously the docstrings were placed above the variable assignments,
which Sphinx cannot parse. Moved them below and added the
required '.. envvar::' directives, consistent with how other
packages (e.g. opentelemetry-instrumentation) document their
environment variables.

Fixes open-telemetry#4256

* Fix typo from 'determines' to 'determine'

* Apply suggestion from @xrmx

* asyncio: move environment_variables docs to __init__ module docstring for sphinx

* asyncio: keep envvar docs in environment_variables.py with module-level docstring

---------

Co-authored-by: Riccardo Magliocchetti <riccardo.magliocchetti@gmail.com>
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.

asyncio: environment variables are not documented in the docs

3 participants