Skip to content

Commit

Permalink
perf: Use reverse_each whenever possible
Browse files Browse the repository at this point in the history
  • Loading branch information
arielvalentin authored Dec 23, 2023
1 parent 19f7492 commit 2785b53
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 2785b53

Please sign in to comment.