Module: Datadog::Tracing::Contrib::ActiveRecord::Events::Instantiation

Includes:
Datadog::Tracing::Contrib::ActiveRecord::Event
Defined in:
lib/datadog/tracing/contrib/active_record/events/instantiation.rb

Overview

Defines instrumentation for instantiation.active_record event

Constant Summary collapse

EVENT_NAME =
'instantiation.active_record'.freeze

Class Method Summary collapse

Methods included from Datadog::Tracing::Contrib::ActiveRecord::Event

included

Class Method Details

.event_nameObject



24
25
26
# File 'lib/datadog/tracing/contrib/active_record/events/instantiation.rb', line 24

def event_name
  self::EVENT_NAME
end

.process(span, event, _id, payload) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/datadog/tracing/contrib/active_record/events/instantiation.rb', line 32

def process(span, event, _id, payload)
  span.resource = payload.fetch(:class_name)
  span.span_type = Ext::SPAN_TYPE_INSTANTIATION
  span.set_tag(Tracing::Metadata::Ext::TAG_COMPONENT, Ext::TAG_COMPONENT)
  span.set_tag(Tracing::Metadata::Ext::TAG_OPERATION, Ext::TAG_OPERATION_INSTANTIATION)

  # 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)

  span.set_tag(Ext::TAG_INSTANTIATION_CLASS_NAME, payload.fetch(:class_name))
  span.set_tag(Ext::TAG_INSTANTIATION_RECORD_COUNT, payload.fetch(:record_count))
rescue StandardError => e
  Datadog.logger.debug(e.message)
end

.span_nameObject



28
29
30
# File 'lib/datadog/tracing/contrib/active_record/events/instantiation.rb', line 28

def span_name
  Ext::SPAN_INSTANTIATION
end

.supported?Boolean

Returns:

  • (Boolean)


19
20
21
22
# File 'lib/datadog/tracing/contrib/active_record/events/instantiation.rb', line 19

def supported?
  Gem.loaded_specs['activerecord'] \
    && Gem.loaded_specs['activerecord'].version >= Gem::Version.new('4.2')
end