-
Notifications
You must be signed in to change notification settings - Fork 375
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
unable to disable log_injection #2542
Comments
👋 @Kallin , thanks for reporting! I have taken sometime looking into this. Unfortunately, I was not able to reproduce your case(with the Ruby 2.7 and Rails 6).
I am able to control the behaviour by toggling However, I understand the logger's behaviour is highly configurable in Rails ( Our tracer leverage the
I wonder what is the result of yours? |
I am also seeing this: c.tracing.log_injection = false does not disable the log tags for me as well in the I verified that the following tag exists during a controller action in (ruby) Rails.logger.formatter.current_tags
["dd.env=development dd.service=REDACTED dd.trace_id=REDACTED dd.span_id=0"] Using ddtrace 1.8.0 To fix this, I added: # remove once https://github.com/DataDog/dd-trace-rb/issues/2542 is fixed
Datadog.configuration.tracing.log_injection = false to the top of my |
👋 @thomasdziedzic-calmwave Could you provide me your version for ruby and rails ? I could try to reproduce with such your description |
I'm using ruby 3.1.3 and rails 7.0.4 I created a repo that reproduces the issue at https://github.com/thomasdziedzic-calmwave/ddtrace_issue_2542 thomasdziedzic-calmwave/ddtrace_issue_2542@e01b85f reproduces the issue for example:
thomasdziedzic-calmwave/ddtrace_issue_2542@c45537c is my current workaround to disable these log tags to repro, remove the workaround, and run bin/rails s, visit localhost:3000/home/index and see that the tags are attached from ddtrace even when the initializer has log_injection turned off. to see the workaround in action, run the same commands, but with the workaround left in place in development.rb |
👋 @thomasdziedzic-calmwave, Thanks for your awesome repository for reproducing this issue. I am able to reproduce with the example and I believe it is related to the way we provide auto instrumentation.
Our auto instrumentation leverage railtie to hook into initialization process, even before loading initializers (where log injection being overwritten to With auto instrumentation, I would recommend providing an environment variable
Let me know if it helps 😄 |
Is there a reason that the auto instrumentation injects the log tags so early? |
Any reason https://github.com/DataDog/dd-trace-rb/blob/master/lib/datadog/tracing/contrib/rails/patcher.rb#L45 can't be pulled out of the before_initialize? I think it's a bit much to ask everyone to always add @thomasdziedzic-calmwave, thanks for the suggestion, I'll try that workaround in the interim. And thanks everyone for looking into this! |
👋 @Kallin @thomasdziedzic-calmwave , I think the assumption for configuring the behaviour in the initializer make sense. We will be working on to improve this, in the meanwhile, adding |
ℹ️ I tried to address this by removing tags based on proc source location since there is no easy way to provide ENV vars in related project. Looking for proper solution as well. 🙏 original_tags = Array.wrap(Rails.application.config.log_tags).reject! { |tag| tag&.source_location&.include?('datadog') }
Rails.application.config.log_tags = original_tags |
Current behaviour
logs include dd_trace details, like
even though
Datadog.configuration.tracing.log_injection
is set to false.Expected behaviour
Datadog.configuration.tracing.log_injection
should be respectedSteps to reproduce
set
Datadog.configuration.tracing.log_injection
to true, observe logs still contain the trace details.Environment
Datadog.configure ...
):** further **
This seems to be due to this code, https://github.com/DataDog/dd-trace-rb/blob/master/lib/datadog/tracing/contrib/rails/patcher.rb#L45 , which runs before any of the configuration values can be set.
All I'm trying to do here is keep the logs less cluttered for development. Is there a recommended way to disable datadog for development? Should I just do it at the gemfile level?
The text was updated successfully, but these errors were encountered: