Skip to content

asyncio: fix environment variables not appearing in docs#4261

Open
srikaaviya wants to merge 5 commits intoopen-telemetry:mainfrom
srikaaviya:fix-asyncio-env-var-docs
Open

asyncio: fix environment variables not appearing in docs#4261
srikaaviya wants to merge 5 commits intoopen-telemetry:mainfrom
srikaaviya:fix-asyncio-env-var-docs

Conversation

@srikaaviya
Copy link

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 @xrmx's 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 @xrmx's 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
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
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
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
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
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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Easy to review / merge / close

Development

Successfully merging this pull request may close these issues.

asyncio: environment variables are not documented in the docs

3 participants