Module: NewRelic::Security::Instrumentation::GRPC::RpcDesc

Included in:
Prepend
Defined in:
lib/newrelic_security/instrumentation-security/grpc/server/chain.rb,
lib/newrelic_security/instrumentation-security/grpc/server/prepend.rb,
lib/newrelic_security/instrumentation-security/grpc/server/instrumentation.rb

Defined Under Namespace

Modules: Chain, Prepend

Instance Method Summary collapse

Instance Method Details

#grpc_server_on_enter(active_call, mth, _inter_ctx, is_grpc_client_stream, is_grpc_server_stream) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/newrelic_security/instrumentation-security/grpc/server/instrumentation.rb', line 9

def grpc_server_on_enter(active_call, mth, _inter_ctx, is_grpc_client_stream, is_grpc_server_stream)
  event = nil
  NewRelic::Security::Agent.logger.debug "OnEnter : #{self.class}.#{__method__}"
  grpc_request = {}
  grpc_request[:headers] = active_call.
  grpc_request[:peer] = active_call.peer
  # puts "mth : #{mth.class} #{mth.methods}"
  # puts "mth :#{mth.original_name}, #{mth.to_s}, #{mth.name}, #{mth.receiver}, #{mth.parameters}, #{mth.owner}, #{mth.unbind}, #{mth.super_method},, #{mth.instance_variables}"
  NewRelic::Security::Agent::Utils.get_app_routes(:grpc, mth) if NewRelic::Security::Agent.agent.route_map.empty?
  grpc_request[:method] = "#{mth.owner}/#{mth.original_name}"
  grpc_request[:is_grpc_client_stream] = is_grpc_client_stream
  grpc_request[:is_grpc_server_stream] = is_grpc_server_stream
  grpc_request[:body] = is_grpc_client_stream ? [] : ::String.new
  NewRelic::Security::Agent::Control::GRPCContext.set_context(grpc_request)
  NewRelic::Security::Agent::Utils.parse_fuzz_header(NewRelic::Security::Agent::Control::GRPCContext.get_context)
rescue => exception
  NewRelic::Security::Agent.logger.error "Exception in hook in #{self.class}.#{__method__}, #{exception.inspect}, #{exception.backtrace}"
ensure
  yield
  return event
end