From 36854b8279f8c7db2f716fd3ca3ba8be4e25e94f Mon Sep 17 00:00:00 2001 From: Kayla Reopelle Date: Mon, 19 Aug 2024 15:23:54 -0700 Subject: [PATCH] chore: Add comment, replace view with advice --- .../rack/middlewares/event_handler.rb | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/instrumentation/rack/lib/opentelemetry/instrumentation/rack/middlewares/event_handler.rb b/instrumentation/rack/lib/opentelemetry/instrumentation/rack/middlewares/event_handler.rb index b9b457805..cb64bd6f5 100644 --- a/instrumentation/rack/lib/opentelemetry/instrumentation/rack/middlewares/event_handler.rb +++ b/instrumentation/rack/lib/opentelemetry/instrumentation/rack/middlewares/event_handler.rb @@ -158,6 +158,8 @@ def untraced_request?(env) false end + # TODO: This one is long because I wanted to keep the stable semantic + # conventions, and (for now) emit attributes that matched the span def record_http_server_request_duration_metric(span) return unless metrics_enabled? && http_server_duration_histogram @@ -169,7 +171,7 @@ def record_http_server_request_duration_metric(span) attrs = {} # pattern below goes # stable convention - # current span convention + # attribute that matches rack spans (old convention) # attrs['http.request.method'] attrs['http.method'] = span.attributes['http.method'] @@ -298,14 +300,8 @@ def meter end def http_server_duration_histogram - # only want to make the view and the histogram once - # OpenTelemetry.meter_provider.add_view( - # 'http.server.request.duration', - # aggregation: OpenTelemetry::SDK::Metrics::Aggregation::ExplicitBucketHistogram.new( - # boundaries: [0.005, 0.01, 0.025, 0.05, 0.075, 0.1, 0.25, 0.5, 0.75, 1, 2.5, 5, 7.5, 10] - # ) - # ) - # Meter might be nil if metrics API isn't installed or isn't configured to send data + # Only want to make the histogram once + # Need to implement advice so we can update the buckets to match seconds instead of ms return @http_server_duration_histogram if defined?(@http_server_duration_histogram) @http_server_duration_histogram = nil unless meter