Skip to content

Commit 14dc089

Browse files
committed
Fix: remove redundant .to_s and refactor
1 parent c5b6aa3 commit 14dc089

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def call(env)
3737

3838
OpenTelemetry::Common::HTTP::ClientContext.with_attributes(attributes) do |attrs, _|
3939
tracer.in_span(
40-
http_method.to_s, attributes: attrs, kind: config.fetch(:span_kind)
40+
http_method, attributes: attrs, kind: config.fetch(:span_kind)
4141
) do |span|
4242
OpenTelemetry.propagation.inject(env.request_headers)
4343

@@ -59,11 +59,12 @@ def call(env)
5959
private
6060

6161
def span_creation_attributes(http_method:, url:, config:)
62+
cleansed_url = OpenTelemetry::Common::Utilities.cleanse_url(url.to_s)
6263
attrs = {
6364
'http.method' => http_method,
6465
'http.request.method' => http_method,
65-
'http.url' => OpenTelemetry::Common::Utilities.cleanse_url(url.to_s),
66-
'url.full' => OpenTelemetry::Common::Utilities.cleanse_url(url.to_s),
66+
'http.url' => cleansed_url,
67+
'url.full' => cleansed_url,
6768
'faraday.adapter.name' => app.class.name
6869
}
6970
attrs['net.peer.name'] = url.host if url.host

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def call(env)
3737

3838
OpenTelemetry::Common::HTTP::ClientContext.with_attributes(attributes) do |attrs, _|
3939
tracer.in_span(
40-
http_method.to_s, attributes: attrs, kind: config.fetch(:span_kind)
40+
http_method, attributes: attrs, kind: config.fetch(:span_kind)
4141
) do |span|
4242
OpenTelemetry.propagation.inject(env.request_headers)
4343

0 commit comments

Comments
 (0)