Open adrys-lab opened 2 years ago
We have seen this configuration in the source code of ddtrace
# ActiveRecord integration constants
# @public_api Changing resource names, tag names, or environment variables creates breaking changes.
module Ext
ENV_ENABLED = 'DD_TRACE_ACTIVE_RECORD_ENABLED'.freeze
ENV_ANALYTICS_ENABLED = 'DD_TRACE_ACTIVE_RECORD_ANALYTICS_ENABLED'.freeze
ENV_ANALYTICS_SAMPLE_RATE = 'DD_TRACE_ACTIVE_RECORD_ANALYTICS_SAMPLE_RATE'.freeze
SERVICE_NAME = 'active_record'.freeze
SPAN_INSTANTIATION = 'active_record.instantiation'.freeze
SPAN_SQL = 'active_record.sql'.freeze
SPAN_TYPE_INSTANTIATION = 'custom'.freeze
TAG_COMPONENT = 'active_record'.freeze
TAG_OPERATION_INSTANTIATION = 'instantiation'.freeze
TAG_OPERATION_SQL = 'sql'.freeze
TAG_DB_CACHED = 'active_record.db.cached'.freeze
TAG_DB_NAME = 'active_record.db.name'.freeze
TAG_DB_VENDOR = 'active_record.db.vendor'.freeze
TAG_INSTANTIATION_CLASS_NAME = 'active_record.instantiation.class_name'.freeze
TAG_INSTANTIATION_RECORD_COUNT = 'active_record.instantiation.record_count'.freeze
end
and usage
module Datadog
module Tracing
module Contrib
module ActiveRecord
module Configuration
# Custom settings for the ActiveRecord integration
# @public_api
class Settings < Contrib::Configuration::Settings
option :enabled do |o|
o.default { env_to_bool(Ext::ENV_ENABLED, true) }
o.lazy
end
Should we mandatorily add an ENV VAR DD_TRACE_ACTIVE_RECORD_ENABLED = false
? 🤔
Where is this documented ?
👋 sorry for the delay, if you'd like for active_record
and active_support
spans to not be generated, you can remove these lies altogether from your configuration.
- c.tracing.instrument(:active_record, service_name: "#{service}-active-record", enabled: false)
- c.tracing.instrument(:active_support, service_name: "#{service}-active-support", enabled: false)
One caveat is that c.tracing.instrument(:rails)
will activate active_record
and active_support
behind the scenes so you'll have to remove c.tracing.instrument(:rails)
as well. You should then activate only the Rails-related instrumentations that you need.
Here's the exhaustive list of all instrumentations that Rails activates when you do c.tracing.instrument(:rails)
:
rack
action_cable
action_mailer
active_support
action_pack
action_view
active_job
active_record
lograge
semantic_logger
Feel free to pick only the ones you can about, and enable them with c.tracing.instrument(INSTRUMENTATION_NAME_HERE)
.
hey @marcotc thanks for your help as always.
i have found some ENV VARS that allow to disable specific tracing instrumentation without disabling rails
.
DD_TRACE_ACTIVE_RECORD_ENABLED
disables this specific one,
so this worked for me.
DD_TRACE_ACTIVE_RECORD_ENABLED = false
DD_TRACE_ACTIVE_SUPPORT_ENABLED = false
i have found that inspecting directly gem source code, but i think it deserves to be documented in your public rails instrucmentation for the gem 🙏
Current behaviour we would like to disable
active_record
traces cause with the ones frommysql2
is enough for us. Once we try to disable them, they are still appearing with:Meanwhile, if we don't add the instrumentation, they appear with the default service_name as
mysql2
, as documented in the doc: https://docs.datadoghq.com/tracing/trace_collection/dd_libraries/ruby/#active-recordEntire Config file:
Expected behaviour Traces are not appearing anymore.
Environment
ddtrace version: 1.2.0
Configuration block (
Datadog.configure ...
):Ruby version: 3.1.0
Operating system:
Relevant library versions: Rails 6