Module: Datadog::Tracing::Contrib::Rack::Patcher

Defined in:
lib/datadog/tracing/contrib/rack/patcher.rb

Overview

Applies multiple patches

Constant Summary collapse

PATCHERS =
[
  MiddlewarePatcher,
  MiddlewareNamePatcher
].freeze

Class Method Summary collapse

Class Method Details

.get_option(option) ⇒ Object



104
105
106
# File 'lib/datadog/tracing/contrib/rack/patcher.rb', line 104

def get_option(option)
  Datadog.configuration.tracing[:rack].get_option(option)
end

.patchObject



86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/datadog/tracing/contrib/rack/patcher.rb', line 86

def patch
  MiddlewarePatcher.patch unless MiddlewarePatcher.patched?

  # Patch middleware names
  if !MiddlewareNamePatcher.patched? && get_option(:middleware_names)
    if get_option(:application)
      MiddlewareNamePatcher.patch
    else
      Datadog.logger.warn(
        %(
      Rack :middleware_names requires you to also pass :application.
      Middleware names have NOT been patched; please provide :application.
      e.g. use: :rack, middleware_names: true, application: my_rack_app)
      )
    end
  end
end

.patch_error_resultObject



112
113
114
# File 'lib/datadog/tracing/contrib/rack/patcher.rb', line 112

def patch_error_result
  MiddlewarePatcher.patch_error_result || MiddlewareNamePatcher.patch_error_result
end

.patch_successfulObject



108
109
110
# File 'lib/datadog/tracing/contrib/rack/patcher.rb', line 108

def patch_successful
  MiddlewarePatcher.patch_successful || MiddlewareNamePatcher.patch_successful
end

.patched?Boolean

Returns:

  • (Boolean)


78
79
80
# File 'lib/datadog/tracing/contrib/rack/patcher.rb', line 78

def patched?
  PATCHERS.all?(&:patched?)
end

.target_versionObject



82
83
84
# File 'lib/datadog/tracing/contrib/rack/patcher.rb', line 82

def target_version
  Integration.version
end