Class: Gruf::Zipkin::Interceptor

Inherits:
Interceptors::ServerInterceptor
  • Object
show all
Defined in:
lib/gruf/zipkin/interceptor.rb

Overview

Intercepts calls to provide Zipkin tracing

Instance Method Summary collapse

Instance Method Details

#call(&block) ⇒ Object

Handle the gruf around hook and trace sampled requests



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/gruf/zipkin/interceptor.rb', line 25

def call(&block)
  # do this here to ensure the tracer is initialized before the trace block. Zipkin's library has poor OOE support
  tr = tracer

  trace = build_trace
  if trace && trace.sampled?
    result = nil
    ::ZipkinTracer::TraceContainer.with_trace_id(trace.trace_id) do
      result = trace.trace!(tr, &block)
    end
  else
    result = yield
  end
  result
end