Sha256: 87c862a888619fef6ee0f30981be6b2996d0a0b936eed91a0c8c02bfbe7233ef
Contents?: true
Size: 1.8 KB
Versions: 4
Compression:
Stored size: 1.8 KB
Contents
# frozen_string_literal: true require_relative '../../../metadata/ext' require_relative '../../analytics' require_relative '../ext' require_relative '../event' module Datadog module Tracing module Contrib module ActiveRecord module Events # Defines instrumentation for instantiation.active_record event module Instantiation include ActiveRecord::Event EVENT_NAME = 'instantiation.active_record' module_function def supported? Gem.loaded_specs['activerecord'] \ && Gem.loaded_specs['activerecord'].version >= Gem::Version.new('4.2') end def event_name self::EVENT_NAME end def span_name Ext::SPAN_INSTANTIATION end def process(span, event, _id, payload) span.resource = payload.fetch(:class_name) 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 end end end end end end
Version data entries
4 entries across 4 versions & 1 rubygems