module Datadog::Contrib::ActiveRecord::Events::Instantiation
Defines instrumentation for instantiation.active_record event
Constants
- EVENT_NAME
Public Instance Methods
event_name()
click to toggle source
# File lib/ddtrace/contrib/active_record/events/instantiation.rb, line 22 def event_name self::EVENT_NAME end
process(span, event, _id, payload)
click to toggle source
# 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 # 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_name()
click to toggle source
# File lib/ddtrace/contrib/active_record/events/instantiation.rb, line 26 def span_name Ext::SPAN_INSTANTIATION end
supported?()
click to toggle source
# 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