Skip to content

Commit bb4ce0b

Browse files
committed
squash: fixes
1 parent 98511c4 commit bb4ce0b

File tree

9 files changed

+36
-44
lines changed

9 files changed

+36
-44
lines changed

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

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,19 @@ module Middlewares
1313
module Dup
1414
# Excon middleware for instrumentation
1515
class TracerMiddleware < ::Excon::Middleware::Base
16-
1716
def request_call(datum)
1817
return @stack.request_call(datum) if untraced?(datum)
1918

2019
http_method, original_method = Helpers.normalize_method(datum[:method])
2120
cleansed_url = OpenTelemetry::Common::Utilities.cleanse_url(::Excon::Utils.request_uri(datum))
2221
attributes = {
23-
OpenTelemetry::SemanticConventions::Trace::HTTP_HOST => datum[:host],
24-
OpenTelemetry::SemanticConventions::Trace::HTTP_METHOD => http_method,
25-
OpenTelemetry::SemanticConventions::Trace::HTTP_SCHEME => datum[:scheme],
26-
OpenTelemetry::SemanticConventions::Trace::HTTP_TARGET => datum[:path],
27-
OpenTelemetry::SemanticConventions::Trace::HTTP_URL => cleansed_url,
28-
OpenTelemetry::SemanticConventions::Trace::NET_PEER_NAME => datum[:hostname],
29-
OpenTelemetry::SemanticConventions::Trace::NET_PEER_PORT => datum[:port],
22+
'http.host' => datum[:host],
23+
'http.method' => http_method,
24+
'http.scheme' => datum[:scheme],
25+
'http.target' => datum[:path],
26+
'http.url' => cleansed_url,
27+
'net.peer.name' => datum[:hostname],
28+
'net.peer.port' => datum[:port],
3029
'http.request.method' => http_method,
3130
'url.scheme' => datum[:scheme],
3231
'url.path' => datum[:path],
@@ -37,7 +36,7 @@ def request_call(datum)
3736
attributes['http.request.method_original'] = original_method if original_method
3837
attributes['url.query'] = datum[:query] if datum[:query]
3938
peer_service = Excon::Instrumentation.instance.config[:peer_service]
40-
attributes[OpenTelemetry::SemanticConventions::Trace::PEER_SERVICE] = peer_service if peer_service
39+
attributes['peer.service'] = peer_service if peer_service
4140
attributes.merge!(OpenTelemetry::Common::HTTP::ClientContext.attributes)
4241
span_name = Helpers.format_span_name(attributes, http_method)
4342
span = tracer.start_span(span_name, attributes: attributes, kind: :client)
@@ -81,7 +80,7 @@ def handle_response(datum)
8180

8281
if datum.key?(:response)
8382
response = datum[:response]
84-
span.set_attribute(OpenTelemetry::SemanticConventions::Trace::HTTP_STATUS_CODE, response[:status])
83+
span.set_attribute('http.status_code', response[:status])
8584
span.set_attribute('http.response.status_code', response[:status])
8685
span.status = OpenTelemetry::Trace::Status.error unless Helpers::HTTP_STATUS_SUCCESS_RANGE.cover?(response[:status].to_i)
8786
end

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

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,22 @@ module Middlewares
1313
module Old
1414
# Excon middleware for instrumentation
1515
class TracerMiddleware < ::Excon::Middleware::Base
16-
1716
def request_call(datum)
1817
return @stack.request_call(datum) if untraced?(datum)
1918

2019
http_method, original_method = Helpers.normalize_method(datum[:method])
2120
attributes = {
22-
OpenTelemetry::SemanticConventions::Trace::HTTP_HOST => datum[:host],
23-
OpenTelemetry::SemanticConventions::Trace::HTTP_METHOD => http_method,
24-
OpenTelemetry::SemanticConventions::Trace::HTTP_SCHEME => datum[:scheme],
25-
OpenTelemetry::SemanticConventions::Trace::HTTP_TARGET => datum[:path],
26-
OpenTelemetry::SemanticConventions::Trace::HTTP_URL => OpenTelemetry::Common::Utilities.cleanse_url(::Excon::Utils.request_uri(datum)),
27-
OpenTelemetry::SemanticConventions::Trace::NET_PEER_NAME => datum[:hostname],
28-
OpenTelemetry::SemanticConventions::Trace::NET_PEER_PORT => datum[:port]
21+
'http.host' => datum[:host],
22+
'http.method' => http_method,
23+
'http.scheme' => datum[:scheme],
24+
'http.target' => datum[:path],
25+
'http.url' => OpenTelemetry::Common::Utilities.cleanse_url(::Excon::Utils.request_uri(datum)),
26+
'net.peer.name' => datum[:hostname],
27+
'net.peer.port' => datum[:port]
2928
}
3029
attributes['http.request.method_original'] = original_method if original_method
3130
peer_service = Excon::Instrumentation.instance.config[:peer_service]
32-
attributes[OpenTelemetry::SemanticConventions::Trace::PEER_SERVICE] = peer_service if peer_service
31+
attributes['peer.service'] = peer_service if peer_service
3332
attributes.merge!(OpenTelemetry::Common::HTTP::ClientContext.attributes)
3433
span_name = Helpers.format_span_name(attributes, http_method)
3534
span = tracer.start_span(span_name, attributes: attributes, kind: :client)
@@ -73,7 +72,7 @@ def handle_response(datum)
7372

7473
if datum.key?(:response)
7574
response = datum[:response]
76-
span.set_attribute(OpenTelemetry::SemanticConventions::Trace::HTTP_STATUS_CODE, response[:status])
75+
span.set_attribute('http.status_code', response[:status])
7776
span.status = OpenTelemetry::Trace::Status.error unless Helpers::HTTP_STATUS_SUCCESS_RANGE.cover?(response[:status].to_i)
7877
end
7978

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ module Middlewares
1313
module Stable
1414
# Excon middleware for instrumentation
1515
class TracerMiddleware < ::Excon::Middleware::Base
16-
1716
def request_call(datum)
1817
return @stack.request_call(datum) if untraced?(datum)
1918

@@ -29,7 +28,7 @@ def request_call(datum)
2928
attributes['http.request.method_original'] = original_method if original_method
3029
attributes['url.query'] = datum[:query] if datum[:query]
3130
peer_service = Excon::Instrumentation.instance.config[:peer_service]
32-
attributes[OpenTelemetry::SemanticConventions::Trace::PEER_SERVICE] = peer_service if peer_service
31+
attributes['peer.service'] = peer_service if peer_service
3332
attributes.merge!(OpenTelemetry::Common::HTTP::ClientContext.attributes)
3433
span_name = Helpers.format_span_name(attributes, http_method)
3534
span = tracer.start_span(span_name, attributes: attributes, kind: :client)

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ module Dup
1414
# TracerMiddleware propagates context and instruments Faraday requests
1515
# by way of its middleware system
1616
class TracerMiddleware < ::Faraday::Middleware
17-
1817
def call(env)
1918
http_method, original_method = Helpers.normalize_method(env.method)
2019
config = Faraday::Instrumentation.instance.config

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ module Stable
1414
# TracerMiddleware propagates context and instruments Faraday requests
1515
# by way of its middleware system
1616
class TracerMiddleware < ::Faraday::Middleware
17-
1817
def call(env)
1918
http_method, original_method = Helpers.normalize_method(env.method)
2019
config = Faraday::Instrumentation.instance.config

instrumentation/net_http/lib/opentelemetry/instrumentation/net/http/helpers.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ module Helpers
4040
# @api private
4141
def known_methods
4242
@known_methods ||= if (env_methods = ENV.fetch('OTEL_INSTRUMENTATION_HTTP_KNOWN_METHODS', nil))
43-
env_methods.split(',').map(&:strip).map(&:upcase).freeze
43+
env_methods.split(',').map { |x| x.strip.upcase }.freeze
4444
else
4545
DEFAULT_KNOWN_METHODS
4646
end

instrumentation/net_http/lib/opentelemetry/instrumentation/net/http/patches/dup/instrumentation.rb

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ module Patches
1414
module Dup
1515
# Module to prepend to Net::HTTP for instrumentation
1616
module Instrumentation
17-
1817
# Constant for the HTTP status range
1918

2019
def request(req, body = nil, &)
@@ -26,11 +25,11 @@ def request(req, body = nil, &)
2625
http_method, original_method = Helpers.normalize_method(req.method)
2726

2827
attributes = {
29-
OpenTelemetry::SemanticConventions::Trace::HTTP_METHOD => http_method,
30-
OpenTelemetry::SemanticConventions::Trace::HTTP_SCHEME => Helpers::USE_SSL_TO_SCHEME[use_ssl?],
31-
OpenTelemetry::SemanticConventions::Trace::HTTP_TARGET => req.path,
32-
OpenTelemetry::SemanticConventions::Trace::NET_PEER_NAME => @address,
33-
OpenTelemetry::SemanticConventions::Trace::NET_PEER_PORT => @port,
28+
'http.method' => http_method,
29+
'http.scheme' => Helpers::USE_SSL_TO_SCHEME[use_ssl?],
30+
'http.target' => req.path,
31+
'net.peer.name' => @address,
32+
'net.peer.port' => @port,
3433
'http.request.method' => http_method,
3534
'url.scheme' => Helpers::USE_SSL_TO_SCHEME[use_ssl?],
3635
'server.address' => @address,
@@ -72,8 +71,8 @@ def connect
7271
end
7372

7473
attributes = {
75-
OpenTelemetry::SemanticConventions::Trace::NET_PEER_NAME => conn_address,
76-
OpenTelemetry::SemanticConventions::Trace::NET_PEER_PORT => conn_port,
74+
'net.peer.name' => conn_address,
75+
'net.peer.port' => conn_port,
7776
'server.address' => conn_address,
7877
'server.port' => conn_port
7978
}.merge!(OpenTelemetry::Common::HTTP::ClientContext.attributes)
@@ -96,7 +95,7 @@ def annotate_span_with_response!(span, response)
9695

9796
status_code = response.code.to_i
9897

99-
span.set_attribute(OpenTelemetry::SemanticConventions::Trace::HTTP_STATUS_CODE, status_code)
98+
span.set_attribute('http.status_code', status_code)
10099
span.set_attribute('http.response.status_code', status_code)
101100
span.status = OpenTelemetry::Trace::Status.error unless Helpers::HTTP_STATUS_SUCCESS_RANGE.cover?(status_code)
102101
end

instrumentation/net_http/lib/opentelemetry/instrumentation/net/http/patches/old/instrumentation.rb

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ module Patches
1414
module Old
1515
# Module to prepend to Net::HTTP for instrumentation
1616
module Instrumentation
17-
1817
# Constant for the HTTP status range
1918

2019
def request(req, body = nil, &)
@@ -26,11 +25,11 @@ def request(req, body = nil, &)
2625
http_method, original_method = Helpers.normalize_method(req.method)
2726

2827
attributes = {
29-
OpenTelemetry::SemanticConventions::Trace::HTTP_METHOD => http_method,
30-
OpenTelemetry::SemanticConventions::Trace::HTTP_SCHEME => Helpers::USE_SSL_TO_SCHEME[use_ssl?],
31-
OpenTelemetry::SemanticConventions::Trace::HTTP_TARGET => req.path,
32-
OpenTelemetry::SemanticConventions::Trace::NET_PEER_NAME => @address,
33-
OpenTelemetry::SemanticConventions::Trace::NET_PEER_PORT => @port
28+
'http.method' => http_method,
29+
'http.scheme' => Helpers::USE_SSL_TO_SCHEME[use_ssl?],
30+
'http.target' => req.path,
31+
'net.peer.name' => @address,
32+
'net.peer.port' => @port
3433
}
3534
attributes['http.request.method_original'] = original_method if original_method
3635
attributes.merge!(OpenTelemetry::Common::HTTP::ClientContext.attributes)
@@ -64,8 +63,8 @@ def connect
6463
end
6564

6665
attributes = {
67-
OpenTelemetry::SemanticConventions::Trace::NET_PEER_NAME => conn_address,
68-
OpenTelemetry::SemanticConventions::Trace::NET_PEER_PORT => conn_port
66+
'net.peer.name' => conn_address,
67+
'net.peer.port' => conn_port
6968
}.merge!(OpenTelemetry::Common::HTTP::ClientContext.attributes)
7069

7170
if use_ssl? && proxy?
@@ -86,7 +85,7 @@ def annotate_span_with_response!(span, response)
8685

8786
status_code = response.code.to_i
8887

89-
span.set_attribute(OpenTelemetry::SemanticConventions::Trace::HTTP_STATUS_CODE, status_code)
88+
span.set_attribute('http.status_code', status_code)
9089
span.status = OpenTelemetry::Trace::Status.error unless Helpers::HTTP_STATUS_SUCCESS_RANGE.cover?(status_code)
9190
end
9291

instrumentation/net_http/lib/opentelemetry/instrumentation/net/http/patches/stable/instrumentation.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ module Patches
1414
module Stable
1515
# Module to prepend to Net::HTTP for instrumentation
1616
module Instrumentation
17-
1817
# Constant for the HTTP status range
1918

2019
def request(req, body = nil, &)

0 commit comments

Comments
 (0)