Skip to content

Commit 2f7a79d

Browse files
committed
Rely on Rack semconv middlware alias for Sinatra instrumentation
1 parent 62ce1ca commit 2f7a79d

File tree

5 files changed

+7
-14
lines changed

5 files changed

+7
-14
lines changed

instrumentation/CONTRIBUTING.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -458,11 +458,8 @@ end
458458
# Set up fake Rack application
459459
builder = Rack::Builder.app do
460460
# Integration is automatic in web frameworks but plain Rack applications require this line.
461-
# - middleware_args_old to emit old HTTP semantic conventions
462-
# - middleware_args_stable to emit stable HTTP semantic conventions
463-
# - middleware_args_dup to emit both old and stable HTTP semantic conventions
464461
# Enable it in your config.ru.
465-
use *OpenTelemetry::Instrumentation::Rack::Instrumentation.instance.middleware_args_old
462+
use *OpenTelemetry::Instrumentation::Rack::Instrumentation.instance.middleware_args
466463
run ExampleAPI
467464
end
468465
app = Rack::MockRequest.new(builder)

instrumentation/rack/lib/opentelemetry/instrumentation/rack/instrumentation.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,19 +36,19 @@ class Instrumentation < OpenTelemetry::Instrumentation::Base
3636
#
3737
# @example Default usage
3838
# Rack::Builder.new do
39-
# use *OpenTelemetry::Instrumentation::Rack::Instrumenation.instance.middleware_args_old
39+
# use *OpenTelemetry::Instrumentation::Rack::Instrumenation.instance.middleware_args
4040
# run lambda { |_arg| [200, { 'Content-Type' => 'text/plain' }, body] }
4141
# end
4242
# @return [Array] consisting of a middleware and arguments used in rack builders
43-
def middleware_args_old
43+
def middleware_args
4444
if config.fetch(:use_rack_events, false) == true && defined?(OpenTelemetry::Instrumentation::Rack::Middlewares::Old::EventHandler)
4545
[::Rack::Events, [OpenTelemetry::Instrumentation::Rack::Middlewares::Old::EventHandler.new]]
4646
else
4747
[OpenTelemetry::Instrumentation::Rack::Middlewares::Old::TracerMiddleware]
4848
end
4949
end
5050

51-
alias middleware_args middleware_args_old
51+
alias middleware_args_old middleware_args
5252

5353
def middleware_args_dup
5454
if config.fetch(:use_rack_events, false) == true && defined?(OpenTelemetry::Instrumentation::Rack::Middlewares::Dup::EventHandler)

instrumentation/sinatra/example/config.ru

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,5 @@ class App < Sinatra::Base
4747
end
4848
end
4949

50-
# Rack instrumentation is moving through the process of migrating to the new HTTP semantic
51-
# conventions. In this example, we will use the old HTTP conventions by patching the Rack
52-
# middleware that uses the old conventions. See README: HTTP Semantic Conventions for more
53-
# information.
54-
use(*OpenTelemetry::Instrumentation::Rack::Instrumentation.instance.middleware_args_old)
50+
use(*OpenTelemetry::Instrumentation::Rack::Instrumentation.instance.middleware_args)
5551
run App

instrumentation/sinatra/lib/opentelemetry/instrumentation/sinatra/instrumentation.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def install_middleware(app)
6060
elsif values.include?('http')
6161
app.use(*OpenTelemetry::Instrumentation::Rack::Instrumentation.instance.middleware_args_stable)
6262
else
63-
app.use(*OpenTelemetry::Instrumentation::Rack::Instrumentation.instance.middleware_args_old)
63+
app.use(*OpenTelemetry::Instrumentation::Rack::Instrumentation.instance.middleware_args)
6464
end
6565
end
6666

instrumentation/sinatra/test/opentelemetry/instrumentation/sinatra_old_http_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ class CustomError < StandardError; end
198198
let(:app) do
199199
apps_to_build = apps
200200
Rack::Builder.new do
201-
use(*OpenTelemetry::Instrumentation::Rack::Instrumentation.instance.middleware_args_old)
201+
use(*OpenTelemetry::Instrumentation::Rack::Instrumentation.instance.middleware_args)
202202

203203
apps_to_build.each do |root, app|
204204
map root do

0 commit comments

Comments
 (0)