Skip to content

Commit a3a6efa

Browse files
committed
[Excon] Reduce memory allocation for span names
1 parent 3af247f commit a3a6efa

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

instrumentation/excon/lib/opentelemetry/instrumentation/excon/middlewares/tracer_middleware.rb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,16 @@ module Excon
1010
module Middlewares
1111
# Excon middleware for instrumentation
1212
class TracerMiddleware < ::Excon::Middleware::Base
13+
HTTP_METHODS_TO_UPPERCASE = Hash.new { |hash, key| hash[key] = key.to_s.upcase }
14+
HTTP_METHODS_TO_SPAN_NAMES = Hash.new { |hash, key| hash[key] = "HTTP #{key}" }
15+
1316
def request_call(datum)
1417
begin
1518
unless datum.key?(:otel_span)
16-
http_method = datum[:method].to_s.upcase
19+
http_method = HTTP_METHODS_TO_UPPERCASE[datum[:method]]
1720
attributes = span_creation_attributes(datum, http_method)
1821
tracer.start_span(
19-
"HTTP #{http_method}",
22+
HTTP_METHODS_TO_SPAN_NAMES[http_method],
2023
attributes: attributes,
2124
kind: :client
2225
).tap do |span|

0 commit comments

Comments
 (0)