Class: Gruf::Lightstep::ClientInterceptor

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

Overview

Intercepts outbound calls to provide LightStep tracing

Instance Method Summary collapse

Instance Method Details

#call(request_context:) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/gruf/lightstep/client_interceptor.rb', line 24

def call(request_context:)
  span = active_span
  if span
    span_data = span.to_h
    logger.debug "[gruf-lightstep] Injecting current active span #{span_data[:span_guid]} into outbound request context for #{request_context.method_name}"
    request_context.['ot-tracer-spanid'] = span_data[:span_guid].to_s
    request_context.['ot-tracer-traceid'] = span_data[:trace_guid].to_s
    request_context.['ot-tracer-sampled'] = '1'
  end

  yield
end