class THTP::Server::Instrumentation::Sentry
Captures exceptions to Sentry
Public Class Methods
@param raven [Raven] A Sentry
client instance, or something that acts like one
# File lib/thtp/server/instrumentation.rb, line 196 def initialize(raven) @raven = raven end
Public Instance Methods
An unknown error occurred @param request [Rack::Request] The inbound HTTP request @param error [Exception] The to-be-serialized exception @param time [Integer] Milliseconds of execution wall time
# File lib/thtp/server/instrumentation.rb, line 214 def internal_error(request:, error:, time:) @raven.capture_exception(error, **http_context(request)) end
Handler raised an unexpected error @param request [Rack::Request] The inbound HTTP request @param rpc [Symbol] The name of the RPC @param args [Thrift::Struct?] The deserialized thrift args @param error [THTP::ServerError] The to-be-serialized exception @param time [Integer] Milliseconds of execution wall time
# File lib/thtp/server/instrumentation.rb, line 206 def rpc_error(request:, rpc:, args:, error:, time:) @raven.capture_exception(error, **rpc_context(request, rpc, args)) end
Private Instance Methods
subclass and override if desired @param rack_request [Rack::Request] The inbound HTTP request
# File lib/thtp/server/instrumentation.rb, line 222 def http_context(rack_request) { user: { ip: rack_request.ip, user_agent: rack_request.user_agent }, extra: {}, } end
subclass and override if desired @param rack_request [Rack::Request] The inbound HTTP request @param rpc [Symbol] The name of the RPC @param args [Thrift::Struct] The deserialized thrift args
# File lib/thtp/server/instrumentation.rb, line 233 def rpc_context(rack_request, rpc, _args) http_context(rack_request).tap do |context| context[:extra].merge!(rpc: rpc) end end