Class: GrpcNewrelicInterceptor::ServerInterceptor
- Inherits:
-
GRPC::ServerInterceptor
- Object
- GRPC::ServerInterceptor
- GrpcNewrelicInterceptor::ServerInterceptor
- Defined in:
- lib/grpc_newrelic_interceptor/server_interceptor.rb
Defined Under Namespace
Classes: Request
Instance Method Summary collapse
-
#initialize(ignored_services: [], params_filter: nil) ⇒ ServerInterceptor
constructor
A new instance of ServerInterceptor.
-
#request_response(request:, call:, method:) ⇒ Object
Intercept a unary request response call.
Constructor Details
#initialize(ignored_services: [], params_filter: nil) ⇒ ServerInterceptor
Returns a new instance of ServerInterceptor.
10 11 12 13 |
# File 'lib/grpc_newrelic_interceptor/server_interceptor.rb', line 10 def initialize(ignored_services: [], params_filter: nil) @ignored_services = Set.new(ignored_services.map(&:service_name)) @params_filter = params_filter end |
Instance Method Details
#request_response(request:, call:, method:) ⇒ Object
Intercept a unary request response call.
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/grpc_newrelic_interceptor/server_interceptor.rb', line 22 def request_response(request:, call:, method:) return yield if !newrelic_enabled? service_name = get_service_name(method) return yield if @ignored_services.include?(service_name) # NewRelic::Agent::Tracer.in_transaction is introduced in Newrelic v6.0.0. # We can use it for custom instrumentation. # cf. https://github.com/newrelic/rpm/blob/6.0.0.351/lib/new_relic/agent/tracer.rb#L42-L55 = { partial_name: get_partial_name(method), category: :rack, options: { request: get_request(method, call), filtered_params: filter(request.to_h), } } NewRelic::Agent::Tracer.in_transaction(**) do yield end end |