Skip to content

Commit

Permalink
Merge branch 'master' into fix/requests-none-header-argument
Browse files Browse the repository at this point in the history
  • Loading branch information
alrex committed Jun 9, 2020
2 parents 95d132a + 1041e11 commit dc02ae5
Show file tree
Hide file tree
Showing 84 changed files with 501 additions and 447 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ Approvers ([@open-telemetry/python-approvers](https://github.com/orgs/open-telem
- [Chris Kleinknecht](https://github.com/c24t), Google
- [Diego Hurtado](https://github.com/ocelotl)
- [Hector Hernandez](https://github.com/hectorhdzg), Microsoft
- [Leighton Chen](https://github.com/lzchen), Microsoft
- [Mauricio Vásquez](https://github.com/mauriciovasquezbernal), Kinvolk
- [Reiley Yang](https://github.com/reyang), Microsoft

Expand All @@ -116,16 +115,17 @@ Approvers ([@open-telemetry/python-approvers](https://github.com/orgs/open-telem
Maintainers ([@open-telemetry/python-maintainers](https://github.com/orgs/open-telemetry/teams/python-maintainers)):

- [Alex Boten](https://github.com/codeboten), LightStep
- [Leighton Chen](https://github.com/lzchen), Microsoft
- [Yusuke Tsutsumi](https://github.com/toumorokoshi), Zillow Group

*Find more about the maintainer role in [community repository](https://github.com/open-telemetry/community/blob/master/community-membership.md#maintainer).*

### Thanks to all the people who already contributed!

<a href="https://github.com/open-telemetry/opentelemetry-python/graphs/contributors">
<img src="https://contributors-img.web.app/image?repo=open-telemetry/opentelemetry-python" />
</a>

*Find more about the maintainer role in [community repository](https://github.com/open-telemetry/community/blob/master/community-membership.md#maintainer).*

## Release Schedule

OpenTelemetry Python is under active development.
Expand Down
2 changes: 1 addition & 1 deletion dev-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ pylint==2.4.4
flake8==3.7.9
isort~=4.3
black>=19.3b0,==19.*
mypy==0.740
mypy==0.770
sphinx~=2.1
sphinx-rtd-theme~=0.4
sphinx-autodoc-typehints~=1.10.2
Expand Down
15 changes: 0 additions & 15 deletions docs/auto_instrumentation/auto_instrumentation.rst

This file was deleted.

7 changes: 0 additions & 7 deletions docs/auto_instrumentation/instrumentor.rst

This file was deleted.

2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
source_dirs = [
os.path.abspath("../opentelemetry-api/src/"),
os.path.abspath("../opentelemetry-sdk/src/"),
os.path.abspath("../opentelemetry-auto-instrumentation/src/"),
os.path.abspath("../opentelemetry-instrumentation/src/"),
]

ext = "../ext"
Expand Down
4 changes: 2 additions & 2 deletions docs/examples/auto-instrumentation/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ Installation
.. code:: sh
$ pip install opentelemetry-sdk
$ pip install opentelemetry-auto-instrumentation
$ pip install opentelemetry-instrumentation
$ pip install opentelemetry-ext-flask
$ pip install requests
Expand Down Expand Up @@ -138,7 +138,7 @@ and run this instead:

.. code:: sh
$ opentelemetry-auto-instrumentation python server_uninstrumented.py
$ opentelemetry-instrument python server_uninstrumented.py
In the console where you previously executed ``client.py``, run again
this again:
Expand Down
3 changes: 2 additions & 1 deletion docs/examples/basic_meter/observer.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import psutil

from opentelemetry import metrics
from opentelemetry.sdk.metrics import MeterProvider
from opentelemetry.sdk.metrics import MeterProvider, ValueObserver
from opentelemetry.sdk.metrics.export import ConsoleMetricsExporter
from opentelemetry.sdk.metrics.export.batcher import UngroupedBatcher
from opentelemetry.sdk.metrics.export.controller import PushController
Expand All @@ -43,6 +43,7 @@ def get_cpu_usage_callback(observer):
description="per-cpu usage",
unit="1",
value_type=float,
observer_type=ValueObserver,
label_keys=("cpu_number",),
)

Expand Down
8 changes: 4 additions & 4 deletions docs/examples/datadog_exporter/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Auto-Instrumention Example
pip install opentelemetry-api
pip install opentelemetry-sdk
pip install opentelemetry-ext-datadog
pip install opentelemetry-auto-instrumentation
pip install opentelemetry-instrumentation
pip install opentelemetry-ext-flask
pip install flask
pip install requests
Expand All @@ -66,16 +66,16 @@ Auto-Instrumention Example

.. code-block:: sh
opentelemetry-auto-instrumentation python server.py
opentelemetry-instrument python server.py
* Run client

.. code-block:: sh
opentelemetry-auto-instrumentation python client.py testing
opentelemetry-instrument python client.py testing
* Run client with parameter to raise error

.. code-block:: sh
opentelemetry-auto-instrumentation python client.py error
opentelemetry-instrument python client.py error
2 changes: 1 addition & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ install <https://pip.pypa.io/en/stable/reference/pip_install/#editable-installs>

api/api
sdk/sdk
auto_instrumentation/auto_instrumentation
instrumentation/instrumentation

.. toctree::
:maxdepth: 2
Expand Down
15 changes: 15 additions & 0 deletions docs/instrumentation/instrumentation.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
OpenTelemetry Python Instrumentation
====================================

.. automodule:: opentelemetry.instrumentation
:members:
:undoc-members:
:show-inheritance:

Submodules
----------

.. toctree::
:maxdepth: 1

instrumentor
7 changes: 7 additions & 0 deletions docs/instrumentation/instrumentor.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
opentelemetry.instrumentation.instrumentor package
==================================================

.. automodule:: opentelemetry.instrumentation.instrumentor
:members:
:undoc-members:
:show-inheritance:
2 changes: 1 addition & 1 deletion eachdist.ini
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
sortfirst=
opentelemetry-api
opentelemetry-sdk
opentelemetry-auto-instrumentation
opentelemetry-instrumentation
ext/opentelemetry-ext-wsgi
ext/opentelemetry-ext-dbapi
ext/*
Expand Down
1 change: 1 addition & 0 deletions ext/opentelemetry-ext-aiohttp-client/setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ package_dir=
packages=find_namespace:
install_requires =
opentelemetry-api >= 0.9.dev0
opentelemetry-instrumentation == 0.9.dev0
aiohttp ~= 3.0

[options.packages.find]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,38 +52,11 @@ def strip_query_params(url: yarl.URL) -> str:
from opentelemetry import context as context_api
from opentelemetry import propagators, trace
from opentelemetry.ext.aiohttp_client.version import __version__
from opentelemetry.instrumentation.utils import http_status_to_canonical_code
from opentelemetry.trace import SpanKind
from opentelemetry.trace.status import Status, StatusCanonicalCode


# TODO: refactor this code to some common utility
def http_status_to_canonical_code(status: int) -> StatusCanonicalCode:
# pylint:disable=too-many-branches,too-many-return-statements
if status < 100:
return StatusCanonicalCode.UNKNOWN
if status <= 399:
return StatusCanonicalCode.OK
if status <= 499:
if status == 401: # HTTPStatus.UNAUTHORIZED:
return StatusCanonicalCode.UNAUTHENTICATED
if status == 403: # HTTPStatus.FORBIDDEN:
return StatusCanonicalCode.PERMISSION_DENIED
if status == 404: # HTTPStatus.NOT_FOUND:
return StatusCanonicalCode.NOT_FOUND
if status == 429: # HTTPStatus.TOO_MANY_REQUESTS:
return StatusCanonicalCode.RESOURCE_EXHAUSTED
return StatusCanonicalCode.INVALID_ARGUMENT
if status <= 599:
if status == 501: # HTTPStatus.NOT_IMPLEMENTED:
return StatusCanonicalCode.UNIMPLEMENTED
if status == 503: # HTTPStatus.SERVICE_UNAVAILABLE:
return StatusCanonicalCode.UNAVAILABLE
if status == 504: # HTTPStatus.GATEWAY_TIMEOUT:
return StatusCanonicalCode.DEADLINE_EXCEEDED
return StatusCanonicalCode.INTERNAL
return StatusCanonicalCode.UNKNOWN


def url_path_span_name(params: aiohttp.TraceRequestStartParams) -> str:
"""Extract a span name from the request URL path.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,43 +98,6 @@ async def default_handler(request):
loop = asyncio.get_event_loop()
return loop.run_until_complete(do_request())

def test_http_status_to_canonical_code(self):
for status_code, expected in (
(HTTPStatus.OK, StatusCanonicalCode.OK),
(HTTPStatus.ACCEPTED, StatusCanonicalCode.OK),
(HTTPStatus.IM_USED, StatusCanonicalCode.OK),
(HTTPStatus.MULTIPLE_CHOICES, StatusCanonicalCode.OK),
(HTTPStatus.BAD_REQUEST, StatusCanonicalCode.INVALID_ARGUMENT),
(HTTPStatus.UNAUTHORIZED, StatusCanonicalCode.UNAUTHENTICATED),
(HTTPStatus.FORBIDDEN, StatusCanonicalCode.PERMISSION_DENIED),
(HTTPStatus.NOT_FOUND, StatusCanonicalCode.NOT_FOUND),
(
HTTPStatus.UNPROCESSABLE_ENTITY,
StatusCanonicalCode.INVALID_ARGUMENT,
),
(
HTTPStatus.TOO_MANY_REQUESTS,
StatusCanonicalCode.RESOURCE_EXHAUSTED,
),
(HTTPStatus.NOT_IMPLEMENTED, StatusCanonicalCode.UNIMPLEMENTED),
(HTTPStatus.SERVICE_UNAVAILABLE, StatusCanonicalCode.UNAVAILABLE),
(
HTTPStatus.GATEWAY_TIMEOUT,
StatusCanonicalCode.DEADLINE_EXCEEDED,
),
(
HTTPStatus.HTTP_VERSION_NOT_SUPPORTED,
StatusCanonicalCode.INTERNAL,
),
(600, StatusCanonicalCode.UNKNOWN),
(99, StatusCanonicalCode.UNKNOWN),
):
with self.subTest(status_code=status_code):
actual = opentelemetry.ext.aiohttp_client.http_status_to_canonical_code(
int(status_code)
)
self.assertEqual(actual, expected, status_code)

def test_status_codes(self):
for status_code, span_status in (
(HTTPStatus.OK, StatusCanonicalCode.OK),
Expand Down
2 changes: 1 addition & 1 deletion ext/opentelemetry-ext-boto/setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ packages=find_namespace:
install_requires =
boto ~= 2.0
opentelemetry-api == 0.9.dev0
opentelemetry-auto-instrumentation == 0.9.dev0
opentelemetry-instrumentation == 0.9.dev0

[options.extras_require]
test =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
Instrument `Boto`_ to trace service requests.
There are two options for instrumenting code. The first option is to use the
``opentelemetry-auto-instrumentation`` executable which will automatically
``opentelemetry-instrument`` executable which will automatically
instrument your Boto client. The second is to programmatically enable
instrumentation via the following code:
Expand Down Expand Up @@ -50,8 +50,8 @@
from boto.connection import AWSAuthConnection, AWSQueryConnection
from wrapt import ObjectProxy, wrap_function_wrapper

from opentelemetry.auto_instrumentation.instrumentor import BaseInstrumentor
from opentelemetry.ext.boto.version import __version__
from opentelemetry.instrumentation.instrumentor import BaseInstrumentor
from opentelemetry.trace import SpanKind, get_tracer

logger = logging.getLogger(__name__)
Expand Down
1 change: 1 addition & 0 deletions ext/opentelemetry-ext-dbapi/setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ package_dir=
packages=find_namespace:
install_requires =
opentelemetry-api == 0.9.dev0
opentelemetry-instrumentation == 0.9.dev0
wrapt >= 1.0.0, < 2.0.0

[options.extras_require]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
import wrapt

from opentelemetry.ext.dbapi.version import __version__
from opentelemetry.instrumentation.utils import unwrap
from opentelemetry.trace import SpanKind, Tracer, TracerProvider, get_tracer
from opentelemetry.trace.status import Status, StatusCanonicalCode

Expand Down Expand Up @@ -141,9 +142,7 @@ def unwrap_connect(
connect_module: Module name where the connect method is available.
connect_method_name: The connect method name.
"""
conn = getattr(connect_module, connect_method_name, None)
if isinstance(conn, wrapt.ObjectProxy):
setattr(connect_module, connect_method_name, conn.__wrapped__)
unwrap(connect_module, connect_method_name)


def instrument_connection(
Expand Down
2 changes: 1 addition & 1 deletion ext/opentelemetry-ext-django/setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ packages=find_namespace:
install_requires =
django >= 1.10
opentelemetry-ext-wsgi == 0.9.dev0
opentelemetry-auto-instrumentation == 0.9.dev0
opentelemetry-instrumentation == 0.9.dev0
opentelemetry-api == 0.9.dev0

[options.extras_require]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@

from django.conf import settings

from opentelemetry.auto_instrumentation.instrumentor import BaseInstrumentor
from opentelemetry.configuration import Configuration
from opentelemetry.ext.django.middleware import _DjangoMiddleware
from opentelemetry.instrumentation.instrumentor import BaseInstrumentor

_logger = getLogger(__name__)

Expand Down
2 changes: 1 addition & 1 deletion ext/opentelemetry-ext-flask/setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ packages=find_namespace:
install_requires =
flask ~= 1.0
opentelemetry-ext-wsgi == 0.9.dev0
opentelemetry-auto-instrumentation == 0.9.dev0
opentelemetry-instrumentation == 0.9.dev0
opentelemetry-api == 0.9.dev0

[options.extras_require]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ def hello():

import opentelemetry.ext.wsgi as otel_wsgi
from opentelemetry import configuration, context, propagators, trace
from opentelemetry.auto_instrumentation.instrumentor import BaseInstrumentor
from opentelemetry.ext.flask.version import __version__
from opentelemetry.instrumentation.instrumentor import BaseInstrumentor
from opentelemetry.util import disable_trace, time_ns

_logger = getLogger(__name__)
Expand Down
2 changes: 1 addition & 1 deletion ext/opentelemetry-ext-jinja2/setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ package_dir=
packages=find_namespace:
install_requires =
opentelemetry-api == 0.9.dev0
opentelemetry-auto-instrumentation == 0.9.dev0
opentelemetry-instrumentation == 0.9.dev0
jinja2~=2.7
wrapt >= 1.0.0, < 2.0.0

Expand Down
Loading

0 comments on commit dc02ae5

Please sign in to comment.