class Gruf::Sentry::ServerInterceptor

Intercepts inbound calls to provide Sentry error reporting

Public Instance Methods

call() { || ... } click to toggle source

Handle the gruf around hook and capture errors

# File lib/gruf/sentry/server_interceptor.rb, line 29
def call(&_block)
  return yield if Gruf::Sentry.ignore_methods.include?(request.method_name)

  begin
    yield
  rescue StandardError, GRPC::BadStatus => e
    if error?(e) # only capture
      ::Sentry.configure_scope do |scope|
        scope.set_transaction_name(request.service_key)
        scope.set_tags(grpc_method: request.method_key,
                       grpc_request_class: request.request_class.name,
                       grpc_service_key: request.service_key,
                       grpc_error_code: code_for(e),
                       grpc_error_class: e.class.name)
      end
      ::Sentry.capture_exception(e)
    end
    raise # passthrough
  end
end

Private Instance Methods

request_message_params() click to toggle source

@return [Hash]

# File lib/gruf/sentry/server_interceptor.rb, line 55
def request_message_params
  return {} if request.client_streamer? || !request.message.respond_to?(:to_h)

  request.message.to_h
end