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.metadata
grpc_request[:peer] = active_call.peer
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.(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
|