From 2785b53803e6a0812b3d939a617a5c8adf3c7127 Mon Sep 17 00:00:00 2001 From: Ariel Valentin Date: Sat, 23 Dec 2023 17:14:50 +0000 Subject: [PATCH] perf: Use reverse_each whenever possible --- .../instrumentation/active_job/handlers/default.rb | 2 +- .../instrumentation/rack/middlewares/event_handler.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/instrumentation/active_job/lib/opentelemetry/instrumentation/active_job/handlers/default.rb b/instrumentation/active_job/lib/opentelemetry/instrumentation/active_job/handlers/default.rb index 3c6b6aa7d..9a5db43b5 100644 --- a/instrumentation/active_job/lib/opentelemetry/instrumentation/active_job/handlers/default.rb +++ b/instrumentation/active_job/lib/opentelemetry/instrumentation/active_job/handlers/default.rb @@ -80,7 +80,7 @@ def finish_span(span, tokens) end # pops the context stack - tokens&.reverse&.each do |token| + tokens&.reverse_each do |token| OpenTelemetry::Context.detach(token) rescue StandardError => e OpenTelemetry.handle_error(exception: e) 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 74bdb9005..338bd95dd 100644 --- a/instrumentation/rack/lib/opentelemetry/instrumentation/rack/middlewares/event_handler.rb +++ b/instrumentation/rack/lib/opentelemetry/instrumentation/rack/middlewares/event_handler.rb @@ -192,7 +192,7 @@ def request_span_attributes(env) end def detach_contexts(request) - request.env[TOKENS_KEY]&.reverse&.each do |token| + request.env[TOKENS_KEY]&.reverse_each do |token| OpenTelemetry::Context.detach(token) OpenTelemetry::Trace.current_span.finish end