Skip to content

ReadTheDocs and pkg_resources fix#1145

Merged
codeboten merged 3 commits intoopen-telemetry:masterfrom
aabmass:fix-docs-1144
Sep 24, 2020
Merged

ReadTheDocs and pkg_resources fix#1145
codeboten merged 3 commits intoopen-telemetry:masterfrom
aabmass:fix-docs-1144

Conversation

@aabmass
Copy link
Copy Markdown
Member

@aabmass aabmass commented Sep 22, 2020

Description

ReadTheDocs builds do not currently install the OTel packages in a virtualenv, but just update sys.path to include the modules. Autodoc imports the modules, which runs this code, but since the package isn't installed, pkg_resources.get_distribution() fails.

This change has opentelemetry-api and opentelemetry-sdk installed in the virtualenv to fix this.

Fixes #1144

Type of change

Please delete options that are not relevant.

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

How Has This Been Tested?

Ran the commands from https://readthedocs.org/projects/opentelemetry-python/builds/11937984/ and the issue is resolved.

$ python3 -m venv venv-docs && source venv-docs/bin/activate
$ python -m pip install --upgrade --no-cache-dir pip
$ python -m pip install --upgrade --no-cache-dir Pygments==2.3.1 setuptools==41.0.1 docutils==0.14 mock==1.0.1 pillow==5
.4.1 'alabaster>=0.7,<0.8,!=0.7.5' commonmark==0.8.1 recommonmark==0.5.0 'sphinx<2' 'sphinx-rtd-theme<0.5' 'readthedocs-sphinx-ext<1.1'
$ python -m pip install --exists-action=w --no-cache-dir -r docs-requirements.txt
$ sphinx-build -T -E -b html -d _build/doctrees-readthedocs -D language=en . _build/html

Checklist:

  • Followed the style guidelines of this project

@aabmass aabmass requested a review from a team September 22, 2020 20:36
Copy link
Copy Markdown
Contributor

@codeboten codeboten left a comment

Choose a reason for hiding this comment

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

This approach seems fine to me. Thanks for the fix!

TELEMETRY_SDK_NAME = "telemetry.sdk.name"
TELEMETRY_SDK_VERSION = "telemetry.sdk.version"

OPENTELEMETRY_SDK_VERSION = pkg_resources.get_distribution(
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.

Would opencensus-exporter have the same issue?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I believe it would if the autodoc directive included that util.py file, but it just includes it doesn't: https://github.com/open-telemetry/opentelemetry-python/blob/master/docs/exporter/opencensus/opencensus.rst

So all you see in the docs here is the docstring here:

"""
The **OpenCensus Exporter** allows to export traces and metrics using
OpenCensus.
"""

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I could fix that one up to do this as well though in case it's added in the future. Another option is to update the docs-requirements.txt file to actually install the opentelemetry-sdk/opentelemetry-api in the virtualenv so that pkg_resources.get_distrubution() works correctly.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Gonna go with this second approach instead 👍

@codeboten codeboten merged commit 7636547 into open-telemetry:master Sep 24, 2020
@aabmass aabmass deleted the fix-docs-1144 branch September 24, 2020 14:51
srikanthccv pushed a commit to srikanthccv/opentelemetry-python that referenced this pull request Nov 1, 2020
* chore: creating new metric kind

* chore: adding todo to remove observer kind later
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ReadTheDocs configuration issue

3 participants