diff --git a/docs/examples/http/README.rst b/docs/examples/http/README.rst index c462d9f092d..edbb5044f69 100644 --- a/docs/examples/http/README.rst +++ b/docs/examples/http/README.rst @@ -3,7 +3,7 @@ HTTP Integration Example This example shows how to use :doc:`WSGI Middleware <../../ext/wsgi/wsgi>` -and :doc:`requests <../../ext/http_requests/http_requests>` integrations to +and :doc:`requests <../../ext/requests/requests>` integrations to instrument an HTTP client and server in Python. The source files required to run this example are available :scm_web:`here `. @@ -16,7 +16,7 @@ Installation pip install opentelemetry-api pip install opentelemetry-sdk pip install opentelemetry-ext-wsgi - pip install opentelemetry-ext-http-requests + pip install opentelemetry-ext-requests pip install flask @@ -60,6 +60,6 @@ Useful links - OpenTelemetry_ - :doc:`../../api/trace` - :doc:`../../ext/wsgi/wsgi` -- :doc:`../../ext/http_requests/http_requests` +- :doc:`../../ext/requests/requests` .. _OpenTelemetry: https://github.com/open-telemetry/opentelemetry-python/ \ No newline at end of file diff --git a/docs/examples/http/client.py b/docs/examples/http/client.py index 483e95b516a..56b0ca6ea76 100755 --- a/docs/examples/http/client.py +++ b/docs/examples/http/client.py @@ -19,7 +19,7 @@ import requests from opentelemetry import trace -from opentelemetry.ext import http_requests +from opentelemetry.ext.requests import RequestsInstrumentor from opentelemetry.sdk.trace import TracerProvider from opentelemetry.sdk.trace.export import ( BatchExportSpanProcessor, @@ -32,7 +32,7 @@ trace.set_tracer_provider(TracerProvider()) # Enable instrumentation in the requests library. -http_requests.RequestsInstrumentor().instrument() +RequestsInstrumentor().instrument() # Configure a console span exporter. exporter = ConsoleSpanExporter() diff --git a/docs/examples/http/server.py b/docs/examples/http/server.py index 46e2e22103b..10af2eb9513 100755 --- a/docs/examples/http/server.py +++ b/docs/examples/http/server.py @@ -20,7 +20,7 @@ import requests from opentelemetry import trace -from opentelemetry.ext import http_requests +from opentelemetry.ext.requests import RequestsInstrumentor from opentelemetry.ext.wsgi import OpenTelemetryMiddleware from opentelemetry.sdk.trace import TracerProvider from opentelemetry.sdk.trace.export import ( @@ -36,7 +36,7 @@ # Integrations are the glue that binds the OpenTelemetry API and the # frameworks and libraries that are used together, automatically creating # Spans and propagating context as appropriate. -http_requests.RequestsInstrumentor().instrument() +RequestsInstrumentor().instrument() app = flask.Flask(__name__) app.wsgi_app = OpenTelemetryMiddleware(app.wsgi_app) diff --git a/docs/examples/opentelemetry-example-app/setup.py b/docs/examples/opentelemetry-example-app/setup.py index 9764784ba27..fb78cd84463 100644 --- a/docs/examples/opentelemetry-example-app/setup.py +++ b/docs/examples/opentelemetry-example-app/setup.py @@ -37,7 +37,7 @@ "typing; python_version<'3.5'", "opentelemetry-api", "opentelemetry-sdk", - "opentelemetry-ext-http-requests", + "opentelemetry-ext-requests", "opentelemetry-ext-flask", "flask", "requests", diff --git a/docs/examples/opentelemetry-example-app/src/opentelemetry_example_app/flask_example.py b/docs/examples/opentelemetry-example-app/src/opentelemetry_example_app/flask_example.py index 1a9de310129..863d6f33890 100644 --- a/docs/examples/opentelemetry-example-app/src/opentelemetry_example_app/flask_example.py +++ b/docs/examples/opentelemetry-example-app/src/opentelemetry_example_app/flask_example.py @@ -19,7 +19,7 @@ import flask import requests -import opentelemetry.ext.http_requests +import opentelemetry.ext.requests from opentelemetry import trace from opentelemetry.ext.flask import FlaskInstrumentor from opentelemetry.sdk.trace import TracerProvider @@ -33,7 +33,7 @@ # It must be done before instrumenting any library trace.set_tracer_provider(TracerProvider()) -opentelemetry.ext.http_requests.RequestsInstrumentor().instrument() +opentelemetry.ext.requests.RequestsInstrumentor().instrument() FlaskInstrumentor().instrument() trace.get_tracer_provider().add_span_processor( diff --git a/docs/ext/http_requests/http_requests.rst b/docs/ext/requests/requests.rst similarity index 72% rename from docs/ext/http_requests/http_requests.rst rename to docs/ext/requests/requests.rst index 9cc09de547f..5959d4c9243 100644 --- a/docs/ext/http_requests/http_requests.rst +++ b/docs/ext/requests/requests.rst @@ -1,7 +1,7 @@ OpenTelemetry requests Integration ================================== -.. automodule:: opentelemetry.ext.http_requests +.. automodule:: opentelemetry.ext.requests :members: :undoc-members: :show-inheritance: diff --git a/docs/getting-started.rst b/docs/getting-started.rst index f4e6918d96f..f25cf79b77d 100644 --- a/docs/getting-started.rst +++ b/docs/getting-started.rst @@ -176,7 +176,7 @@ We will now instrument a basic Flask application that uses the requests library .. code-block:: sh pip install opentelemetry-ext-flask - pip install opentelemetry-ext-http-requests + pip install opentelemetry-ext-requests And let's write a small Flask application that sends an HTTP request, activating each instrumentation during the initialization: @@ -190,7 +190,7 @@ And let's write a small Flask application that sends an HTTP request, activating import flask import requests - import opentelemetry.ext.http_requests + import opentelemetry.ext.requests from opentelemetry import trace from opentelemetry.sdk.trace import TracerProvider from opentelemetry.sdk.trace.export import ConsoleSpanExporter @@ -202,7 +202,7 @@ And let's write a small Flask application that sends an HTTP request, activating ) app = flask.Flask(__name__) - opentelemetry.ext.http_requests.RequestsInstrumentor().instrument() + opentelemetry.ext.requests.RequestsInstrumentor().instrument() @app.route("/") def hello(): diff --git a/ext/opentelemetry-ext-http-requests/CHANGELOG.md b/ext/opentelemetry-ext-requests/CHANGELOG.md similarity index 70% rename from ext/opentelemetry-ext-http-requests/CHANGELOG.md rename to ext/opentelemetry-ext-requests/CHANGELOG.md index a3f8a8f1fbd..34ca8ff226a 100644 --- a/ext/opentelemetry-ext-http-requests/CHANGELOG.md +++ b/ext/opentelemetry-ext-requests/CHANGELOG.md @@ -2,6 +2,7 @@ ## Unreleased +- Rename package to opentelemetry-ext-requests ([#619](https://github.com/open-telemetry/opentelemetry-python/pull/619)) - Implement instrumentor interface ([#597](https://github.com/open-telemetry/opentelemetry-python/pull/597)) ## 0.3a0 diff --git a/ext/opentelemetry-ext-http-requests/LICENSE b/ext/opentelemetry-ext-requests/LICENSE similarity index 100% rename from ext/opentelemetry-ext-http-requests/LICENSE rename to ext/opentelemetry-ext-requests/LICENSE diff --git a/ext/opentelemetry-ext-http-requests/MANIFEST.in b/ext/opentelemetry-ext-requests/MANIFEST.in similarity index 100% rename from ext/opentelemetry-ext-http-requests/MANIFEST.in rename to ext/opentelemetry-ext-requests/MANIFEST.in diff --git a/ext/opentelemetry-ext-http-requests/README.rst b/ext/opentelemetry-ext-requests/README.rst similarity index 58% rename from ext/opentelemetry-ext-http-requests/README.rst rename to ext/opentelemetry-ext-requests/README.rst index 88cdecf31e2..95d80d4997b 100644 --- a/ext/opentelemetry-ext-http-requests/README.rst +++ b/ext/opentelemetry-ext-requests/README.rst @@ -3,8 +3,8 @@ OpenTelemetry requests Integration |pypi| -.. |pypi| image:: https://badge.fury.io/py/opentelemetry-ext-http-requests.svg - :target: https://pypi.org/project/opentelemetry-ext-http-requests/ +.. |pypi| image:: https://badge.fury.io/py/opentelemetry-ext-requests.svg + :target: https://pypi.org/project/opentelemetry-ext-requests/ This library allows tracing HTTP requests made by the `requests `_ library. @@ -14,10 +14,10 @@ Installation :: - pip install opentelemetry-ext-http-requests + pip install opentelemetry-ext-requests References ---------- -* `OpenTelemetry requests Integration `_ +* `OpenTelemetry requests Integration `_ * `OpenTelemetry Project `_ diff --git a/ext/opentelemetry-ext-http-requests/setup.cfg b/ext/opentelemetry-ext-requests/setup.cfg similarity index 91% rename from ext/opentelemetry-ext-http-requests/setup.cfg rename to ext/opentelemetry-ext-requests/setup.cfg index fc2ff724574..9ab8401dd0c 100644 --- a/ext/opentelemetry-ext-http-requests/setup.cfg +++ b/ext/opentelemetry-ext-requests/setup.cfg @@ -13,13 +13,13 @@ # limitations under the License. # [metadata] -name = opentelemetry-ext-http-requests +name = opentelemetry-ext-requests description = OpenTelemetry requests integration long_description = file: README.rst long_description_content_type = text/x-rst author = OpenTelemetry Authors author_email = cncf-opentelemetry-contributors@lists.cncf.io -url = https://github.com/open-telemetry/opentelemetry-python/tree/master/ext/opentelemetry-ext-http-requests +url = https://github.com/open-telemetry/opentelemetry-python/tree/master/ext/opentelemetry-ext-requests platforms = any license = Apache-2.0 classifiers = @@ -54,4 +54,4 @@ where = src [options.entry_points] opentelemetry_instrumentor = - requests = opentelemetry.ext.http_requests:RequestsInstrumentor + requests = opentelemetry.ext.requests:RequestsInstrumentor diff --git a/ext/opentelemetry-ext-http-requests/setup.py b/ext/opentelemetry-ext-requests/setup.py similarity index 91% rename from ext/opentelemetry-ext-http-requests/setup.py rename to ext/opentelemetry-ext-requests/setup.py index d7917ed893d..a71a8d44b5e 100644 --- a/ext/opentelemetry-ext-http-requests/setup.py +++ b/ext/opentelemetry-ext-requests/setup.py @@ -17,7 +17,7 @@ BASE_DIR = os.path.dirname(__file__) VERSION_FILENAME = os.path.join( - BASE_DIR, "src", "opentelemetry", "ext", "http_requests", "version.py" + BASE_DIR, "src", "opentelemetry", "ext", "requests", "version.py" ) PACKAGE_INFO = {} with open(VERSION_FILENAME) as f: diff --git a/ext/opentelemetry-ext-http-requests/src/opentelemetry/ext/http_requests/__init__.py b/ext/opentelemetry-ext-requests/src/opentelemetry/ext/requests/__init__.py similarity index 97% rename from ext/opentelemetry-ext-http-requests/src/opentelemetry/ext/http_requests/__init__.py rename to ext/opentelemetry-ext-requests/src/opentelemetry/ext/requests/__init__.py index 9bb176dfd1e..c98a24cc885 100644 --- a/ext/opentelemetry-ext-http-requests/src/opentelemetry/ext/http_requests/__init__.py +++ b/ext/opentelemetry-ext-requests/src/opentelemetry/ext/requests/__init__.py @@ -22,10 +22,10 @@ .. code-block:: python import requests - import opentelemetry.ext.http_requests + import opentelemetry.ext.requests # You can optionally pass a custom TracerProvider to RequestInstrumentor.instrument() - opentelemetry.ext.http_requests.RequestInstrumentor.instrument() + opentelemetry.ext.requests.RequestInstrumentor.instrument() response = requests.get(url="https://www.example.org/") Limitations @@ -49,7 +49,7 @@ from opentelemetry import context, propagators, trace from opentelemetry.auto_instrumentation.instrumentor import BaseInstrumentor -from opentelemetry.ext.http_requests.version import __version__ +from opentelemetry.ext.requests.version import __version__ from opentelemetry.trace import SpanKind, get_tracer from opentelemetry.trace.status import Status, StatusCanonicalCode diff --git a/ext/opentelemetry-ext-http-requests/src/opentelemetry/ext/http_requests/version.py b/ext/opentelemetry-ext-requests/src/opentelemetry/ext/requests/version.py similarity index 100% rename from ext/opentelemetry-ext-http-requests/src/opentelemetry/ext/http_requests/version.py rename to ext/opentelemetry-ext-requests/src/opentelemetry/ext/requests/version.py diff --git a/ext/opentelemetry-ext-http-requests/tests/__init__.py b/ext/opentelemetry-ext-requests/tests/__init__.py similarity index 100% rename from ext/opentelemetry-ext-http-requests/tests/__init__.py rename to ext/opentelemetry-ext-requests/tests/__init__.py diff --git a/ext/opentelemetry-ext-http-requests/tests/test_requests_integration.py b/ext/opentelemetry-ext-requests/tests/test_requests_integration.py similarity index 91% rename from ext/opentelemetry-ext-http-requests/tests/test_requests_integration.py rename to ext/opentelemetry-ext-requests/tests/test_requests_integration.py index 3cc0ac006a3..7764aad3ec5 100644 --- a/ext/opentelemetry-ext-http-requests/tests/test_requests_integration.py +++ b/ext/opentelemetry-ext-requests/tests/test_requests_integration.py @@ -18,8 +18,9 @@ import requests import urllib3 +import opentelemetry.ext.requests from opentelemetry import context, propagators, trace -from opentelemetry.ext import http_requests +from opentelemetry.ext.requests import RequestsInstrumentor from opentelemetry.sdk import resources from opentelemetry.test.mock_httptextformat import MockHTTPTextFormat from opentelemetry.test.test_base import TestBase @@ -30,7 +31,7 @@ class TestRequestsIntegration(TestBase): def setUp(self): super().setUp() - http_requests.RequestsInstrumentor().instrument() + RequestsInstrumentor().instrument() httpretty.enable() httpretty.register_uri( httpretty.GET, self.URL, body="Hello!", @@ -38,7 +39,7 @@ def setUp(self): def tearDown(self): super().tearDown() - http_requests.RequestsInstrumentor().uninstrument() + RequestsInstrumentor().uninstrument() httpretty.disable() def test_basic(self): @@ -67,7 +68,7 @@ def test_basic(self): span.status.canonical_code, trace.status.StatusCanonicalCode.OK ) - self.check_span_instrumentation_info(span, http_requests) + self.check_span_instrumentation_info(span, opentelemetry.ext.requests) def test_not_foundbasic(self): url_404 = "http://httpbin.org/status/404" @@ -111,17 +112,17 @@ def test_invalid_url(self): ) def test_uninstrument(self): - http_requests.RequestsInstrumentor().uninstrument() + RequestsInstrumentor().uninstrument() result = requests.get(self.URL) self.assertEqual(result.text, "Hello!") span_list = self.memory_exporter.get_finished_spans() self.assertEqual(len(span_list), 0) # instrument again to avoid annoying warning message - http_requests.RequestsInstrumentor().instrument() + RequestsInstrumentor().instrument() def test_uninstrument_session(self): session1 = requests.Session() - http_requests.RequestsInstrumentor().uninstrument_session(session1) + RequestsInstrumentor().uninstrument_session(session1) result = session1.get(self.URL) self.assertEqual(result.text, "Hello!") @@ -186,10 +187,8 @@ def test_custom_tracer_provider(self): resource = resources.Resource.create({}) result = self.create_tracer_provider(resource=resource) tracer_provider, exporter = result - http_requests.RequestsInstrumentor().uninstrument() - http_requests.RequestsInstrumentor().instrument( - tracer_provider=tracer_provider - ) + RequestsInstrumentor().uninstrument() + RequestsInstrumentor().instrument(tracer_provider=tracer_provider) result = requests.get(self.URL) self.assertEqual(result.text, "Hello!") diff --git a/opentelemetry-api/src/opentelemetry/metrics/__init__.py b/opentelemetry-api/src/opentelemetry/metrics/__init__.py index b3fe69ab59f..b7ad62adb2e 100644 --- a/opentelemetry-api/src/opentelemetry/metrics/__init__.py +++ b/opentelemetry-api/src/opentelemetry/metrics/__init__.py @@ -221,7 +221,7 @@ def get_meter( This should *not* be the name of the module that is instrumented but the name of the module doing the instrumentation. E.g., instead of ``"requests"``, use - ``"opentelemetry.ext.http_requests"``. + ``"opentelemetry.ext.requests"``. stateful: True/False to indicate whether the meter will be stateful. True indicates the meter computes checkpoints diff --git a/opentelemetry-api/src/opentelemetry/trace/__init__.py b/opentelemetry-api/src/opentelemetry/trace/__init__.py index a4b18a3ddc5..13aaf2c6a4f 100644 --- a/opentelemetry-api/src/opentelemetry/trace/__init__.py +++ b/opentelemetry-api/src/opentelemetry/trace/__init__.py @@ -461,7 +461,7 @@ def get_tracer( This should *not* be the name of the module that is instrumented but the name of the module doing the instrumentation. E.g., instead of ``"requests"``, use - ``"opentelemetry.ext.http_requests"``. + ``"opentelemetry.ext.requests"``. instrumenting_library_version: Optional. The version string of the instrumenting library. Usually this should be the same as diff --git a/scripts/coverage.sh b/scripts/coverage.sh index b9f9b6493e8..839380c27fd 100755 --- a/scripts/coverage.sh +++ b/scripts/coverage.sh @@ -18,7 +18,7 @@ coverage erase cov opentelemetry-api cov opentelemetry-sdk cov ext/opentelemetry-ext-flask -cov ext/opentelemetry-ext-http-requests +cov ext/opentelemetry-ext-requests cov ext/opentelemetry-ext-jaeger cov ext/opentelemetry-ext-opentracing-shim cov ext/opentelemetry-ext-wsgi diff --git a/tests/w3c_tracecontext_validation_server.py b/tests/w3c_tracecontext_validation_server.py index 3e4eb985d78..5961a3b0396 100644 --- a/tests/w3c_tracecontext_validation_server.py +++ b/tests/w3c_tracecontext_validation_server.py @@ -23,24 +23,23 @@ import flask import requests +from opentelemetry import trace +from opentelemetry.ext.requests import RequestsInstrumentor +from opentelemetry.ext.wsgi import OpenTelemetryMiddleware from opentelemetry.sdk.trace import TracerProvider - -# FIXME This could likely be avoided by integrating this script into the -# standard test running mechanisms. - -from opentelemetry import trace # noqa # isort:skip -from opentelemetry.ext import http_requests # noqa # isort:skip" -from opentelemetry.ext.wsgi import OpenTelemetryMiddleware # noqa # isort:skip -from opentelemetry.sdk.trace.export import ( # noqa # isort:skip +from opentelemetry.sdk.trace.export import ( ConsoleSpanExporter, SimpleExportSpanProcessor, ) +# FIXME This could likely be avoided by integrating this script into the +# standard test running mechanisms. + # Integrations are the glue that binds the OpenTelemetry API and the # frameworks and libraries that are used together, automatically creating # Spans and propagating context as appropriate. trace.set_tracer_provider(TracerProvider()) -http_requests.RequestsInstrumentor().instrument() +RequestsInstrumentor().instrument() # SpanExporter receives the spans and send them to the target location. span_processor = SimpleExportSpanProcessor(ConsoleSpanExporter()) diff --git a/tox.ini b/tox.ini index 1b0243c072b..1570df787c6 100644 --- a/tox.ini +++ b/tox.ini @@ -36,9 +36,9 @@ envlist = py3{4,5,6,7,8}-test-ext-flask pypy3-test-ext-flask - ; opentelemetry-ext-http-requests - py3{4,5,6,7,8}-test-ext-http-requests - pypy3-test-ext-http-requests + ; opentelemetry-ext-requests + py3{4,5,6,7,8}-test-ext-requests + pypy3-test-ext-requests ; opentelemetry-ext-jaeger py3{4,5,6,7,8}-test-ext-jaeger @@ -124,7 +124,7 @@ changedir = test-sdk: opentelemetry-sdk/tests test-auto-instrumentation: opentelemetry-auto-instrumentation/tests test-ext-grpc: ext/opentelemetry-ext-grpc/tests - test-ext-http-requests: ext/opentelemetry-ext-http-requests/tests + test-ext-requests: ext/opentelemetry-ext-requests/tests test-ext-jaeger: ext/opentelemetry-ext-jaeger/tests test-ext-dbapi: ext/opentelemetry-ext-dbapi/tests test-ext-mysql: ext/opentelemetry-ext-mysql/tests @@ -156,13 +156,13 @@ commands_pre = test-auto-instrumentation: pip install {toxinidir}/opentelemetry-auto-instrumentation example-app: pip install {toxinidir}/opentelemetry-auto-instrumentation - example-app: pip install {toxinidir}/ext/opentelemetry-ext-http-requests + example-app: pip install {toxinidir}/ext/opentelemetry-ext-requests example-app: pip install {toxinidir}/ext/opentelemetry-ext-wsgi example-app: pip install {toxinidir}/ext/opentelemetry-ext-flask example-app: pip install {toxinidir}/docs/examples/opentelemetry-example-app example-http: pip install -e {toxinidir}/opentelemetry-auto-instrumentation - example-http: pip install -e {toxinidir}/ext/opentelemetry-ext-http-requests + example-http: pip install -e {toxinidir}/ext/opentelemetry-ext-requests example-http: pip install -e {toxinidir}/ext/opentelemetry-ext-wsgi example-http: pip install -r {toxinidir}/docs/examples/http/requirements.txt @@ -195,8 +195,8 @@ commands_pre = redis: pip install {toxinidir}/opentelemetry-auto-instrumentation redis: pip install {toxinidir}/ext/opentelemetry-ext-redis[test] - http-requests: pip install {toxinidir}/opentelemetry-auto-instrumentation - http-requests: pip install {toxinidir}/ext/opentelemetry-ext-http-requests[test] + requests: pip install {toxinidir}/opentelemetry-auto-instrumentation + requests: pip install {toxinidir}/ext/opentelemetry-ext-requests[test] jaeger: pip install {toxinidir}/ext/opentelemetry-ext-jaeger @@ -271,7 +271,7 @@ commands_pre = -e {toxinidir}/opentelemetry-auto-instrumentation \ -e {toxinidir}/opentelemetry-sdk \ -e {toxinidir}/opentelemetry-auto-instrumentation \ - -e {toxinidir}/ext/opentelemetry-ext-http-requests \ + -e {toxinidir}/ext/opentelemetry-ext-requests \ -e {toxinidir}/ext/opentelemetry-ext-wsgi \ -e {toxinidir}/ext/opentelemetry-ext-flask