Module: Bigcommerce::Lightstep::Traceable::ClassMethods
- Defined in:
- lib/bigcommerce/lightstep/traceable.rb
Overview
Extend the class with the tracing methods.
Instance Method Summary collapse
-
#trace(method_name, operation_name, tags: nil, &span_block) ⇒ Object
Trace the perform method for the command with the given operation name as the span name.
Instance Method Details
#trace(method_name, operation_name, tags: nil, &span_block) ⇒ Object
Trace the perform method for the command with the given operation name as the span name
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/bigcommerce/lightstep/traceable.rb', line 41 def trace(method_name, operation_name, tags: nil, &span_block) method_name = method_name.to_sym mod = Module.new mod.define_method(method_name) do |args, &block| tracer = ::Bigcommerce::Lightstep::Tracer.instance tracer.start_span(operation_name) do |span| &.each { |k, v| span.set_tag(k.to_s, v) } span_block&.send(:call, **args.merge(span: span)) begin super(**args, &block) rescue StandardError => e span.set_tag('error', true) span.set_tag('error.message', e.) span.set_tag('error.class', e.class.to_s) raise end end end prepend(mod) end |