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
22 23 24 |
# File 'lib/ddtrace/contrib/active_record/events/instantiation.rb', line 22 def event_name self::EVENT_NAME end |
.process(span, event, _id, payload) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/ddtrace/contrib/active_record/events/instantiation.rb', line 30 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 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::Tracer.log.debug(e.) end |
.span_name ⇒ Object
26 27 28 |
# File 'lib/ddtrace/contrib/active_record/events/instantiation.rb', line 26 def span_name Ext::SPAN_INSTANTIATION end |
.supported? ⇒ Boolean
17 18 19 20 |
# File 'lib/ddtrace/contrib/active_record/events/instantiation.rb', line 17 def supported? Gem.loaded_specs['activerecord'] \ && Gem.loaded_specs['activerecord'].version >= Gem::Version.new('4.2') end |