Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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-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
([#3524](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3524))
- `opentelemetry-instrumentation-grpc`: support non-list interceptors
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ def response_hook(span: Span, status: str, response_headers: List):
import opentelemetry.instrumentation.wsgi as otel_wsgi
from opentelemetry import context, trace
from opentelemetry.instrumentation._semconv import (
HTTP_DURATION_HISTOGRAM_BUCKETS_NEW,
_get_schema_url,
_OpenTelemetrySemanticConventionStability,
_OpenTelemetryStabilitySignalType,
Expand Down Expand Up @@ -583,6 +584,7 @@ def __init__(self, *args, **kwargs):
name=HTTP_SERVER_REQUEST_DURATION,
unit="s",
description="Duration of HTTP server requests.",
explicit_bucket_boundaries_advisory=HTTP_DURATION_HISTOGRAM_BUCKETS_NEW,
)
active_requests_counter = meter.create_up_down_counter(
name=MetricInstruments.HTTP_SERVER_ACTIVE_REQUESTS,
Expand Down Expand Up @@ -716,6 +718,7 @@ def instrument_app(
name=HTTP_SERVER_REQUEST_DURATION,
unit="s",
description="Duration of HTTP server requests.",
explicit_bucket_boundaries_advisory=HTTP_DURATION_HISTOGRAM_BUCKETS_NEW,
)
active_requests_counter = meter.create_up_down_counter(
name=MetricInstruments.HTTP_SERVER_ACTIVE_REQUESTS,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

from opentelemetry import trace
from opentelemetry.instrumentation._semconv import (
HTTP_DURATION_HISTOGRAM_BUCKETS_NEW,
OTEL_SEMCONV_STABILITY_OPT_IN,
_OpenTelemetrySemanticConventionStability,
_server_active_requests_count_attrs_new,
Expand Down Expand Up @@ -522,6 +523,10 @@ def test_flask_metrics_new_semconv(self):
self.assertAlmostEqual(
duration_s, point.sum, places=1
)
self.assertEqual(
point.explicit_bounds,
HTTP_DURATION_HISTOGRAM_BUCKETS_NEW,
)
histogram_data_point_seen = True
if isinstance(point, NumberDataPoint):
number_data_point_seen = True
Expand Down Expand Up @@ -552,8 +557,12 @@ def test_flask_metric_values(self):
self.assertEqual(point.value, 0)

def _assert_basic_metric(
self, expected_duration_attributes, expected_requests_count_attributes
self,
expected_duration_attributes,
expected_requests_count_attributes,
expected_histogram_explicit_bounds=None,
):
# pylint: disable=too-many-nested-blocks
metrics_list = self.memory_metrics_reader.get_metrics_data()
for resource_metric in metrics_list.resource_metrics:
for scope_metrics in resource_metric.scope_metrics:
Expand All @@ -564,6 +573,11 @@ def _assert_basic_metric(
expected_duration_attributes,
dict(point.attributes),
)
if expected_histogram_explicit_bounds is not None:
self.assertEqual(
expected_histogram_explicit_bounds,
point.explicit_bounds,
)
self.assertEqual(point.count, 1)
elif isinstance(point, NumberDataPoint):
self.assertDictEqual(
Expand Down Expand Up @@ -613,6 +627,7 @@ def test_basic_metric_success_new_semconv(self):
self._assert_basic_metric(
expected_duration_attributes,
expected_requests_count_attributes,
expected_histogram_explicit_bounds=HTTP_DURATION_HISTOGRAM_BUCKETS_NEW,
)

def test_basic_metric_nonstandard_http_method_success(self):
Expand Down Expand Up @@ -654,6 +669,7 @@ def test_basic_metric_nonstandard_http_method_success_new_semconv(self):
self._assert_basic_metric(
expected_duration_attributes,
expected_requests_count_attributes,
expected_histogram_explicit_bounds=HTTP_DURATION_HISTOGRAM_BUCKETS_NEW,
)

@patch.dict(
Expand All @@ -679,6 +695,7 @@ def test_basic_metric_nonstandard_http_method_allowed_success_new_semconv(
self._assert_basic_metric(
expected_duration_attributes,
expected_requests_count_attributes,
expected_histogram_explicit_bounds=HTTP_DURATION_HISTOGRAM_BUCKETS_NEW,
)

def test_metric_uninstrument(self):
Expand Down