Module: Datadog::Contrib::Rails::Framework
- Defined in:
- lib/ddtrace/contrib/rails/framework.rb
Overview
Rails framework code, used to essentially:
-
handle configuration entries which are specific to Datadog tracing
-
instrument parts of the framework when needed
Class Method Summary collapse
- .activate_active_record!(config) ⇒ Object
- .activate_rack!(config) ⇒ Object
- .config_with_defaults ⇒ Object
-
.setup ⇒ Object
configure Datadog settings.
Class Method Details
.activate_active_record!(config) ⇒ Object
57 58 59 60 61 62 63 64 65 |
# File 'lib/ddtrace/contrib/rails/framework.rb', line 57 def self.activate_active_record!(config) return unless defined?(::ActiveRecord) Datadog.configuration.use( :active_record, service_name: config[:database_service], tracer: config[:tracer] ) end |
.activate_rack!(config) ⇒ Object
46 47 48 49 50 51 52 53 54 55 |
# File 'lib/ddtrace/contrib/rails/framework.rb', line 46 def self.activate_rack!(config) Datadog.configuration.use( :rack, tracer: config[:tracer], application: ::Rails.application, service_name: config[:service_name], middleware_names: config[:middleware_names], distributed_tracing: config[:distributed_tracing] ) end |
.config_with_defaults ⇒ Object
35 36 37 38 39 40 41 42 43 44 |
# File 'lib/ddtrace/contrib/rails/framework.rb', line 35 def self.config_with_defaults # We set defaults here instead of in the patcher because we need to wait # for the Rails application to be fully initialized. Datadog.configuration[:rails].tap do |config| config[:service_name] ||= Utils.app_name config[:database_service] ||= "#{config[:service_name]}-#{Contrib::ActiveRecord::Utils.adapter_name}" config[:controller_service] ||= config[:service_name] config[:cache_service] ||= "#{config[:service_name]}-cache" end end |
.setup ⇒ Object
configure Datadog settings
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/ddtrace/contrib/rails/framework.rb', line 24 def self.setup config = config_with_defaults activate_rack!(config) activate_active_record!(config) # By default, default service would be guessed from the script # being executed, but here we know better, get it from Rails config. config[:tracer].default_service = config[:service_name] end |