module Method::Tracer
Public Class Methods
active_span()
click to toggle source
# File lib/method/tracer.rb, line 20 def active_span @active_span end
configure(tracer: OpenTracing.global_tracer, active_span: nil)
click to toggle source
# File lib/method/tracer.rb, line 24 def configure(tracer: OpenTracing.global_tracer, active_span: nil) @tracer = tracer @active_span = active_span end
extended(klazz)
click to toggle source
# File lib/method/tracer.rb, line 12 def extended(klazz) klazz.extend(ClassMethods) end
included(klazz)
click to toggle source
# File lib/method/tracer.rb, line 8 def included(klazz) klazz.extend(ClassMethods) end
method_tracer()
click to toggle source
# File lib/method/tracer.rb, line 16 def method_tracer @tracer || (raise ConfigError.new("Please configure the tracer using Method::Tracer.configure method")) end
trace(operation_name, tracer: method_tracer, **args) { |current_span| ... }
click to toggle source
# File lib/method/tracer.rb, line 29 def trace(operation_name, tracer: method_tracer, **args, &block) parent_span = args.include?(:child_of) ? args[:child_of] : active_span args[:child_of] = parent_span.respond_to?(:call) ? parent_span.call : parent_span current_span = tracer.start_span(operation_name, **args) yield current_span rescue Exception => e if current_span current_span.set_tag('error', true) current_span.log(event: 'error', :'error.object' => e) end raise ensure current_span.finish if current_span end
trace_method(klazz, method_name, **args, &block)
click to toggle source
# File lib/method/tracer.rb, line 46 def trace_method(klazz, method_name, **args, &block) trace("#{klazz.to_s}##{method_name.to_s}", **args, &block) end