Module: NewRelic::Agent::Instrumentation::GRPC::Client::Chain

Defined in:
lib/new_relic/agent/instrumentation/grpc/client/chain.rb

Class Method Summary collapse

Class Method Details

.instrument!Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/new_relic/agent/instrumentation/grpc/client/chain.rb', line 11

def self.instrument!
  ::GRPC::ClientStub.class_eval do
    include NewRelic::Agent::Instrumentation::GRPC::Client

    def bidi_streamer_with_new_relic_trace(method, requests, marshal, unmarshal,
      deadline: nil,
      return_op: false,
      parent: nil,
      credentials: nil,
      metadata: {},
      &blk)

      issue_request_with_tracing(:bidi_streamer, method, requests, marshal, unmarshal,
        deadline: deadline,
        return_op: return_op,
        parent: parent,
        credentials: credentials,
        metadata: )

      # TODO: gRPC - confirm that &blk is being invoked correctly
    end

    alias bidi_streamer_without_newrelic_trace bidi_streamer
    alias bidi_streamer bidi_streamer_with_newrelic_trace

    def client_streamer_with_newrelic_trace(method, requests, marshal, unmarshal,
      deadline: nil,
      return_op: false,
      parent: nil,
      credentials: nil,
      metadata: {})

      issue_request_with_tracing(:client_streamer, method, requests, marshal, unmarshal,
        deadline: deadline,
        return_op: return_op,
        parent: parent,
        credentials: credentials,
        metadata: )
    end

    alias client_streamer_without_newrelic_trace client_streamer
    alias client_streamer client_streamer_with_newrelic_trace

    def request_response_with_newrelic_trace(method, req, marshal, unmarshal,
      deadline: nil,
      return_op: false,
      parent: nil,
      credentials: nil,
      metadata: {})

      issue_request_with_tracing(:request_response, method, req, marshal, unmarshal,
        deadline: deadline,
        return_op: return_op,
        parent: parent,
        credentials: credentials,
        metadata: )
    end

    alias request_response_without_newrelic_trace request_response
    alias request_response request_response_with_newrelic_trace

    def server_streamer_with_newrelic_trace(method, req, marshal, unmarshal,
      deadline: nil,
      return_op: false,
      parent: nil,
      credentials: nil,
      metadata: {},
      &blk)

      issue_request_with_tracing(:server_streamer, method, req, marshal, unmarshal,
        deadline: deadline,
        return_op: return_op,
        parent: parent,
        credentials: credentials,
        metadata: )

      # TODO: gRPC - confirm that &blk is being invoked correctly
    end

    alias server_streamer_without_newrelic_trace server_streamer
    alias server_streamer server_streamer_with_newrelic_trace
  end
end