Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename docs/example file for http metrics from "http.py" to "http_metrics" as it leads to namespace conflicts in request library #1271

Merged
merged 1 commit into from
Oct 22, 2020

Conversation

pavankrish123
Copy link
Contributor

Description

This is a minor fix for a small issue from PR #1116. The example file for demonstrating http metrics is named as http.py. This leads to a shadow import with another file in requests causing the import scream.


(env) basic_meter $ python http.py 
Traceback (most recent call last):
  File "http.py", line 19, in <module>
    import requests
  File "/Users/pavankri/ot/opentelemetry-python/env/lib/python3.8/site-packages/requests/__init__.py", line 43, in <module>
    import urllib3
  File "/Users/pavankri/ot/opentelemetry-python/env/lib/python3.8/site-packages/urllib3/__init__.py", line 7, in <module>
    from .connectionpool import HTTPConnectionPool, HTTPSConnectionPool, connection_from_url
  File "/Users/pavankri/ot/opentelemetry-python/env/lib/python3.8/site-packages/urllib3/connectionpool.py", line 11, in <module>
    from .exceptions import (
  File "/Users/pavankri/ot/opentelemetry-python/env/lib/python3.8/site-packages/urllib3/exceptions.py", line 2, in <module>
    from .packages.six.moves.http_client import IncompleteRead as httplib_IncompleteRead
  File "/Users/pavankri/ot/opentelemetry-python/env/lib/python3.8/site-packages/urllib3/packages/six.py", line 199, in load_module
    mod = mod._resolve()
  File "/Users/pavankri/ot/opentelemetry-python/env/lib/python3.8/site-packages/urllib3/packages/six.py", line 113, in _resolve
    return _import_module(self.mod)
  File "/Users/pavankri/ot/opentelemetry-python/env/lib/python3.8/site-packages/urllib3/packages/six.py", line 82, in _import_module
    __import__(name)
  File "/Users/pavankri/ot/opentelemetry-python/docs/examples/basic_meter/http.py", line 22, in <module>
    from opentelemetry.instrumentation.requests import RequestsInstrumentor
  File "/Users/pavankri/ot/opentelemetry-python/env/lib/python3.8/site-packages/opentelemetry/instrumentation/requests/__init__.py", line 39, in <module>
    from requests import Timeout, URLRequired
ImportError: cannot import name 'Timeout' from partially initialized module 'requests' (most likely due to a circular import) (/Users/pavankri/ot/opentelemetry-python/env/lib/python3.8/site-packages/requests/__init__.py)

Fixes # (issue)

Type of change

Please delete options that are not relevant.

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

How Has This Been Tested?

  • Renamed the file to something appropriate http_metrics.py and that resolved the issue. Verified the example is working as expected

  • [ X] Test A

(env) basic_meter   $ mv http.py http_metrics.py
(env) basic_meter   $ python http_metrics.py 
...
ConsoleMetricsExporter(data="ValueRecorder(name="http.client.duration", description="measures the duration of the outbound HTTP request")", labels="(('http.flavor', '1.1'), ('http.method', 'GET'), ('http.status_code', '200'), ('http.url', 'http://example.com'))", value=minmaxsumcount(min=77.86989212036133, max=77.86989212036133, sum=77.86989212036133, count=1), resource={'telemetry.sdk.language': 'python', 'telemetry.sdk.name': 'opentelemetry', 'telemetry.sdk.version': '0.15.dev0'})

Checklist:

  • Followed the style guidelines of this project
  • Changelogs have been updated (N/A)
  • Unit tests have been added (N/A)
  • Documentation has been updated

@pavankrish123 pavankrish123 requested review from a team, aabmass and hectorhdzg and removed request for a team October 21, 2020 23:34
@pavankrish123 pavankrish123 changed the title Rename http metrics example file name from "http.py" as it leads to namespace conflicts in request library [Donot merge] Rename http metrics example file name from "http.py" as it leads to namespace conflicts in request library Oct 21, 2020
@pavankrish123 pavankrish123 changed the title [Donot merge] Rename http metrics example file name from "http.py" as it leads to namespace conflicts in request library Rename http metrics example file name from "http.py" as it leads to namespace conflicts in request library Oct 21, 2020
@pavankrish123 pavankrish123 changed the title Rename http metrics example file name from "http.py" as it leads to namespace conflicts in request library Rename docs/example file for http metrics from "http.py" to "http_metrics" as it leads to namespace conflicts in request library Oct 21, 2020
Copy link
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.

Thanks for the PR!

@codeboten codeboten merged commit cdd9fd2 into open-telemetry:master Oct 22, 2020
srikanthccv pushed a commit to srikanthccv/opentelemetry-python that referenced this pull request Nov 1, 2020
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.

3 participants