opentelemetry-instrumentation-asgi: add explicit http duration buckets for stable semconv (#3526)
* opentelemetry-instrumentation-asgi: add explicit http duration buckets for stable semconv * Please pylint
This commit is contained in:
parent
680f197515
commit
5e4b55812a
|
|
@ -15,6 +15,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
|
||||
- `opentelemetry-instrumentation-fastapi`: fix wrapping of middlewares
|
||||
([#3012](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3012))
|
||||
- `opentelemetry-instrumentation-asgi`: add explicit http duration buckets for stable semconv
|
||||
([#3526](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3526))
|
||||
- `opentelemetry-instrumentation-flask`: proper bucket boundaries in stable semconv http duration
|
||||
([#3523](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3523))
|
||||
- `opentelemetry-instrumentation-django`: proper bucket boundaries in stable semconv http duration
|
||||
|
|
|
|||
|
|
@ -202,6 +202,7 @@ from asgiref.compatibility import guarantee_single_callable
|
|||
|
||||
from opentelemetry import context, trace
|
||||
from opentelemetry.instrumentation._semconv import (
|
||||
HTTP_DURATION_HISTOGRAM_BUCKETS_NEW,
|
||||
_filter_semconv_active_request_count_attr,
|
||||
_filter_semconv_duration_attrs,
|
||||
_get_schema_url,
|
||||
|
|
@ -589,6 +590,7 @@ class OpenTelemetryMiddleware:
|
|||
name=HTTP_SERVER_REQUEST_DURATION,
|
||||
description="Duration of HTTP server requests.",
|
||||
unit="s",
|
||||
explicit_bucket_boundaries_advisory=HTTP_DURATION_HISTOGRAM_BUCKETS_NEW,
|
||||
)
|
||||
self.server_response_size_histogram = None
|
||||
if _report_old(sem_conv_opt_in_mode):
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ from unittest import mock
|
|||
import opentelemetry.instrumentation.asgi as otel_asgi
|
||||
from opentelemetry import trace as trace_api
|
||||
from opentelemetry.instrumentation._semconv import (
|
||||
HTTP_DURATION_HISTOGRAM_BUCKETS_NEW,
|
||||
OTEL_SEMCONV_STABILITY_OPT_IN,
|
||||
_OpenTelemetrySemanticConventionStability,
|
||||
_server_active_requests_count_attrs_new,
|
||||
|
|
@ -1245,6 +1246,7 @@ class TestAsgiApplication(AsyncAsgiTestBase):
|
|||
self.assertTrue(number_data_point_seen and histogram_data_point_seen)
|
||||
|
||||
async def test_asgi_metrics_new_semconv(self):
|
||||
# pylint: disable=too-many-nested-blocks
|
||||
app = otel_asgi.OpenTelemetryMiddleware(simple_asgi)
|
||||
self.seed_app(app)
|
||||
await self.send_default_request()
|
||||
|
|
@ -1274,6 +1276,11 @@ class TestAsgiApplication(AsyncAsgiTestBase):
|
|||
for point in data_points:
|
||||
if isinstance(point, HistogramDataPoint):
|
||||
self.assertEqual(point.count, 3)
|
||||
if metric.name == "http.server.request.duration":
|
||||
self.assertEqual(
|
||||
point.explicit_bounds,
|
||||
HTTP_DURATION_HISTOGRAM_BUCKETS_NEW,
|
||||
)
|
||||
histogram_data_point_seen = True
|
||||
if isinstance(point, NumberDataPoint):
|
||||
number_data_point_seen = True
|
||||
|
|
@ -1284,6 +1291,7 @@ class TestAsgiApplication(AsyncAsgiTestBase):
|
|||
self.assertTrue(number_data_point_seen and histogram_data_point_seen)
|
||||
|
||||
async def test_asgi_metrics_both_semconv(self):
|
||||
# pylint: disable=too-many-nested-blocks
|
||||
app = otel_asgi.OpenTelemetryMiddleware(simple_asgi)
|
||||
self.seed_app(app)
|
||||
await self.send_default_request()
|
||||
|
|
@ -1313,6 +1321,11 @@ class TestAsgiApplication(AsyncAsgiTestBase):
|
|||
for point in data_points:
|
||||
if isinstance(point, HistogramDataPoint):
|
||||
self.assertEqual(point.count, 3)
|
||||
if metric.name == "http.server.request.duration":
|
||||
self.assertEqual(
|
||||
point.explicit_bounds,
|
||||
HTTP_DURATION_HISTOGRAM_BUCKETS_NEW,
|
||||
)
|
||||
histogram_data_point_seen = True
|
||||
if isinstance(point, NumberDataPoint):
|
||||
number_data_point_seen = True
|
||||
|
|
|
|||
Loading…
Reference in New Issue