Skip to content

Commit 9335366

Browse files
xrmxemdneto
andauthored
opentelemetry-instrumentation-urllib3: add explicit http duration buckets for stable semconv (#3518)
* opentelemetry-instrumentation-urllib3: add explicit http duration buckets for stable semconv * Add Changelog * Update CHANGELOG.md --------- Co-authored-by: Emídio Neto <[email protected]>
1 parent 1953d97 commit 9335366

File tree

3 files changed

+8
-0
lines changed

3 files changed

+8
-0
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1515

1616
- `opentelemetry-instrumentation-fastapi`: fix wrapping of middlewares
1717
([#3012](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3012))
18+
- `opentelemetry-instrumentation-urllib3`: proper bucket boundaries in stable semconv http duration metrics
19+
([#3518](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3518))
1820
- `opentelemetry-instrumentation-urllib`: proper bucket boundaries in stable semconv http duration metrics
1921
([#3519](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3519))
2022
- `opentelemetry-instrumentation-falcon`: proper bucket boundaries in stable semconv http duration

instrumentation/opentelemetry-instrumentation-urllib3/src/opentelemetry/instrumentation/urllib3/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ def response_hook(
103103
import wrapt
104104

105105
from opentelemetry.instrumentation._semconv import (
106+
HTTP_DURATION_HISTOGRAM_BUCKETS_NEW,
106107
_client_duration_attrs_new,
107108
_client_duration_attrs_old,
108109
_filter_semconv_duration_attrs,
@@ -267,6 +268,7 @@ def _instrument(self, **kwargs):
267268
name=HTTP_CLIENT_REQUEST_DURATION,
268269
unit="s",
269270
description="Duration of HTTP client requests.",
271+
explicit_bucket_boundaries_advisory=HTTP_DURATION_HISTOGRAM_BUCKETS_NEW,
270272
)
271273
# http.client.request.body.size histogram
272274
request_size_histogram_new = create_http_client_request_body_size(

instrumentation/opentelemetry-instrumentation-urllib3/tests/test_urllib3_metrics.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
from urllib3 import encode_multipart_formdata
2323

2424
from opentelemetry.instrumentation._semconv import (
25+
HTTP_DURATION_HISTOGRAM_BUCKETS_NEW,
2526
OTEL_SEMCONV_STABILITY_OPT_IN,
2627
_OpenTelemetrySemanticConventionStability,
2728
)
@@ -169,6 +170,7 @@ def test_basic_metrics_new_semconv(self):
169170
max_data_point=duration_s,
170171
min_data_point=duration_s,
171172
attributes=attrs_new,
173+
explicit_bounds=HTTP_DURATION_HISTOGRAM_BUCKETS_NEW,
172174
)
173175
],
174176
est_value_delta=40 / 1000,
@@ -258,6 +260,7 @@ def test_basic_metrics_both_semconv(self):
258260
max_data_point=duration_s,
259261
min_data_point=duration_s,
260262
attributes=attrs_new,
263+
explicit_bounds=HTTP_DURATION_HISTOGRAM_BUCKETS_NEW,
261264
)
262265
],
263266
est_value_delta=40 / 1000,
@@ -451,6 +454,7 @@ def test_basic_metrics_nonstandard_http_method_new_semconv(self):
451454
max_data_point=duration_s,
452455
min_data_point=duration_s,
453456
attributes=attrs_new,
457+
explicit_bounds=HTTP_DURATION_HISTOGRAM_BUCKETS_NEW,
454458
)
455459
],
456460
est_value_delta=40 / 1000,

0 commit comments

Comments
 (0)