From a4ba77de854fd89ba0b60da1b73894c7535b04bb Mon Sep 17 00:00:00 2001 From: Riccardo Magliocchetti Date: Wed, 21 May 2025 11:55:48 +0200 Subject: [PATCH 1/3] opentelemetry-instrumentation-urllib3: add explicit http duration buckets for stable semconv --- .../src/opentelemetry/instrumentation/urllib3/__init__.py | 2 ++ .../tests/test_urllib3_metrics.py | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/instrumentation/opentelemetry-instrumentation-urllib3/src/opentelemetry/instrumentation/urllib3/__init__.py b/instrumentation/opentelemetry-instrumentation-urllib3/src/opentelemetry/instrumentation/urllib3/__init__.py index 551c67f700..4fae08ee24 100644 --- a/instrumentation/opentelemetry-instrumentation-urllib3/src/opentelemetry/instrumentation/urllib3/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-urllib3/src/opentelemetry/instrumentation/urllib3/__init__.py @@ -103,6 +103,7 @@ def response_hook( import wrapt from opentelemetry.instrumentation._semconv import ( + HTTP_DURATION_HISTOGRAM_BUCKETS_NEW, _client_duration_attrs_new, _client_duration_attrs_old, _filter_semconv_duration_attrs, @@ -267,6 +268,7 @@ def _instrument(self, **kwargs): name=HTTP_CLIENT_REQUEST_DURATION, unit="s", description="Duration of HTTP client requests.", + explicit_bucket_boundaries_advisory=HTTP_DURATION_HISTOGRAM_BUCKETS_NEW, ) # http.client.request.body.size histogram request_size_histogram_new = create_http_client_request_body_size( diff --git a/instrumentation/opentelemetry-instrumentation-urllib3/tests/test_urllib3_metrics.py b/instrumentation/opentelemetry-instrumentation-urllib3/tests/test_urllib3_metrics.py index 959f793398..7672b65230 100644 --- a/instrumentation/opentelemetry-instrumentation-urllib3/tests/test_urllib3_metrics.py +++ b/instrumentation/opentelemetry-instrumentation-urllib3/tests/test_urllib3_metrics.py @@ -22,6 +22,7 @@ from urllib3 import encode_multipart_formdata from opentelemetry.instrumentation._semconv import ( + HTTP_DURATION_HISTOGRAM_BUCKETS_NEW, OTEL_SEMCONV_STABILITY_OPT_IN, _OpenTelemetrySemanticConventionStability, ) @@ -169,6 +170,7 @@ def test_basic_metrics_new_semconv(self): max_data_point=duration_s, min_data_point=duration_s, attributes=attrs_new, + explicit_bounds=HTTP_DURATION_HISTOGRAM_BUCKETS_NEW, ) ], est_value_delta=40 / 1000, @@ -258,6 +260,7 @@ def test_basic_metrics_both_semconv(self): max_data_point=duration_s, min_data_point=duration_s, attributes=attrs_new, + explicit_bounds=HTTP_DURATION_HISTOGRAM_BUCKETS_NEW, ) ], est_value_delta=40 / 1000, @@ -451,6 +454,7 @@ def test_basic_metrics_nonstandard_http_method_new_semconv(self): max_data_point=duration_s, min_data_point=duration_s, attributes=attrs_new, + explicit_bounds=HTTP_DURATION_HISTOGRAM_BUCKETS_NEW, ) ], est_value_delta=40 / 1000, From 9b0c869f0de26ef7f68b91759ab6533d05448dce Mon Sep 17 00:00:00 2001 From: Riccardo Magliocchetti Date: Wed, 21 May 2025 12:00:09 +0200 Subject: [PATCH 2/3] Add Changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6ecdc6d396..6c2452646a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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-urllib3` Proper bucket boundaries in stable semconv http duration metrics + ([#3518](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3518)) ### Breaking changes From c2232fc8cf6ada84e30af7af1fd88ecc4329aa1f Mon Sep 17 00:00:00 2001 From: Riccardo Magliocchetti Date: Wed, 21 May 2025 15:24:11 +0200 Subject: [PATCH 3/3] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6c2452646a..47b5e75ec1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,7 +15,7 @@ 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-urllib3` Proper bucket boundaries in stable semconv http duration metrics +- `opentelemetry-instrumentation-urllib3`: proper bucket boundaries in stable semconv http duration metrics ([#3518](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3518)) ### Breaking changes