Module: Datadog::Contrib::ActiveRecord::Events::Instantiation
- Includes:
- Datadog::Contrib::ActiveRecord::Event
- Defined in:
- lib/ddtrace/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
- .event_name ⇒ Object
- .process(span, event, _id, payload) ⇒ Object
- .span_name ⇒ Object
- .supported? ⇒ Boolean
Methods included from Datadog::Contrib::ActiveRecord::Event
Class Method Details
.event_name ⇒ Object
23 24 25 |
# File 'lib/ddtrace/contrib/active_record/events/instantiation.rb', line 23 def event_name self::EVENT_NAME end |
.process(span, event, _id, payload) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/ddtrace/contrib/active_record/events/instantiation.rb', line 31 def process(span, event, _id, payload) # Inherit service name from parent, if available. span.service = if configuration[:orm_service_name] configuration[:orm_service_name] elsif span.parent span.parent.service else Ext::SERVICE_NAME end span.resource = payload.fetch(:class_name) span.span_type = Ext::SPAN_TYPE_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.) end |
.span_name ⇒ Object
27 28 29 |
# File 'lib/ddtrace/contrib/active_record/events/instantiation.rb', line 27 def span_name Ext::SPAN_INSTANTIATION end |
.supported? ⇒ Boolean
18 19 20 21 |
# File 'lib/ddtrace/contrib/active_record/events/instantiation.rb', line 18 def supported? Gem.loaded_specs['activerecord'] \ && Gem.loaded_specs['activerecord'].version >= Gem::Version.new('4.2') end |