Class: Rabbitek::Client::Hooks::OpenTracing

Inherits:
Rabbitek::ClientHook show all
Defined in:
lib/rabbitek/client/hooks/opentracing.rb

Overview

OpenTracing client hook

Instance Method Summary collapse

Instance Method Details

#call(payload, params) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/rabbitek/client/hooks/opentracing.rb', line 11

def call(payload, params)
  result = nil

  ::OpenTracing.start_active_span(params[:routing_key], opentracing_options(params)) do |scope|
    params[:headers] ||= {}
    Utils::OpenTracing.inject!(scope.span, params[:headers])

    result = super
  rescue StandardError => e
    raise unless scope.span

    Utils::OpenTracing.log_error(scope.span, e)
    raise
  end

  result
end

#opentracing_options(params) ⇒ Object



29
30
31
# File 'lib/rabbitek/client/hooks/opentracing.rb', line 29

def opentracing_options(params)
  Utils::OpenTracing.client_options(params)
end