Class: Gruf::Rollbar::ClientInterceptor

Inherits:
Interceptors::ClientInterceptor
  • Object
show all
Includes:
ErrorParser
Defined in:
lib/gruf/rollbar/client_interceptor.rb

Overview

Intercepts outbound calls to provide Rollbar reporting

Instance Method Summary collapse

Methods included from ErrorParser

#code_for, #error?, #error_classes

Instance Method Details

#call(request_context:) ⇒ Object

Parameters:

  • (Gruf::Outbound::RequestContext)


14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/gruf/rollbar/client_interceptor.rb', line 14

def call(request_context:)
  return yield if Gruf::Rollbar.ignore_methods.include?(request_context.method_name)

  begin
    yield
  rescue StandardError, GRPC::BadStatus => e
    if error?(e) # only capture
      ::Rollbar.scoped({
                         grpc_method_name: request_context.method_name,
                         grpc_route_key: request_context.route_key,
                         grpc_call_type: request_context.type,
                         grpc_error_code: code_for(e),
                         grpc_error_class: e.class.name
                       }) do
        ::Rollbar.error(e)
      end
    end
    raise # passthrough
  end
end