Class: Gruf::Lightstep::ServerInterceptor
- Inherits:
-
Interceptors::ServerInterceptor
- Object
- Interceptors::ServerInterceptor
- Gruf::Lightstep::ServerInterceptor
- Defined in:
- lib/gruf/lightstep/server_interceptor.rb
Overview
Intercepts inbound calls to provide LightStep tracing
Constant Summary collapse
- DEFAULT_ERROR_CLASSES =
%w[GRPC::Unknown GRPC::Internal GRPC::DataLoss GRPC::FailedPrecondition GRPC::Unavailable GRPC::DeadlineExceeded GRPC::Cancelled].freeze
Instance Method Summary collapse
-
#call(&_block) ⇒ Object
Handle the gruf around hook and trace sampled requests.
Instance Method Details
#call(&_block) ⇒ Object
Handle the gruf around hook and trace sampled requests
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/gruf/lightstep/server_interceptor.rb', line 29 def call(&_block) return yield if ignore_methods.include?(request.method_name) result = nil params = tracer = ::Bigcommerce::Lightstep::Tracer.instance tracer.clear_active_span! # because we're always starting from the top on a gRPC boundary tracer.start_span(request.method_name, context: request_method.headers.to_h) do |span| span.set_tag('grpc.method', request.method_key) span.set_tag('grpc.request_class', request.request_class) span.set_tag('grpc.service', request.service_key) span.set_tag('span.kind', 'server') allowlist.each do |param| span.set_tag(param.to_s, params[param]) if params.key?(param) end begin result = yield rescue StandardError => e span.set_tag('error', error?(e)) span.set_tag('grpc.error', true) span.set_tag('grpc.error_code', code_for(e)) span.set_tag('grpc.error_class', e.class) raise # passthrough, we just want the annotations end end result end |