Module: Datadog::Tracing::Contrib::Rack::MiddlewareNamePatcher
- Includes:
- Patcher
- Defined in:
- lib/datadog/tracing/contrib/rack/patcher.rb
Overview
Provides instrumentation for Rack middleware names
Class Method Summary collapse
- .get_option(option) ⇒ Object
- .patch ⇒ Object
- .patch_middleware_names ⇒ Object
- .retain_middleware_name(middleware) ⇒ Object
- .target_version ⇒ Object
Methods included from Patcher
Class Method Details
.get_option(option) ⇒ Object
64 65 66 |
# File 'lib/datadog/tracing/contrib/rack/patcher.rb', line 64 def get_option(option) Datadog.configuration.tracing[:rack].get_option(option) end |
.patch ⇒ Object
33 34 35 |
# File 'lib/datadog/tracing/contrib/rack/patcher.rb', line 33 def patch patch_middleware_names end |
.patch_middleware_names ⇒ Object
37 38 39 40 41 42 43 44 45 |
# File 'lib/datadog/tracing/contrib/rack/patcher.rb', line 37 def patch_middleware_names retain_middleware_name(get_option(:application)) rescue => e # We can safely ignore these exceptions since they happen only in the # context of middleware patching outside a Rails server process (eg. a # process that doesn't serve HTTP requests but has Rails environment # loaded such as a Resque master process) Datadog.logger.debug("Error patching middleware stack: #{e}") end |
.retain_middleware_name(middleware) ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/datadog/tracing/contrib/rack/patcher.rb', line 47 def retain_middleware_name(middleware) return unless middleware && middleware.respond_to?(:call) middleware.singleton_class.class_eval do alias_method :__call, :call def call(env) env['RESPONSE_MIDDLEWARE'] = self.class.to_s __call(env) end end following = (middleware.instance_variable_get('@app') if middleware.instance_variable_defined?('@app')) retain_middleware_name(following) end |
.target_version ⇒ Object
29 30 31 |
# File 'lib/datadog/tracing/contrib/rack/patcher.rb', line 29 def target_version Integration.version end |