Module: Datadog::Contrib::Grape::Patcher

Includes:
Patcher
Defined in:
lib/ddtrace/contrib/grape/patcher.rb

Overview

Patcher enables patching of ‘grape’ module.

Defined Under Namespace

Classes: DeprecatedPin

Class Method Summary collapse

Methods included from Patcher

included

Class Method Details

.add_pin!Object



31
32
33
34
35
36
37
38
39
40
# File 'lib/ddtrace/contrib/grape/patcher.rb', line 31

def add_pin!
  # Attach a Pin object globally and set the service once
  pin = DeprecatedPin.new(
    get_option(:service_name),
    app: Ext::APP,
    app_type: Datadog::Ext::AppTypes::WEB,
    tracer: -> { get_option(:tracer) }
  )
  pin.onto(::Grape)
end

.get_option(option) ⇒ Object



42
43
44
# File 'lib/ddtrace/contrib/grape/patcher.rb', line 42

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

.patchObject



21
22
23
24
25
26
27
28
29
# File 'lib/ddtrace/contrib/grape/patcher.rb', line 21

def patch
  # Patch endpoints
  ::Grape::Endpoint.send(:include, Instrumentation)

  add_pin!

  # Subscribe to ActiveSupport events
  Datadog::Contrib::Grape::Endpoint.subscribe
end

.target_versionObject



17
18
19
# File 'lib/ddtrace/contrib/grape/patcher.rb', line 17

def target_version
  Integration.version
end