Skip to content

Commit 6a47a17

Browse files
committed
squash: fix
1 parent 6b762fb commit 6a47a17

File tree

28 files changed

+59
-182
lines changed

28 files changed

+59
-182
lines changed

instrumentation/ethon/lib/opentelemetry/instrumentation/ethon/http_helper.rb

Lines changed: 5 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -59,34 +59,16 @@ module HttpHelper
5959

6060
private_constant :METHOD_CACHE, :OLD_SPAN_NAMES
6161

62-
# Prepares all span data for stable semantic conventions in a single call
62+
# Prepares all span data for the specified semantic convention in a single call
6363
# @param method [String, Symbol] The HTTP method
64+
# @param semconv [Symbol] The semantic convention to use (:stable or :old)
6465
# @return [SpanCreationAttributes] struct containing span_name, normalized_method, and original_method
65-
def self.attrs_for_stable(method)
66+
def self.span_attributes(method, semconv: :stable)
6667
normalized = METHOD_CACHE[method]
6768
if normalized
69+
span_name = semconv == :old ? OLD_SPAN_NAMES[normalized] : normalized
6870
SpanCreationAttributes.new(
69-
span_name: normalized,
70-
normalized_method: normalized,
71-
original_method: nil
72-
)
73-
else
74-
SpanCreationAttributes.new(
75-
span_name: 'HTTP',
76-
normalized_method: '_OTHER',
77-
original_method: method.to_s
78-
)
79-
end
80-
end
81-
82-
# Prepares all span data for old semantic conventions in a single call
83-
# @param method [String, Symbol] The HTTP method
84-
# @return [SpanCreationAttributes] struct containing span_name, normalized_method, and original_method
85-
def self.attrs_for_old(method)
86-
normalized = METHOD_CACHE[method]
87-
if normalized
88-
SpanCreationAttributes.new(
89-
span_name: OLD_SPAN_NAMES[normalized],
71+
span_name: span_name,
9072
normalized_method: normalized,
9173
original_method: nil
9274
)

instrumentation/ethon/lib/opentelemetry/instrumentation/ethon/patches/dup/easy.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def reset
6868
end
6969

7070
def otel_before_request
71-
span_data = HttpHelper.attrs_for_stable(@otel_method)
71+
span_data = HttpHelper.span_attributes(@otel_method)
7272

7373
@otel_span = tracer.start_span(
7474
span_data.span_name,

instrumentation/ethon/lib/opentelemetry/instrumentation/ethon/patches/old/easy.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def reset
6767
end
6868

6969
def otel_before_request
70-
span_data = HttpHelper.attrs_for_old(@otel_method)
70+
span_data = HttpHelper.span_attributes(@otel_method, semconv: :old)
7171

7272
@otel_span = tracer.start_span(
7373
span_data.span_name,

instrumentation/ethon/lib/opentelemetry/instrumentation/ethon/patches/stable/easy.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def reset
6767
end
6868

6969
def otel_before_request
70-
span_data = HttpHelper.attrs_for_stable(@otel_method)
70+
span_data = HttpHelper.span_attributes(@otel_method)
7171

7272
@otel_span = tracer.start_span(
7373
span_data.span_name,

instrumentation/excon/lib/opentelemetry/instrumentation/excon/http_helper.rb

Lines changed: 5 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -59,34 +59,16 @@ module HttpHelper
5959

6060
private_constant :METHOD_CACHE, :OLD_SPAN_NAMES
6161

62-
# Prepares all span data for stable semantic conventions in a single call
62+
# Prepares all span data for the specified semantic convention in a single call
6363
# @param method [String, Symbol] The HTTP method
64+
# @param semconv [Symbol] The semantic convention to use (:stable or :old)
6465
# @return [SpanCreationAttributes] struct containing span_name, normalized_method, and original_method
65-
def self.attrs_for_stable(method)
66+
def self.span_attributes(method, semconv: :stable)
6667
normalized = METHOD_CACHE[method]
6768
if normalized
69+
span_name = semconv == :old ? OLD_SPAN_NAMES[normalized] : normalized
6870
SpanCreationAttributes.new(
69-
span_name: normalized,
70-
normalized_method: normalized,
71-
original_method: nil
72-
)
73-
else
74-
SpanCreationAttributes.new(
75-
span_name: 'HTTP',
76-
normalized_method: '_OTHER',
77-
original_method: method.to_s
78-
)
79-
end
80-
end
81-
82-
# Prepares all span data for old semantic conventions in a single call
83-
# @param method [String, Symbol] The HTTP method
84-
# @return [SpanCreationAttributes] struct containing span_name, normalized_method, and original_method
85-
def self.attrs_for_old(method)
86-
normalized = METHOD_CACHE[method]
87-
if normalized
88-
SpanCreationAttributes.new(
89-
span_name: OLD_SPAN_NAMES[normalized],
71+
span_name: span_name,
9072
normalized_method: normalized,
9173
original_method: nil
9274
)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class TracerMiddleware < ::Excon::Middleware::Base
1717
def request_call(datum)
1818
return @stack.request_call(datum) if untraced?(datum)
1919

20-
span_data = HttpHelper.attrs_for_stable(datum[:method])
20+
span_data = HttpHelper.span_attributes(datum[:method])
2121

2222
cleansed_url = OpenTelemetry::Common::Utilities.cleanse_url(::Excon::Utils.request_uri(datum))
2323
attributes = {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class TracerMiddleware < ::Excon::Middleware::Base
1717
def request_call(datum)
1818
return @stack.request_call(datum) if untraced?(datum)
1919

20-
span_data = HttpHelper.attrs_for_old(datum[:method])
20+
span_data = HttpHelper.span_attributes(datum[:method], semconv: :old)
2121

2222
attributes = {
2323
OpenTelemetry::SemanticConventions::Trace::HTTP_HOST => datum[:host],

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class TracerMiddleware < ::Excon::Middleware::Base
1717
def request_call(datum)
1818
return @stack.request_call(datum) if untraced?(datum)
1919

20-
span_data = HttpHelper.attrs_for_stable(datum[:method])
20+
span_data = HttpHelper.span_attributes(datum[:method])
2121

2222
attributes = {
2323
'http.request.method' => span_data.normalized_method,

instrumentation/faraday/lib/opentelemetry/instrumentation/faraday/http_helper.rb

Lines changed: 5 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -61,34 +61,16 @@ module HttpHelper
6161

6262
module_function
6363

64-
# Prepares all span data for stable semantic conventions in a single call
64+
# Prepares all span data for the specified semantic convention in a single call
6565
# @param method [String, Symbol] The HTTP method
66+
# @param semconv [Symbol] The semantic convention to use (:stable or :old)
6667
# @return [SpanCreationAttributes] struct containing span_name, normalized_method, and original_method
67-
def attrs_for_stable(method)
68+
module_function def span_attributes(method, semconv: :stable)
6869
normalized = METHOD_CACHE[method]
6970
if normalized
71+
span_name = semconv == :old ? OLD_SPAN_NAMES[normalized] : normalized
7072
SpanCreationAttributes.new(
71-
span_name: normalized,
72-
normalized_method: normalized,
73-
original_method: nil
74-
)
75-
else
76-
SpanCreationAttributes.new(
77-
span_name: 'HTTP',
78-
normalized_method: '_OTHER',
79-
original_method: method.to_s
80-
)
81-
end
82-
end
83-
84-
# Prepares all span data for old semantic conventions in a single call
85-
# @param method [String, Symbol] The HTTP method
86-
# @return [SpanCreationAttributes] struct containing span_name, normalized_method, and original_method
87-
def attrs_for_old(method)
88-
normalized = METHOD_CACHE[method]
89-
if normalized
90-
SpanCreationAttributes.new(
91-
span_name: OLD_SPAN_NAMES[normalized],
73+
span_name: span_name,
9274
normalized_method: normalized,
9375
original_method: nil
9476
)

instrumentation/faraday/lib/opentelemetry/instrumentation/faraday/middlewares/dup/tracer_middleware.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class TracerMiddleware < ::Faraday::Middleware
1616
HTTP_STATUS_SUCCESS_RANGE = (100..399)
1717

1818
def call(env)
19-
span_data = HttpHelper.attrs_for_stable(env.method)
19+
span_data = HttpHelper.span_attributes(env.method)
2020

2121
config = Faraday::Instrumentation.instance.config
2222

0 commit comments

Comments
 (0)