Module: Datadog::Tracing::Contrib::Racecar::Event::ClassMethods

Defined in:
lib/datadog/tracing/contrib/racecar/event.rb

Overview

Class methods for Racecar events. Note, they share the same process method and before_trace method.

Instance Method Summary collapse

Instance Method Details

#configurationObject



32
33
34
# File 'lib/datadog/tracing/contrib/racecar/event.rb', line 32

def configuration
  Datadog.configuration.tracing[:racecar]
end

#on_start(span, event, _id, payload) ⇒ Object



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/datadog/tracing/contrib/racecar/event.rb', line 36

def on_start(span, event, _id, payload)
  span.service = configuration[:service_name]
  span.resource = payload[:consumer_class]

  span.set_tag(Contrib::Ext::Messaging::TAG_SYSTEM, Ext::TAG_MESSAGING_SYSTEM)
  span.set_tag(Tracing::Metadata::Ext::TAG_COMPONENT, Ext::TAG_COMPONENT)

  # Set analytics sample rate
  if Contrib::Analytics.enabled?(configuration[:analytics_enabled])
    Contrib::Analytics.set_sample_rate(span, configuration[:analytics_sample_rate])
  end

  # Measure service stats
  Contrib::Analytics.set_measured(span)

  # Tag original global service name if not used
  if span.service != Datadog.configuration.service
    span.set_tag(Tracing::Contrib::Ext::Metadata::TAG_BASE_SERVICE, Datadog.configuration.service)
  end

  span.set_tag(Ext::TAG_TOPIC, payload[:topic])
  span.set_tag(Ext::TAG_CONSUMER, payload[:consumer_class])
  span.set_tag(Ext::TAG_PARTITION, payload[:partition])
  span.set_tag(Ext::TAG_OFFSET, payload[:offset]) if payload.key?(:offset)
  span.set_tag(Ext::TAG_FIRST_OFFSET, payload[:first_offset]) if payload.key?(:first_offset)
  span.set_tag(Ext::TAG_MESSAGE_COUNT, payload[:message_count]) if payload.key?(:message_count)
  span.set_error(payload[:exception_object]) if payload[:exception_object]
end

#span_optionsObject



28
29
30
# File 'lib/datadog/tracing/contrib/racecar/event.rb', line 28

def span_options
  { service: configuration[:service_name] }
end

#subscription(*args, **kwargs) ⇒ Object



22
23
24
25
26
# File 'lib/datadog/tracing/contrib/racecar/event.rb', line 22

def subscription(*args, **kwargs)
  super.tap do |subscription|
    subscription.before_trace { ensure_clean_context! }
  end
end