lib/ddtrace/tracer.rb in ddtrace-0.47.0 vs lib/ddtrace/tracer.rb in ddtrace-0.48.0

- old
+ new

@@ -8,10 +8,11 @@ require 'ddtrace/writer' require 'ddtrace/runtime/identity' require 'ddtrace/sampler' require 'ddtrace/sampling' require 'ddtrace/correlation' +require 'ddtrace/event' require 'ddtrace/utils/only_once' # \Datadog global namespace that includes all tracing functionality for Tracer and Span classes. module Datadog # A \Tracer keeps track of the time spent by an application processing a single operation. For @@ -313,10 +314,14 @@ else start_span(name, options) end end + def trace_completed + @trace_completed ||= TraceCompleted.new + end + # Record the given +context+. For compatibility with previous versions, # +context+ can also be a span. It is similar to the +child_of+ argument, # method will figure out what to do, submitting a +span+ for recording # is like trying to record its +context+. def record(context) @@ -364,9 +369,25 @@ PP.pp(trace, str) Datadog.logger.debug(str) end @writer.write(trace) + trace_completed.publish(trace) + end + + # Triggered whenever a trace is completed + class TraceCompleted < Datadog::Event + def initialize + super(:trace_completed) + end + + # NOTE: Ignore Rubocop rule. This definition allows for + # description of and constraints on arguments. + # rubocop:disable Lint/UselessMethodDefinition + def publish(trace) + super(trace) + end + # rubocop:enable Lint/UselessMethodDefinition end # TODO: Move this kind of configuration building out of the tracer. # Tracer should not have this kind of knowledge of writer. # rubocop:disable Metrics/PerceivedComplexity