Skip to content

Commit f65339f

Browse files
committed
squash: move method
1 parent 43cc87f commit f65339f

File tree

14 files changed

+52
-37
lines changed

14 files changed

+52
-37
lines changed

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,16 +50,19 @@ module HttpHelper
5050
# @param method [String, Symbol] The HTTP method
5151
# @return [SpanCreationAttributes] struct containing span_name, normalized_method, and original_method
5252
def self.span_attrs_for(method)
53+
url_template = OpenTelemetry::Common::HTTP::ClientContext.attributes['url.template']
5354
normalized = METHOD_CACHE[method]
5455
if normalized
56+
span_name = url_template ? "#{normalized} #{url_template}" : normalized
5557
SpanCreationAttributes.new(
56-
span_name: normalized,
58+
span_name: span_name,
5759
normalized_method: normalized,
5860
original_method: nil
5961
)
6062
else
63+
span_name = url_template ? "HTTP #{url_template}" : 'HTTP'
6164
SpanCreationAttributes.new(
62-
span_name: 'HTTP',
65+
span_name: span_name,
6366
normalized_method: '_OTHER',
6467
original_method: method.to_s
6568
)

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

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def otel_before_request
7272

7373
@otel_span = tracer.start_span(
7474
span_data.span_name,
75-
attributes: span_creation_attributes(span_data),
75+
attributes: span_creation_attributes(span_data, client_context_attrs),
7676
kind: :client
7777
)
7878

@@ -89,7 +89,7 @@ def otel_span_started?
8989

9090
private
9191

92-
def span_creation_attributes(span_data)
92+
def span_creation_attributes(span_data, client_context_attrs)
9393
instrumentation_attrs = {
9494
'http.method' => span_data.normalized_method,
9595
'http.request.method' => span_data.normalized_method
@@ -106,9 +106,7 @@ def span_creation_attributes(span_data)
106106

107107
config = Ethon::Instrumentation.instance.config
108108
instrumentation_attrs['peer.service'] = config[:peer_service] if config[:peer_service]
109-
instrumentation_attrs.merge!(
110-
OpenTelemetry::Common::HTTP::ClientContext.attributes
111-
)
109+
instrumentation_attrs.merge!(OpenTelemetry::Common::HTTP::ClientContext.attributes)
112110
end
113111

114112
# Returns a URL string with userinfo removed.

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

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def otel_before_request
7171

7272
@otel_span = tracer.start_span(
7373
span_data.span_name,
74-
attributes: span_creation_attributes(span_data),
74+
attributes: span_creation_attributes(span_data, client_context_attrs),
7575
kind: :client
7676
)
7777

@@ -88,7 +88,7 @@ def otel_span_started?
8888

8989
private
9090

91-
def span_creation_attributes(span_data)
91+
def span_creation_attributes(span_data, client_context_attrs)
9292
instrumentation_attrs = {
9393
'http.method' => span_data.normalized_method
9494
}
@@ -101,9 +101,7 @@ def span_creation_attributes(span_data)
101101

102102
config = Ethon::Instrumentation.instance.config
103103
instrumentation_attrs['peer.service'] = config[:peer_service] if config[:peer_service]
104-
instrumentation_attrs.merge!(
105-
OpenTelemetry::Common::HTTP::ClientContext.attributes
106-
)
104+
instrumentation_attrs.merge!(OpenTelemetry::Common::HTTP::ClientContext.attributes)
107105
end
108106

109107
# Returns a URL string with userinfo removed.

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

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def otel_before_request
7171

7272
@otel_span = tracer.start_span(
7373
span_data.span_name,
74-
attributes: span_creation_attributes(span_data),
74+
attributes: span_creation_attributes(span_data, client_context_attrs),
7575
kind: :client
7676
)
7777

@@ -88,7 +88,7 @@ def otel_span_started?
8888

8989
private
9090

91-
def span_creation_attributes(span_data)
91+
def span_creation_attributes(span_data, client_context_attrs)
9292
instrumentation_attrs = {
9393
'http.request.method' => span_data.normalized_method
9494
}
@@ -102,9 +102,7 @@ def span_creation_attributes(span_data)
102102

103103
config = Ethon::Instrumentation.instance.config
104104
instrumentation_attrs['peer.service'] = config[:peer_service] if config[:peer_service]
105-
instrumentation_attrs.merge!(
106-
OpenTelemetry::Common::HTTP::ClientContext.attributes
107-
)
105+
instrumentation_attrs.merge!(OpenTelemetry::Common::HTTP::ClientContext.attributes)
108106
end
109107

110108
# Returns a URL string with userinfo removed.

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,16 +50,19 @@ module HttpHelper
5050
# @param method [String, Symbol] The HTTP method
5151
# @return [SpanCreationAttributes] struct containing span_name, normalized_method, and original_method
5252
def self.span_attrs_for(method)
53+
url_template = OpenTelemetry::Common::HTTP::ClientContext.attributes['url.template']
5354
normalized = METHOD_CACHE[method]
5455
if normalized
56+
span_name = url_template ? "#{normalized} #{url_template}" : normalized
5557
SpanCreationAttributes.new(
56-
span_name: normalized,
58+
span_name: span_name,
5759
normalized_method: normalized,
5860
original_method: nil
5961
)
6062
else
63+
span_name = url_template ? "HTTP #{url_template}" : 'HTTP'
6164
SpanCreationAttributes.new(
62-
span_name: 'HTTP',
65+
span_name: span_name,
6366
normalized_method: '_OTHER',
6467
original_method: method.to_s
6568
)

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,16 +52,19 @@ module HttpHelper
5252
# @param method [String, Symbol] The HTTP method
5353
# @return [SpanCreationAttributes] struct containing span_name, normalized_method, and original_method
5454
def span_attrs_for(method)
55+
url_template = OpenTelemetry::Common::HTTP::ClientContext.attributes['url.template']
5556
normalized = METHOD_CACHE[method]
5657
if normalized
58+
span_name = url_template ? "#{normalized} #{url_template}" : normalized
5759
SpanCreationAttributes.new(
58-
span_name: normalized,
60+
span_name: span_name,
5961
normalized_method: normalized,
6062
original_method: nil
6163
)
6264
else
65+
span_name = url_template ? "HTTP #{url_template}" : 'HTTP'
6366
SpanCreationAttributes.new(
64-
span_name: 'HTTP',
67+
span_name: span_name,
6568
normalized_method: '_OTHER',
6669
original_method: method.to_s
6770
)

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ def call(env)
2424
http_method: span_data.normalized_method,
2525
original_method: span_data.original_method,
2626
url: env.url,
27-
config: config
27+
config: config,
28+
client_context_attrs: client_context_attrs
2829
)
2930

3031
OpenTelemetry::Common::HTTP::ClientContext.with_attributes(attributes) do |attrs, _|
@@ -66,9 +67,7 @@ def span_creation_attributes(http_method:, original_method:, url:, config:)
6667
end
6768
attrs['peer.service'] = config[:peer_service] if config[:peer_service]
6869

69-
attrs.merge!(
70-
OpenTelemetry::Common::HTTP::ClientContext.attributes
71-
)
70+
attrs.merge!(OpenTelemetry::Common::HTTP::ClientContext.attributes)
7271
end
7372

7473
# Versions prior to 1.0 do not define an accessor for app

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ def call(env)
2424
http_method: span_data.normalized_method,
2525
original_method: span_data.original_method,
2626
url: env.url,
27-
config: config
27+
config: config,
28+
client_context_attrs: client_context_attrs
2829
)
2930

3031
OpenTelemetry::Common::HTTP::ClientContext.with_attributes(attributes) do |attrs, _|
@@ -60,9 +61,7 @@ def span_creation_attributes(http_method:, original_method:, url:, config:)
6061
attrs['server.address'] = url.host if url.host
6162
attrs['peer.service'] = config[:peer_service] if config[:peer_service]
6263

63-
attrs.merge!(
64-
OpenTelemetry::Common::HTTP::ClientContext.attributes
65-
)
64+
attrs.merge!(OpenTelemetry::Common::HTTP::ClientContext.attributes)
6665
end
6766

6867
# Versions prior to 1.0 do not define an accessor for app

instrumentation/http/lib/opentelemetry/instrumentation/http/http_helper.rb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,16 +50,19 @@ module HttpHelper
5050
# @param method [String, Symbol] The HTTP method
5151
# @return [SpanCreationAttributes] struct containing span_name, normalized_method, and original_method
5252
def self.span_attrs_for(method)
53+
url_template = OpenTelemetry::Common::HTTP::ClientContext.attributes['url.template']
5354
normalized = METHOD_CACHE[method]
5455
if normalized
56+
span_name = url_template ? "#{normalized} #{url_template}" : normalized
5557
SpanCreationAttributes.new(
56-
span_name: normalized,
58+
span_name: span_name,
5759
normalized_method: normalized,
5860
original_method: nil
5961
)
6062
else
63+
span_name = url_template ? "HTTP #{url_template}" : 'HTTP'
6164
SpanCreationAttributes.new(
62-
span_name: 'HTTP',
65+
span_name: span_name,
6366
normalized_method: '_OTHER',
6467
original_method: method.to_s
6568
)

instrumentation/http_client/lib/opentelemetry/instrumentation/http_client/http_helper.rb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,16 +50,19 @@ module HttpHelper
5050
# @param method [String, Symbol] The HTTP method
5151
# @return [SpanCreationAttributes] struct containing span_name, normalized_method, and original_method
5252
def self.span_attrs_for(method)
53+
url_template = OpenTelemetry::Common::HTTP::ClientContext.attributes['url.template']
5354
normalized = METHOD_CACHE[method]
5455
if normalized
56+
span_name = url_template ? "#{normalized} #{url_template}" : normalized
5557
SpanCreationAttributes.new(
56-
span_name: normalized,
58+
span_name: span_name,
5759
normalized_method: normalized,
5860
original_method: nil
5961
)
6062
else
63+
span_name = url_template ? "HTTP #{url_template}" : 'HTTP'
6164
SpanCreationAttributes.new(
62-
span_name: 'HTTP',
65+
span_name: span_name,
6366
normalized_method: '_OTHER',
6467
original_method: method.to_s
6568
)

0 commit comments

Comments
 (0)