Skip to content
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

Allow for dynamic log injection configuration #2992

Merged
merged 3 commits into from
Jul 25, 2023
Merged

Conversation

marcotc
Copy link
Member

@marcotc marcotc commented Jul 22, 2023

Fixes #2542

As part of Dynamic Configuration, we want to allow users to enable or disable log injection at any time.

The main limitation we have in Ruby Tracing is that we need to patch an integration to enable log injection.

This PR enables all integrations that perform log correlation to always inject the correlation patch methods, but allow it to be safely disabled when Datadog.configuration.tracing.log_injection is set to false at runtime.

Rails, for example, was making decision at the application startup that couldn't be changed later. This PR addresses that.

We still depend on users having instrumented the integration itself for correlation to work.

Our SemanticLogger and Lograge integrations already support dynamic configuration of log injection; only Rails core logger and ActiveJob logging needed changes.

@marcotc marcotc self-assigned this Jul 22, 2023
@marcotc marcotc added this to the 1.13.0 milestone Jul 22, 2023
@github-actions github-actions bot added integrations Involves tracing integrations tracing labels Jul 22, 2023

# `after_initialize` will respect the configuration from `config/initializers/datadog.rb`
# and add tags to `::ActiveSupport::TaggedLogging`
add_tags_to_logger(app) if Datadog.configuration.tracing.log_injection
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't have to try to inject tag logs at the after_initialize stage anymore because we always inject a safe injection proc early, at before_initialize.
This simplifies our logic quite a bit.

@marcotc marcotc marked this pull request as ready for review July 24, 2023 23:34
@marcotc marcotc requested a review from a team July 24, 2023 23:34
@github-actions github-actions bot added appsec Application Security monitoring product core Involves Datadog core libraries labels Jul 25, 2023
@marcotc marcotc merged commit 0347e6b into master Jul 25, 2023
@marcotc marcotc deleted the log-config-dynamic branch July 25, 2023 18:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
appsec Application Security monitoring product core Involves Datadog core libraries integrations Involves tracing integrations tracing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

unable to disable log_injection
2 participants