Skip to content

Commit

Permalink
feat(rack)! Use Rack Events By Default
Browse files Browse the repository at this point in the history
I have been running the `Rack::Events` based instrumentation in our production workloads since 2023-10-23.

There is no noticeable difference in performance, however applications using `Rack::BodyProxy`
to stream responses will notice a slight increase in latency since it will include timings
writing response output to the socket.
  • Loading branch information
arielvalentin committed Oct 28, 2023
1 parent 06fba20 commit f85dbe7
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion instrumentation/rack/example/trace_demonstration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
builder = Rack::Builder.app do
# integration should be automatic in web frameworks (like rails),
# but for a plain Rack application, enable it in your config.ru, e.g.,
use OpenTelemetry::Instrumentation::Rack::Middlewares::TracerMiddleware
use ::Rack::Events, [OpenTelemetry::Instrumentation::Rack::Middlewares::EventHandler.new]

app = ->(_env) { [200, { 'Content-Type' => 'text/plain' }, ['All responses are OK']] }
run app
Expand Down
2 changes: 1 addition & 1 deletion instrumentation/rack/example/trace_demonstration2.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
end

# integrate instrumentation explicitly:
builder.use OpenTelemetry::Instrumentation::Rack::Middlewares::TracerMiddleware
builder.use ::Rack::Events, [OpenTelemetry::Instrumentation::Rack::Middlewares::EventHandler.new]

# demonstrate tracing (span output to console):
puts Rack::MockRequest.new(builder).get('/')
2 changes: 1 addition & 1 deletion instrumentation/rack/example/trace_demonstration3.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
builder = Rack::Builder.app do
# integration should be automatic in web frameworks (like rails),
# but for a plain Rack application, enable it in your config.ru, e.g.,
use OpenTelemetry::Instrumentation::Rack::Middlewares::TracerMiddleware
use ::Rack::Events, [OpenTelemetry::Instrumentation::Rack::Middlewares::EventHandler.new]

app = ->(_env) { [200, { 'Content-Type' => 'text/plain' }, ['All responses are OK']] }
run app
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class Instrumentation < OpenTelemetry::Instrumentation::Base
option :untraced_requests, default: nil, validate: :callable
option :response_propagators, default: [], validate: :array
# This option is only valid for applicaitons using Rack 2.0 or greater
option :use_rack_events, default: false, validate: :boolean
option :use_rack_events, default: true, validate: :boolean

# Temporary Helper for Sinatra and ActionPack middleware to use during installation
#
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
_(instrumentation.config[:url_quantization]).must_be_nil
_(instrumentation.config[:untraced_requests]).must_be_nil
_(instrumentation.config[:response_propagators]).must_be_empty
_(instrumentation.config[:use_rack_events]).must_equal false
_(instrumentation.config[:use_rack_events]).must_equal true
end
end

Expand Down

0 comments on commit f85dbe7

Please sign in to comment.