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

Add dynamic config support for log injection #5221

Merged
merged 31 commits into from
Jun 26, 2023

Conversation

randomanderson
Copy link
Contributor

@randomanderson randomanderson commented May 16, 2023

What Does This Do

Supports dynamic config with log injection. There are 3 main changes:

1. Instrumentation enable/disable is no longer controlled by the log injection flag
For "reasons", log injection was special-cased to also control instrumentation enable/disable. In order to support dynamic config, the instrumentations need to be enabled. We already have a separate mechanism for disabling instrumentations

2. "Event Instrumentation"s are wrapped in config checks
These are the parts of the instrumentations where the AgentContext is store in an InstrumentationContext. With this PR, the instrumentation is skipped if log injection is not enabled (or TraceConfig is null meaning a NOOP span)

3. MDC operations are wrapped in config checks
These are parts of the instrumentations that might not occur during a span (the LogAppender writing an event). With these instrumentations, the PR checks if a context was stored (meaning log injection was enabled when the log message was created) or if log injection is enabled at the tracer level.

Testing

The smoke tests test:
enabled by default -> disabled by remote config -> reenabled by remote config reset.

@randomanderson randomanderson added the tag: do not merge Do not merge changes label May 16, 2023
@pr-commenter
Copy link

pr-commenter bot commented May 16, 2023

Benchmarks

Parameters

Baseline Candidate
commit 1.17.0-SNAPSHOT~c8861df65a 1.17.0-SNAPSHOT~fb30ab5d21
config baseline candidate
See matching parameters
Baseline Candidate
module Agent Agent
parent None None

Summary

Found 0 performance improvements and 0 performance regressions! Performance is the same for 22 cases.

…ogs-wip

# Conflicts:
#	dd-java-agent/instrumentation/jboss-logmanager/src/main/java/datadog/trace/instrumentation/jbosslogmanager/ExtLogRecordInstrumentation.java
#	dd-java-agent/instrumentation/log4j1/src/main/java/datadog/trace/instrumentation/log4j1/LoggingEventInstrumentation.java
#	dd-java-agent/instrumentation/logback-1/src/main/java/datadog/trace/instrumentation/logback/LoggingEventInstrumentation.java
#	internal-api/src/main/java/datadog/trace/api/InstrumenterConfig.java
@randomanderson randomanderson force-pushed the landerson/dynamic-logs-wip branch 2 times, most recently from 6f2f0f2 to f0c049e Compare May 22, 2023 21:06
@randomanderson randomanderson force-pushed the landerson/dynamic-logs-wip branch from f0c049e to 5f59ab7 Compare May 22, 2023 21:09
…ogs-wip

# Conflicts:
#	dd-trace-core/src/main/java/datadog/trace/core/CoreTracer.java
# Conflicts:
#	dd-trace-core/src/main/java/datadog/trace/core/TracingConfigPoller.java
#	internal-api/src/main/java/datadog/trace/api/DynamicConfig.java
…ogs-wip

# Conflicts:
#	dd-smoke-tests/dynamic-config/build.gradle
#	dd-smoke-tests/dynamic-config/src/test/groovy/datadog/smoketest/DynamicServiceMappingSmokeTest.groovy
#	dd-trace-core/src/main/java/datadog/trace/core/TracingConfigPoller.java
#	internal-api/src/main/java/datadog/trace/api/DynamicConfig.java
@randomanderson randomanderson removed the tag: do not merge Do not merge changes label Jun 20, 2023
@randomanderson randomanderson marked this pull request as ready for review June 20, 2023 20:02
@randomanderson randomanderson requested a review from a team as a code owner June 20, 2023 20:02
Copy link
Contributor

@bantonsson bantonsson left a comment

Choose a reason for hiding this comment

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

Looks good, but I would like some null check guards unless I missed something.

@mcculls
Copy link
Contributor

mcculls commented Jun 21, 2023

Heads-up that I'm adding the rest of the dynamic-config plumbing in #5437 - once that's merged you'll be able to simplify this PR to just the pieces that act on the dynamic-config

…ogs-wip

# Conflicts:
#	dd-trace-core/src/main/java/datadog/trace/core/CoreTracer.java
#	dd-trace-core/src/main/java/datadog/trace/core/TracingConfigPoller.java
#	internal-api/src/main/java/datadog/trace/api/DynamicConfig.java
#	internal-api/src/main/java/datadog/trace/api/TraceConfig.java
@@ -63,6 +63,7 @@ tasks.named('processLoggingResources').configure {


dependencies {
implementation project(path: ':dd-trace-ot', configuration: 'shadow')
Copy link
Contributor

Choose a reason for hiding this comment

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

I wasn't able to see where dd-trace-ot is required in the tests - is this extra dependency still needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's there to be able to get a reference to ConfigCollector which is how I test in the application that the config was updated. (ConfigCollector is in internal-api). It's a bit of a hack but I didn't want to go down the path of exposing a public api for dynamic config

Copy link
Contributor

Choose a reason for hiding this comment

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

Understood, thanks for the explanation

Copy link
Contributor

@mcculls mcculls left a comment

Choose a reason for hiding this comment

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

LGTM - just some minor cleanup to do before merging

@randomanderson randomanderson force-pushed the landerson/dynamic-logs-wip branch from 2b3376e to fb30ab5 Compare June 26, 2023 19:12
@randomanderson randomanderson merged commit 103ef92 into master Jun 26, 2023
@randomanderson randomanderson deleted the landerson/dynamic-logs-wip branch June 26, 2023 20:53
@github-actions github-actions bot added this to the 1.17.0 milestone Jun 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants