Skip to content

Commit 1953d97

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

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
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-urllib`: proper bucket boundaries in stable semconv http duration metrics
19+
([#3519](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3519))
1820
- `opentelemetry-instrumentation-falcon`: proper bucket boundaries in stable semconv http duration
1921
([#3525](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3525))
2022
- `opentelemetry-instrumentation-wsgi`: add explicit http duration buckets for stable semconv

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ def response_hook(span: Span, request: Request, response: HTTPResponse):
9595
)
9696

9797
from opentelemetry.instrumentation._semconv import (
98+
HTTP_DURATION_HISTOGRAM_BUCKETS_NEW,
9899
_client_duration_attrs_new,
99100
_client_duration_attrs_old,
100101
_filter_semconv_duration_attrs,
@@ -434,6 +435,7 @@ def _create_client_histograms(
434435
name=HTTP_CLIENT_REQUEST_DURATION,
435436
unit="s",
436437
description="Duration of HTTP client requests.",
438+
explicit_bucket_boundaries_advisory=HTTP_DURATION_HISTOGRAM_BUCKETS_NEW,
437439
)
438440
histograms[HTTP_CLIENT_REQUEST_BODY_SIZE] = (
439441
create_http_client_request_body_size(meter)

instrumentation/opentelemetry-instrumentation-urllib/tests/test_metrics_instrumentation.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
from pytest import mark
2424

2525
from opentelemetry.instrumentation._semconv import (
26+
HTTP_DURATION_HISTOGRAM_BUCKETS_NEW,
2627
OTEL_SEMCONV_STABILITY_OPT_IN,
2728
_OpenTelemetrySemanticConventionStability,
2829
)
@@ -76,10 +77,17 @@ def tearDown(self):
7677
httpretty.disable()
7778

7879
# Return Sequence with one histogram
79-
def create_histogram_data_points(self, sum_data_point, attributes):
80+
def create_histogram_data_points(
81+
self, sum_data_point, attributes, explicit_bounds=None
82+
):
8083
return [
8184
self.create_histogram_data_point(
82-
sum_data_point, 1, sum_data_point, sum_data_point, attributes
85+
sum_data_point,
86+
1,
87+
sum_data_point,
88+
sum_data_point,
89+
attributes,
90+
explicit_bounds=explicit_bounds,
8391
)
8492
]
8593

@@ -176,6 +184,7 @@ def test_basic_metric_new_semconv(self):
176184
"http.request.method": "GET",
177185
"network.protocol.version": "1.1",
178186
},
187+
explicit_bounds=HTTP_DURATION_HISTOGRAM_BUCKETS_NEW,
179188
),
180189
est_value_delta=40,
181190
)
@@ -295,6 +304,7 @@ def test_basic_metric_both_semconv(self):
295304
"http.request.method": "GET",
296305
"network.protocol.version": "1.1",
297306
},
307+
explicit_bounds=HTTP_DURATION_HISTOGRAM_BUCKETS_NEW,
298308
),
299309
est_value_delta=40,
300310
)

0 commit comments

Comments
 (0)