module Datadog::Contrib::Grape::Patcher

Patcher enables patching of 'grape' module.

Public Instance Methods

add_pin!() click to toggle source
# 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) click to toggle source
# File lib/ddtrace/contrib/grape/patcher.rb, line 42
def get_option(option)
  Datadog.configuration[:grape].get_option(option)
end
patch() click to toggle source
# 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_version() click to toggle source
# File lib/ddtrace/contrib/grape/patcher.rb, line 17
def target_version
  Integration.version
end