-
Notifications
You must be signed in to change notification settings - Fork 377
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Performance / Logging when Agent is Not Available #53
Comments
Thank you @msaffitz to report this issue! We're working to write better (but more important) useful logs from our tracing clients. We'll provide a fix as soon as possible! |
@msaffitz we could provide a patch for a "generic" Rails application so that it could detect the production mode if default environments are used (using something like # config/initializers/datadog-tracer.rb (or whatever)
# this is just an example and you can change it with a func or anything else
tracing_state = Rails.env.production?
Rails.configuration.datadog_trace = {
enabled: tracing_state,
auto_instrument: tracing_state,
auto_instrument_redis: tracing_state,
# ... and other settings if you have them
} Later on, we'll address other things like the exponential backoff / spammy logs in case of an agent failure in a production environment. Is it a reasonable default / approach that works for you? |
@msaffitz we've merged #55 so that Rails is disabled by default in the next release. This means that you have to follow the snippet in the PR description if you're going to use the Closing that for now but feel free to continue the discussion with more ideas! |
Hi everyone, Is it possible that this fix isn't fixing anything? I've fought with this locally on my dev environment for about 30 minutes and decided to look into the lib to see what was happening. On require there's an object that gets initialized: https://github.com/DataDog/dd-trace-rb/blob/master/lib/ddtrace.rb#L7 That completely disregards the config, of note no options are passed to it. That in turn goes to init a writer that has no options passed to it: https://github.com/DataDog/dd-trace-rb/blob/master/lib/ddtrace/tracer.rb#L46 Which does what it's supposed to and ultimately tries to connect to the agent that isn't there and we get log spammed with I've tried from above and in #55:
I'm sure this does something it does nothing about the problem of having Let me know what I am missing or if I should open a PR to fix it. Thanks! |
Just started using this agent while testing out APM. I'm seeing the
I can reproduce the error running the Rails console in this environment:
|
Is this maybe a workaround? I've managed to turn off the connection attempts and log spam by only requiring the # Gemfile
gem 'ddtrace', require: false # config/initializers/datadog_tracer.rb
if ENV['DATADOG_TRACER_ENABLED'] && ENV['DATADOG_TRACER_ENABLED'] == 'true'
require 'ddtrace'
Rails.configuration.datadog_trace =
{
auto_instrument: true,
auto_instrument_redis: true
}
end |
@robbkidd Yes that's how I fixed it too. |
Is logging the issue or is it a symptom of connection attempts being made even when the tracer is disabled? |
I tried to only require if its enabled like robbkidd suggests, but we want to do custom instrumentation so if the Datadog object isnt defined it will fail for any of those. Seeing something get enqueued after we set datadog_trace config but before its actually disabled when using sidekiq |
#86 should remove the root cause about Redis sending traces despite defined settings. A configuration like: Rails.configuration.datadog_trace =
{
# may depend by your conditional env
enabled: false,
# these may be 'true' to keep parity with your production
auto_instrument: true,
auto_instrument_redis: true
} ensures that:
|
We've released a new gem version that should handle this issue: https://github.com/DataDog/dd-trace-rb/releases/tag/v0.5.0 @robbkidd think it should fix your problems, let us know if it doesn't! |
@FinnBorge can you provide me more details? Actually what is your stack (Rails + Sidekiq?) and what is your |
My mistake @palazzem, misread the history of this.
works fine. |
oh no worries @FinnBorge ! thank you anyway for reporting that! Actually if the |
I'm having this issue because, despite My current config that doesn't have this problem is: require "net/http"
require "ddtrace"
app_name = Rails.application.class.parent.name
is_rails_console = Rails.const_defined?("Console")
dd_tracing_enabled = ENV.has_key?("DD_AGENT_PORT_8126_TCP_ADDR") && !is_rails_console
Datadog::Monkey.patch_all if dd_tracing_enabled
Rails.configuration.datadog_trace = {
enabled: dd_tracing_enabled,
auto_instrument: true,
auto_instrument_redis: true,
default_controller_service: "rails-controller-#{app_name}",
default_cache_service: "rails-cache-#{app_name}",
default_database_service: "postgresql-#{app_name}",
default_service: app_name,
trace_agent_hostname: ENV["DD_AGENT_PORT_8126_TCP_ADDR"],
trace_agent_port: ENV["DD_AGENT_PORT_8126_TCP_PORT"]
} |
Thanks @davetron5000 for sharing your working configuration. It's possible that the problem is more related to the fact that This may create traces (and so logs if the agent is not available) when libraries such as Redis, Mongoid, or others, are initialized and used before our initializer is invoked (and so the tracer is disabled). If you want, you can open a new issue on GitHub posting your current state, so we can keep track of it providing better documentation or a different approach for it. Thanks! |
I'm still seeing this issue even without calling # config/initializers/datadog_tracer.rb
Rails.configuration.datadog_trace = {
enabled: false,
auto_instrument: false,
} and yet I'm still seeing
all over my development server console. Any ideas as to where I may be going wrong here? |
Hey @stevenleeg , what version of the gem are you using? As of 0.11.0, we added a new configuration API that replaced the old In the new implementation, integrations shouldn't be automatically enabled/patched; you're expected to define each integration you'd like to trace explicitly (otherwise they won't be activated.) E.g to activate rails, it looks something like: Datadog.configure do |c|
c.use :rails
end This new configuration API is supposed to replace the use of However, in version 0.11.0, despite All in all... maybe try our latest version 0.11.2, and see if it addresses your issue? If you still have code using our older configuration style, you'll need to follow our migration guide [listed here]((https://github.com/DataDog/dd-trace-rb/releases/tag/v0.11.0) to be compatible. Let me know if that helps or not! |
Ahh yes! Looks like I was following some outdated documentation rather than the latest on this repository. For those of you following along at home, this configuration ended up fixing things for me: # config/initializers/datadog_tracer.rb
Datadog.configure do |c|
c.tracer enabled: Rails.env.production?
c.use :rails
c.use :active_record
end Once that was in place I was able to spin up a development server without the annoying log noise and deploy to production with tracing. 🎆 |
Glad to hear it's working for you! 😄 Where did you see the outdated documentation? Maybe we should update that. |
I was following this documentation - https://elements.heroku.com/buildpacks/datadog/heroku-buildpack-datadog, realised now that it was outdated 😅 |
@rashmi-tondare Ahhh, thanks for letting us know! I think it should be updated now on the buildpack repo, and on Heroku soon. |
@delner awesome! thank you 🙂 |
When the agent is not available we see huge numbers of log lines of the form:
Connection refused - connect(2) for "localhost" port 7777
(For example, we see this in our test environment and it seems that the tests run much more slowly and/or timeout as a result. I'd expect the Rails integration to no-op in any environment other than production.)
The text was updated successfully, but these errors were encountered: