Skip to content

Commit

Permalink
Merge branch 'open-telemetry:main' into grpc_dev
Browse files Browse the repository at this point in the history
  • Loading branch information
CoLa5 committed Aug 14, 2022
2 parents ea0a4a3 + 7625b82 commit 1b9dc9a
Show file tree
Hide file tree
Showing 121 changed files with 1,130 additions and 353 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
- 'release/*'
pull_request:
env:
CORE_REPO_SHA: c09f2076a1878c6d58b78d3895485ef5559f30f7
CORE_REPO_SHA: ece57231cde5bb5656775a62f027cab0b1c76fce

jobs:
build:
Expand Down
15 changes: 14 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,27 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased](https://github.com/open-telemetry/opentelemetry-python/compare/v1.12.0rc2-0.32b0...HEAD)
## [Unreleased]

## [1.12.0-0.33b0](https://github.com/open-telemetry/opentelemetry-python/releases/tag/v1.12.0-0.33b0) - 2022-08-08

- Adding multiple db connections support for django-instrumentation's sqlcommenter
([#1187](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/1187))
- SQLCommenter semicolon bug fix
([#1200](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/1200/files))
- Adding sqlalchemy native tags in sqlalchemy commenter
([#1206](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/1206))
- Add psycopg2 native tags to sqlcommenter
([#1203](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/1203))

### Added
- `opentelemetry-instrumentation-redis` add support to instrument RedisCluster clients
([#1177](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/1177))
- `opentelemetry-instrumentation-sqlalchemy` Added span for the connection phase ([#1133](https://github.com/open-telemetry/opentelemetry-python-contrib/issues/1133))
- Add metric instrumentation in asgi
([#1197](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/1197))
- Add metric instumentation for flask
([#1186](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/1186))

## [1.12.0rc2-0.32b0](https://github.com/open-telemetry/opentelemetry-python/releases/tag/v1.12.0rc2-0.32b0) - 2022-07-01

Expand Down Expand Up @@ -51,6 +62,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
([#1127](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/1127))
- Add metric instrumentation for WSGI
([#1128](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/1128))
- Add metric instrumentation for Urllib3
([#1198](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/1198))
- `opentelemetry-instrumentation-aio-pika` added RabbitMQ aio-pika module instrumentation.
([#1095](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/1095))
- `opentelemetry-instrumentation-requests` Restoring metrics in requests
Expand Down
2 changes: 1 addition & 1 deletion _template/setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ package_dir=
packages=find_namespace:

install_requires =
opentelemetry-api ~= 1.3
opentelemetry-api ~= 1.12

[options.extras_require]
test =
Expand Down
2 changes: 1 addition & 1 deletion _template/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.

__version__ = "0.32b0"
__version__ = "0.33b0"
4 changes: 3 additions & 1 deletion docs-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,6 @@ httpx>=0.18.0

# indirect dependency pins
markupsafe==2.0.1
itsdangerous==2.0.1
itsdangerous==2.0.1

docutils==0.16
4 changes: 2 additions & 2 deletions eachdist.ini
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ sortfirst=
ext/*

[stable]
version=1.12.0rc2
version=1.12.0

packages=
opentelemetry-sdk
Expand All @@ -34,7 +34,7 @@ packages=
opentelemetry-api

[prerelease]
version=0.32b0
version=0.33b0

packages=
all
Expand Down
4 changes: 2 additions & 2 deletions exporter/opentelemetry-exporter-datadog/setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ package_dir=
packages=find_namespace:
install_requires =
ddtrace>=0.34.0,<0.47.0
opentelemetry-api ~= 1.3
opentelemetry-sdk ~= 1.3
opentelemetry-api ~= 1.12
opentelemetry-sdk ~= 1.12
opentelemetry-semantic-conventions == 0.30b0

[options.packages.find]
Expand Down
6 changes: 3 additions & 3 deletions exporter/opentelemetry-exporter-richconsole/setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ package_dir=
packages=find_namespace:
install_requires =
rich>=10.0.0
opentelemetry-api ~= 1.3
opentelemetry-sdk ~= 1.3
opentelemetry-semantic-conventions == 0.32b0
opentelemetry-api ~= 1.12
opentelemetry-sdk ~= 1.12
opentelemetry-semantic-conventions == 0.33b0

[options.packages.find]
where = src
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.

__version__ = "0.32b0"
__version__ = "0.33b0"
4 changes: 2 additions & 2 deletions instrumentation/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
| [opentelemetry-instrumentation-elasticsearch](./opentelemetry-instrumentation-elasticsearch) | elasticsearch >= 2.0 | No
| [opentelemetry-instrumentation-falcon](./opentelemetry-instrumentation-falcon) | falcon >= 1.4.1, < 4.0.0 | No
| [opentelemetry-instrumentation-fastapi](./opentelemetry-instrumentation-fastapi) | fastapi ~= 0.58 | No
| [opentelemetry-instrumentation-flask](./opentelemetry-instrumentation-flask) | flask >= 1.0, < 3.0 | No
| [opentelemetry-instrumentation-flask](./opentelemetry-instrumentation-flask) | flask >= 1.0, < 3.0 | Yes
| [opentelemetry-instrumentation-grpc](./opentelemetry-instrumentation-grpc) | grpcio ~= 1.27 | No
| [opentelemetry-instrumentation-httpx](./opentelemetry-instrumentation-httpx) | httpx >= 0.18.0 | No
| [opentelemetry-instrumentation-jinja2](./opentelemetry-instrumentation-jinja2) | jinja2 >= 2.7, < 4.0 | No
Expand All @@ -40,5 +40,5 @@
| [opentelemetry-instrumentation-system-metrics](./opentelemetry-instrumentation-system-metrics) | psutil >= 5 | No
| [opentelemetry-instrumentation-tornado](./opentelemetry-instrumentation-tornado) | tornado >= 5.1.1 | No
| [opentelemetry-instrumentation-urllib](./opentelemetry-instrumentation-urllib) | urllib | No
| [opentelemetry-instrumentation-urllib3](./opentelemetry-instrumentation-urllib3) | urllib3 >= 1.0.0, < 2.0.0 | No
| [opentelemetry-instrumentation-urllib3](./opentelemetry-instrumentation-urllib3) | urllib3 >= 1.0.0, < 2.0.0 | Yes
| [opentelemetry-instrumentation-wsgi](./opentelemetry-instrumentation-wsgi) | wsgi | Yes
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ install_requires =
test =
pytest
wrapt >= 1.0.0, < 2.0.0
opentelemetry-test-utils == 0.32b0
opentelemetry-test-utils == 0.33b0

[options.packages.find]
where = src
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.

__version__ = "0.32b0"
__version__ = "0.33b0"
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ package_dir=
=src
packages=find_namespace:
install_requires =
opentelemetry-api ~= 1.3
opentelemetry-semantic-conventions == 0.32b0
opentelemetry-instrumentation == 0.32b0
opentelemetry-util-http == 0.32b0
opentelemetry-api ~= 1.12
opentelemetry-semantic-conventions == 0.33b0
opentelemetry-instrumentation == 0.33b0
opentelemetry-util-http == 0.33b0
wrapt >= 1.0.0, < 2.0.0

[options.packages.find]
Expand All @@ -54,4 +54,4 @@ test =

[options.entry_points]
opentelemetry_instrumentor =
aiohttp-client = opentelemetry.instrumentation.aiohttp_client:AioHttpClientInstrumentor
aiohttp-client = opentelemetry.instrumentation.aiohttp_client:AioHttpClientInstrumentor
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.

__version__ = "0.32b0"
__version__ = "0.33b0"
10 changes: 5 additions & 5 deletions instrumentation/opentelemetry-instrumentation-aiopg/setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@ package_dir=
=src
packages=find_namespace:
install_requires =
opentelemetry-api ~= 1.3
opentelemetry-instrumentation-dbapi == 0.32b0
opentelemetry-instrumentation == 0.32b0
opentelemetry-api ~= 1.12
opentelemetry-instrumentation-dbapi == 0.33b0
opentelemetry-instrumentation == 0.33b0
wrapt >= 1.0.0, < 2.0.0

[options.extras_require]
test =
opentelemetry-test-utils == 0.32b0
opentelemetry-semantic-conventions == 0.32b0
opentelemetry-test-utils == 0.33b0
opentelemetry-semantic-conventions == 0.33b0

[options.packages.find]
where = src
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.

__version__ = "0.32b0"
__version__ = "0.33b0"
10 changes: 5 additions & 5 deletions instrumentation/opentelemetry-instrumentation-asgi/setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@ package_dir=
=src
packages=find_namespace:
install_requires =
opentelemetry-api ~= 1.3
opentelemetry-semantic-conventions == 0.32b0
opentelemetry-instrumentation == 0.32b0
opentelemetry-util-http == 0.32b0
opentelemetry-api ~= 1.12
opentelemetry-semantic-conventions == 0.33b0
opentelemetry-instrumentation == 0.33b0
opentelemetry-util-http == 0.33b0
asgiref ~= 3.0

[options.extras_require]
test =
opentelemetry-test-utils == 0.32b0
opentelemetry-test-utils == 0.33b0

[options.packages.find]
where = src
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ def client_response_hook(span: Span, message: dict):
import typing
import urllib
from functools import wraps
from timeit import default_timer
from typing import Tuple

from asgiref.compatibility import guarantee_single_callable
Expand All @@ -162,13 +163,16 @@ def client_response_hook(span: Span, message: dict):
_start_internal_or_server_span,
http_status_to_status_code,
)
from opentelemetry.metrics import get_meter
from opentelemetry.propagators.textmap import Getter, Setter
from opentelemetry.semconv.trace import SpanAttributes
from opentelemetry.trace import Span, set_span_in_context
from opentelemetry.trace.status import Status, StatusCode
from opentelemetry.util.http import (
OTEL_INSTRUMENTATION_HTTP_CAPTURE_HEADERS_SERVER_REQUEST,
OTEL_INSTRUMENTATION_HTTP_CAPTURE_HEADERS_SERVER_RESPONSE,
_parse_active_request_count_attrs,
_parse_duration_attrs,
get_custom_headers,
normalise_request_header_name,
normalise_response_header_name,
Expand Down Expand Up @@ -391,9 +395,21 @@ def __init__(
client_request_hook: _ClientRequestHookT = None,
client_response_hook: _ClientResponseHookT = None,
tracer_provider=None,
meter_provider=None,
):
self.app = guarantee_single_callable(app)
self.tracer = trace.get_tracer(__name__, __version__, tracer_provider)
self.meter = get_meter(__name__, __version__, meter_provider)
self.duration_histogram = self.meter.create_histogram(
name="http.server.duration",
unit="ms",
description="measures the duration of the inbound HTTP request",
)
self.active_requests_counter = self.meter.create_up_down_counter(
name="http.server.active_requests",
unit="requests",
description="measures the number of concurrent HTTP requests that are currently in-flight",
)
self.excluded_urls = excluded_urls
self.default_span_details = (
default_span_details or get_default_span_details
Expand Down Expand Up @@ -426,12 +442,17 @@ async def __call__(self, scope, receive, send):
context_carrier=scope,
context_getter=asgi_getter,
)

attributes = collect_request_attributes(scope)
attributes.update(additional_attributes)
active_requests_count_attrs = _parse_active_request_count_attrs(
attributes
)
duration_attrs = _parse_duration_attrs(attributes)
if scope["type"] == "http":
self.active_requests_counter.add(1, active_requests_count_attrs)
try:
with trace.use_span(span, end_on_exit=True) as current_span:
if current_span.is_recording():
attributes = collect_request_attributes(scope)
attributes.update(additional_attributes)
for key, value in attributes.items():
current_span.set_attribute(key, value)

Expand All @@ -454,10 +475,18 @@ async def __call__(self, scope, receive, send):
span_name,
scope,
send,
duration_attrs,
)
start = default_timer()

await self.app(scope, otel_receive, otel_send)
finally:
if scope["type"] == "http":
duration = max(round((default_timer() - start) * 1000), 0)
self.duration_histogram.record(duration, duration_attrs)
self.active_requests_counter.add(
-1, active_requests_count_attrs
)
if token:
context.detach(token)

Expand All @@ -478,7 +507,9 @@ async def otel_receive():

return otel_receive

def _get_otel_send(self, server_span, server_span_name, scope, send):
def _get_otel_send(
self, server_span, server_span_name, scope, send, duration_attrs
):
@wraps(send)
async def otel_send(message):
with self.tracer.start_as_current_span(
Expand All @@ -489,6 +520,9 @@ async def otel_send(message):
if send_span.is_recording():
if message["type"] == "http.response.start":
status_code = message["status"]
duration_attrs[
SpanAttributes.HTTP_STATUS_CODE
] = status_code
set_status_code(server_span, status_code)
set_status_code(send_span, status_code)
elif message["type"] == "websocket.send":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.

__version__ = "0.32b0"
__version__ = "0.33b0"
Loading

0 comments on commit 1b9dc9a

Please sign in to comment.