Module: Datadog::Tracing::Contrib::Rails::Runner::InstrumentedKernel
- Defined in:
- lib/datadog/tracing/contrib/rails/runner.rb
Overview
Instruments the ‘Kernel.load` method, but only for the `Rails::Command::RunnerCommand` class.
Class Method Summary collapse
Class Method Details
.load(*args) ⇒ Object
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/datadog/tracing/contrib/rails/runner.rb', line 79 def self.load(*args) file = args[0] name = Ext::SPAN_RUNNER_FILE resource = file operation = Ext::TAG_OPERATION_FILE begin # Reads one more byte than the limit to allow us to check if the source exceeds the limit. source = File.read(file, MAX_TAG_VALUE_SIZE + 1) rescue => e Datadog.logger.debug("Failed to read file '#{file}' for Rails runner: #{e.}") end Tracing.trace( name, service: Datadog.configuration.tracing[:rails][:service_name], resource: resource, tags: { Tracing::Metadata::Ext::TAG_COMPONENT => Ext::TAG_COMPONENT, Tracing::Metadata::Ext::TAG_OPERATION => operation, } ) do |span| if source span.set_tag( Ext::TAG_RUNNER_SOURCE, Core::Utils.truncate(source, MAX_TAG_VALUE_SIZE) ) end Contrib::Analytics.set_rate!(span, Datadog.configuration.tracing[:rails]) super end end |