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

Methods included from Patcher

included

Class Method Details

.add_pin!Object



27
28
29
30
31
32
33
34
# File 'lib/ddtrace/contrib/grpc/patcher.rb', line 27

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



41
42
43
# File 'lib/ddtrace/contrib/grpc/patcher.rb', line 41

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

.patchObject



17
18
19
20
21
22
23
24
25
# File 'lib/ddtrace/contrib/grpc/patcher.rb', line 17

def patch
  require 'ddtrace/propagation/grpc_propagator'
  require 'ddtrace/contrib/grpc/datadog_interceptor'
  require 'ddtrace/contrib/grpc/intercept_with_datadog'

  add_pin!

  prepend_interceptor
end

.prepend_interceptorObject



36
37
38
39
# File 'lib/ddtrace/contrib/grpc/patcher.rb', line 36

def prepend_interceptor
  ::GRPC::InterceptionContext
    .send(:prepend, Datadog::Contrib::GRPC::InterceptWithDatadog)
end

.target_versionObject



13
14
15
# File 'lib/ddtrace/contrib/grpc/patcher.rb', line 13

def target_version
  Integration.version
end