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
Class Method Details
.add_pin! ⇒ Object
37 38 39 40 41 42 43 44 45 46 |
# File 'lib/ddtrace/contrib/grape/patcher.rb', line 37 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
48 49 50 |
# File 'lib/ddtrace/contrib/grape/patcher.rb', line 48 def get_option(option) Datadog.configuration[:grape].get_option(option) end |
.patch ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/ddtrace/contrib/grape/patcher.rb', line 21 def patch do_once(:grape) do begin # Patch endpoints ::Grape::Endpoint.send(:include, Instrumentation) add_pin! # Subscribe to ActiveSupport events Datadog::Contrib::Grape::Endpoint.subscribe rescue StandardError => e Datadog::Tracer.log.error("Unable to apply Grape integration: #{e}") end end end |
.patched? ⇒ Boolean
17 18 19 |
# File 'lib/ddtrace/contrib/grape/patcher.rb', line 17 def patched? done?(:grape) end |