Skip to content

Commit 247cc2f

Browse files
committed
fix: appease rubocop whitespace error
1 parent c149be0 commit 247cc2f

File tree

3 files changed

+68
-68
lines changed

3 files changed

+68
-68
lines changed

instrumentation/httpx/lib/opentelemetry/instrumentation/httpx/dup/plugin.rb

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ module Plugin
1313
# an OTEL trace.
1414
module RequestTracer
1515
module_function
16-
16+
1717
# initializes tracing on the +request+.
1818
def call(request)
1919
span = nil
20-
20+
2121
# request objects are reused, when already buffered requests get rerouted to a different
2222
# connection due to connection issues, or when they already got a response, but need to
2323
# be retried. In such situations, the original span needs to be extended for the former,
@@ -29,51 +29,51 @@ def call(request)
2929
# one gets to actually sending the request.
3030
request.on(:headers) do
3131
next if span
32-
32+
3333
span = initialize_span(request)
3434
end
35-
35+
3636
request.on(:response) do |response|
3737
unless span
3838
next unless response.is_a?(::HTTPX::ErrorResponse) && response.error.respond_to?(:connection)
39-
39+
4040
# handles the case when the +error+ happened during name resolution, which means
4141
# that the tracing start point hasn't been triggered yet; in such cases, the approximate
4242
# initial resolving time is collected from the connection, and used as span start time,
4343
# and the tracing object in inserted before the on response callback is called.
4444
span = initialize_span(request, response.error.connection.init_time)
45-
45+
4646
end
47-
47+
4848
finish(response, span)
4949
end
5050
end
51-
51+
5252
def finish(response, span)
5353
if response.is_a?(::HTTPX::ErrorResponse)
5454
span.record_exception(response.error)
5555
span.status = Trace::Status.error(response.error.to_s)
5656
else
5757
span.set_attribute(OpenTelemetry::SemanticConventions::Trace::HTTP_STATUS_CODE, response.status)
5858
span.set_attribute('http.response.status_code', response.status)
59-
59+
6060
if response.status.between?(400, 599)
6161
err = ::HTTPX::HTTPError.new(response)
6262
span.record_exception(err)
6363
span.status = Trace::Status.error(err.to_s)
6464
end
6565
end
66-
66+
6767
span.finish
6868
end
69-
69+
7070
# return a span initialized with the +@request+ state.
7171
def initialize_span(request, start_time = ::Time.now)
7272
verb = request.verb
7373
uri = request.uri
74-
74+
7575
config = HTTPX::Instrumentation.instance.config
76-
76+
7777
attributes = {
7878
OpenTelemetry::SemanticConventions::Trace::HTTP_HOST => uri.host,
7979
OpenTelemetry::SemanticConventions::Trace::HTTP_METHOD => verb,
@@ -89,43 +89,43 @@ def initialize_span(request, start_time = ::Time.now)
8989
'server.address' => uri.host,
9090
'server.port' => uri.port
9191
}
92-
92+
9393
attributes['url.query'] = uri.query unless uri.query.nil?
9494
attributes[OpenTelemetry::SemanticConventions::Trace::PEER_SERVICE] = config[:peer_service] if config[:peer_service]
9595
attributes.merge!(OpenTelemetry::Common::HTTP::ClientContext.attributes)
96-
96+
9797
span = tracer.start_span(verb.to_s, attributes: attributes, kind: :client, start_timestamp: start_time)
98-
98+
9999
OpenTelemetry::Trace.with_span(span) do
100100
OpenTelemetry.propagation.inject(request.headers)
101101
end
102-
102+
103103
span
104104
rescue StandardError => e
105105
OpenTelemetry.handle_error(exception: e)
106106
end
107-
107+
108108
def tracer
109109
HTTPX::Instrumentation.instance.tracer
110110
end
111111
end
112-
112+
113113
# Request patch to initiate the trace on initialization.
114114
module RequestMethods
115115
def initialize(*)
116116
super
117-
117+
118118
RequestTracer.call(self)
119119
end
120120
end
121-
121+
122122
# Connection patch to start monitoring on initialization.
123123
module ConnectionMethods
124124
attr_reader :init_time
125-
125+
126126
def initialize(*)
127127
super
128-
128+
129129
@init_time = ::Time.now
130130
end
131131
end

instrumentation/httpx/lib/opentelemetry/instrumentation/httpx/old/plugin.rb

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ module Plugin
1313
# an OTEL trace.
1414
module RequestTracer
1515
module_function
16-
16+
1717
# initializes tracing on the +request+.
1818
def call(request)
1919
span = nil
20-
20+
2121
# request objects are reused, when already buffered requests get rerouted to a different
2222
# connection due to connection issues, or when they already got a response, but need to
2323
# be retried. In such situations, the original span needs to be extended for the former,
@@ -29,50 +29,50 @@ def call(request)
2929
# one gets to actually sending the request.
3030
request.on(:headers) do
3131
next if span
32-
32+
3333
span = initialize_span(request)
3434
end
35-
35+
3636
request.on(:response) do |response|
3737
unless span
3838
next unless response.is_a?(::HTTPX::ErrorResponse) && response.error.respond_to?(:connection)
39-
39+
4040
# handles the case when the +error+ happened during name resolution, which means
4141
# that the tracing start point hasn't been triggered yet; in such cases, the approximate
4242
# initial resolving time is collected from the connection, and used as span start time,
4343
# and the tracing object in inserted before the on response callback is called.
4444
span = initialize_span(request, response.error.connection.init_time)
45-
45+
4646
end
47-
47+
4848
finish(response, span)
4949
end
5050
end
51-
51+
5252
def finish(response, span)
5353
if response.is_a?(::HTTPX::ErrorResponse)
5454
span.record_exception(response.error)
5555
span.status = Trace::Status.error(response.error.to_s)
5656
else
5757
span.set_attribute(OpenTelemetry::SemanticConventions::Trace::HTTP_STATUS_CODE, response.status)
58-
58+
5959
if response.status.between?(400, 599)
6060
err = ::HTTPX::HTTPError.new(response)
6161
span.record_exception(err)
6262
span.status = Trace::Status.error(err.to_s)
6363
end
6464
end
65-
65+
6666
span.finish
6767
end
68-
68+
6969
# return a span initialized with the +@request+ state.
7070
def initialize_span(request, start_time = ::Time.now)
7171
verb = request.verb
7272
uri = request.uri
73-
73+
7474
config = HTTPX::Instrumentation.instance.config
75-
75+
7676
attributes = {
7777
OpenTelemetry::SemanticConventions::Trace::HTTP_HOST => uri.host,
7878
OpenTelemetry::SemanticConventions::Trace::HTTP_METHOD => verb,
@@ -82,42 +82,42 @@ def initialize_span(request, start_time = ::Time.now)
8282
OpenTelemetry::SemanticConventions::Trace::NET_PEER_NAME => uri.host,
8383
OpenTelemetry::SemanticConventions::Trace::NET_PEER_PORT => uri.port
8484
}
85-
85+
8686
attributes[OpenTelemetry::SemanticConventions::Trace::PEER_SERVICE] = config[:peer_service] if config[:peer_service]
8787
attributes.merge!(OpenTelemetry::Common::HTTP::ClientContext.attributes)
88-
88+
8989
span = tracer.start_span("HTTP #{verb}", attributes: attributes, kind: :client, start_timestamp: start_time)
90-
90+
9191
OpenTelemetry::Trace.with_span(span) do
9292
OpenTelemetry.propagation.inject(request.headers)
9393
end
94-
94+
9595
span
9696
rescue StandardError => e
9797
OpenTelemetry.handle_error(exception: e)
9898
end
99-
99+
100100
def tracer
101101
HTTPX::Instrumentation.instance.tracer
102102
end
103103
end
104-
104+
105105
# Request patch to initiate the trace on initialization.
106106
module RequestMethods
107107
def initialize(*)
108108
super
109-
109+
110110
RequestTracer.call(self)
111111
end
112112
end
113-
113+
114114
# Connection patch to start monitoring on initialization.
115115
module ConnectionMethods
116116
attr_reader :init_time
117-
117+
118118
def initialize(*)
119119
super
120-
120+
121121
@init_time = ::Time.now
122122
end
123123
end

instrumentation/httpx/lib/opentelemetry/instrumentation/httpx/stable/plugin.rb

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ module Plugin
1313
# an OTEL trace.
1414
module RequestTracer
1515
module_function
16-
16+
1717
# initializes tracing on the +request+.
1818
def call(request)
1919
span = nil
20-
20+
2121
# request objects are reused, when already buffered requests get rerouted to a different
2222
# connection due to connection issues, or when they already got a response, but need to
2323
# be retried. In such situations, the original span needs to be extended for the former,
@@ -29,50 +29,50 @@ def call(request)
2929
# one gets to actually sending the request.
3030
request.on(:headers) do
3131
next if span
32-
32+
3333
span = initialize_span(request)
3434
end
35-
35+
3636
request.on(:response) do |response|
3737
unless span
3838
next unless response.is_a?(::HTTPX::ErrorResponse) && response.error.respond_to?(:connection)
39-
39+
4040
# handles the case when the +error+ happened during name resolution, which means
4141
# that the tracing start point hasn't been triggered yet; in such cases, the approximate
4242
# initial resolving time is collected from the connection, and used as span start time,
4343
# and the tracing object in inserted before the on response callback is called.
4444
span = initialize_span(request, response.error.connection.init_time)
45-
45+
4646
end
47-
47+
4848
finish(response, span)
4949
end
5050
end
51-
51+
5252
def finish(response, span)
5353
if response.is_a?(::HTTPX::ErrorResponse)
5454
span.record_exception(response.error)
5555
span.status = Trace::Status.error(response.error.to_s)
5656
else
5757
span.set_attribute('http.response.status_code', response.status)
58-
58+
5959
if response.status.between?(400, 599)
6060
err = ::HTTPX::HTTPError.new(response)
6161
span.record_exception(err)
6262
span.status = Trace::Status.error(err.to_s)
6363
end
6464
end
65-
65+
6666
span.finish
6767
end
68-
68+
6969
# return a span initialized with the +@request+ state.
7070
def initialize_span(request, start_time = ::Time.now)
7171
verb = request.verb
7272
uri = request.uri
73-
73+
7474
config = HTTPX::Instrumentation.instance.config
75-
75+
7676
attributes = {
7777
OpenTelemetry::SemanticConventions::Trace::HTTP_HOST => uri.host,
7878
'http.request.method' => verb,
@@ -85,39 +85,39 @@ def initialize_span(request, start_time = ::Time.now)
8585
attributes['url.query'] = uri.query unless uri.query.nil?
8686
attributes[OpenTelemetry::SemanticConventions::Trace::PEER_SERVICE] = config[:peer_service] if config[:peer_service]
8787
attributes.merge!(OpenTelemetry::Common::HTTP::ClientContext.attributes)
88-
88+
8989
span = tracer.start_span(verb.to_s, attributes: attributes, kind: :client, start_timestamp: start_time)
90-
90+
9191
OpenTelemetry::Trace.with_span(span) do
9292
OpenTelemetry.propagation.inject(request.headers)
9393
end
94-
94+
9595
span
9696
rescue StandardError => e
9797
OpenTelemetry.handle_error(exception: e)
9898
end
99-
99+
100100
def tracer
101101
HTTPX::Instrumentation.instance.tracer
102102
end
103103
end
104-
104+
105105
# Request patch to initiate the trace on initialization.
106106
module RequestMethods
107107
def initialize(*)
108108
super
109-
109+
110110
RequestTracer.call(self)
111111
end
112112
end
113-
113+
114114
# Connection patch to start monitoring on initialization.
115115
module ConnectionMethods
116116
attr_reader :init_time
117-
117+
118118
def initialize(*)
119119
super
120-
120+
121121
@init_time = ::Time.now
122122
end
123123
end

0 commit comments

Comments
 (0)