Skip to content

Commit

Permalink
Create a stand-alone patcher for rack
Browse files Browse the repository at this point in the history
  • Loading branch information
p-lambert committed Dec 13, 2017
1 parent e9f3fc1 commit e1be29b
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 10 deletions.
10 changes: 0 additions & 10 deletions lib/ddtrace/contrib/rack/middlewares.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,6 @@ module Rack
# application. If request tags are not set by the app, they will be set using
# information available at the Rack level.
class TraceMiddleware
include Base
register_as :rack

option :tracer, default: Datadog.tracer
option :service_name, default: 'rack', depends_on: [:tracer] do |value|
get_option(:tracer).set_service_info(value, 'rack', Ext::AppTypes::WEB)
value
end
option :distributed_tracing, default: false

def initialize(app, options = {})
# update options with our configuration, unless it's already available
[:tracer, :service_name, :distributed_tracing].each do |k|
Expand Down
21 changes: 21 additions & 0 deletions lib/ddtrace/contrib/rack/patcher.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
module Datadog
module Contrib
module Rack
module Patcher
include Base
register_as :rack

option :tracer, default: Datadog.tracer
option :distributed_tracing, default: false
option :service_name, default: 'rack', depends_on: [:tracer] do |value|
get_option(:tracer).set_service_info(value, 'rack', Ext::AppTypes::WEB)
value
end

def self.patch
require_relative 'middlewares'
end
end
end
end
end
1 change: 1 addition & 0 deletions lib/ddtrace/monkey.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# because patchers do not include any 3rd party module nor even our
# patching code, which is required on demand, when patching.
require 'ddtrace/contrib/base'
require 'ddtrace/contrib/rack/patcher'
require 'ddtrace/contrib/rails/patcher'
require 'ddtrace/contrib/active_record/patcher'
require 'ddtrace/contrib/elasticsearch/patcher'
Expand Down

0 comments on commit e1be29b

Please sign in to comment.