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

ext: Rename http_requests to requests #619

Merged
merged 3 commits into from
May 3, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions docs/examples/http/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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 <docs/examples/http/>`.
Expand All @@ -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


Expand Down Expand Up @@ -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/
4 changes: 2 additions & 2 deletions docs/examples/http/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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()
Expand Down
4 changes: 2 additions & 2 deletions docs/examples/http/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand All @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion docs/examples/opentelemetry-example-app/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
OpenTelemetry requests Integration
==================================

.. automodule:: opentelemetry.ext.http_requests
.. automodule:: opentelemetry.ext.requests
:members:
:undoc-members:
:show-inheritance:
6 changes: 3 additions & 3 deletions docs/getting-started.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand All @@ -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():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 <https://requests.readthedocs.io/en/master/>`_ library.
Expand All @@ -14,10 +14,10 @@ Installation

::

pip install opentelemetry-ext-http-requests
pip install opentelemetry-ext-requests

References
----------

* `OpenTelemetry requests Integration <https://opentelemetry-python.readthedocs.io/en/latest/ext/http_requests/http_requests..html>`_
* `OpenTelemetry requests Integration <https://opentelemetry-python.readthedocs.io/en/latest/ext/requests/requests.html>`_
* `OpenTelemetry Project <https://opentelemetry.io/>`_
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down Expand Up @@ -54,4 +54,4 @@ where = src

[options.entry_points]
opentelemetry_instrumentor =
requests = opentelemetry.ext.http_requests:RequestsInstrumentor
requests = opentelemetry.ext.requests:RequestsInstrumentor
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -30,15 +31,15 @@ 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!",
)

def tearDown(self):
super().tearDown()
http_requests.RequestsInstrumentor().uninstrument()
RequestsInstrumentor().uninstrument()
httpretty.disable()

def test_basic(self):
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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!")
Expand Down Expand Up @@ -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!")
Expand Down
2 changes: 1 addition & 1 deletion opentelemetry-api/src/opentelemetry/metrics/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion opentelemetry-api/src/opentelemetry/trace/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion scripts/coverage.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 8 additions & 9 deletions tests/w3c_tracecontext_validation_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
Loading