Module: Datadog::Contrib::GRPC::Patcher
- Includes:
- Patcher
- Defined in:
- lib/ddtrace/contrib/grpc/patcher.rb
Overview
Patcher enables patching of ‘grpc’ module.
Defined Under Namespace
Classes: DeprecatedPin
Class Method Summary collapse
- .add_pin! ⇒ Object
- .get_option(option) ⇒ Object
- .patch ⇒ Object
- .patched? ⇒ Boolean
- .prepend_interceptor ⇒ Object
Methods included from Patcher
Class Method Details
.add_pin! ⇒ Object
33 34 35 36 37 38 39 40 |
# File 'lib/ddtrace/contrib/grpc/patcher.rb', line 33 def add_pin! DeprecatedPin.new( get_option(:service_name), app: Ext::APP, app_type: Datadog::Ext::AppTypes::WEB, tracer: get_option(:tracer) ).onto(::GRPC) end |
.get_option(option) ⇒ Object
47 48 49 |
# File 'lib/ddtrace/contrib/grpc/patcher.rb', line 47 def get_option(option) Datadog.configuration[:grpc].get_option(option) end |
.patch ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/ddtrace/contrib/grpc/patcher.rb', line 17 def patch do_once(:grpc) do begin require 'ddtrace/propagation/grpc_propagator' require 'ddtrace/contrib/grpc/datadog_interceptor' require 'ddtrace/contrib/grpc/intercept_with_datadog' add_pin! prepend_interceptor rescue StandardError => e Datadog::Tracer.log.error("Unable to apply gRPC integration: #{e}") end end end |
.patched? ⇒ Boolean
13 14 15 |
# File 'lib/ddtrace/contrib/grpc/patcher.rb', line 13 def patched? done?(:grpc) end |
.prepend_interceptor ⇒ Object
42 43 44 45 |
# File 'lib/ddtrace/contrib/grpc/patcher.rb', line 42 def prepend_interceptor ::GRPC::InterceptionContext .send(:prepend, Datadog::Contrib::GRPC::InterceptWithDatadog) end |