Class: Gruf::Sentry::ClientInterceptor

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

Overview

Intercepts outbound calls to provide Sentry 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)


29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/gruf/sentry/client_interceptor.rb', line 29

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

  begin
    yield
  rescue StandardError, GRPC::BadStatus => e
    if error?(e) # only capture
      ::Sentry.capture_exception(
        e,
        message: e.message,
        extra: {
          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
        }
      )
    end
    raise # passthrough
  end
end