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
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
615734e
Remove defaultEnabled overrides from logger instrumentation
randomanderson May 11, 2023
7c57fc1
Log4j1
randomanderson May 16, 2023
ca33629
Log4j2
randomanderson May 16, 2023
f4feb2c
log4j27
randomanderson May 16, 2023
60c4ace
logback
randomanderson May 16, 2023
3212795
jboss log manager
randomanderson May 16, 2023
3740ff7
initialize logInjectionEnabled
randomanderson May 16, 2023
ab1ed3c
spotless
randomanderson May 16, 2023
f4815d6
some files were missed
randomanderson May 16, 2023
4b84120
fix test
randomanderson May 17, 2023
9de2589
Merge remote-tracking branch 'origin/master' into landerson/dynamic-l…
randomanderson May 22, 2023
5f59ab7
Fix merge issues
randomanderson May 22, 2023
b892d34
Fix test
randomanderson May 22, 2023
98b9ff9
Merge remote-tracking branch 'origin/master' into landerson/dynamic-l…
randomanderson Jun 8, 2023
40c3396
logInjectionEnabled -> logsInjectionEnabled
randomanderson Jun 8, 2023
ab701f1
Add logs injection to the config poller
randomanderson Jun 8, 2023
fc430ce
Merge branch 'master' into landerson/dynamic-logs-wip
randomanderson Jun 9, 2023
bab7ffe
update config collector
randomanderson Jun 9, 2023
b185f56
Add dynamic config smoke test
randomanderson Jun 9, 2023
7e9a597
Smoke tests
randomanderson Jun 9, 2023
0424310
Decrease intervals to speed up test
randomanderson Jun 20, 2023
204a87c
Merge remote-tracking branch 'origin/master' into landerson/dynamic-l…
randomanderson Jun 20, 2023
6e27789
Update to new schema
randomanderson Jun 20, 2023
3f87ab2
give more time for application start
randomanderson Jun 20, 2023
798f477
Merge remote-tracking branch 'origin/master' into landerson/dynamic-l…
randomanderson Jun 21, 2023
0462cc4
PR comments
randomanderson Jun 21, 2023
1a486bc
merge issues
randomanderson Jun 21, 2023
422b50d
PR comments
randomanderson Jun 22, 2023
9b6573b
Try running with profiling disabled
randomanderson Jun 23, 2023
1d56a6d
actually disable profiling
randomanderson Jun 26, 2023
fb30ab5
Use parallel execution for log smoke tests
randomanderson Jun 26, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
logInjectionEnabled -> logsInjectionEnabled
  • Loading branch information
randomanderson committed Jun 8, 2023
commit 40c3396c20cb5466bf9d9a1ee955d7583904550a
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public void afterScopeActivated() {}
@Override
public void afterScopeActivated(
DDTraceId traceId, long localRootSpanId, long spanId, TraceConfig traceConfig) {
if (traceConfig != null && traceConfig.isLogInjectionEnabled()) {
if (traceConfig != null && traceConfig.isLogsInjectionEnabled()) {
add(CorrelationIdentifier.getTraceIdKey(), CorrelationIdentifier.getTraceId());
add(CorrelationIdentifier.getSpanIdKey(), CorrelationIdentifier.getSpanId());
bantonsson marked this conversation as resolved.
Show resolved Hide resolved
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public static void getMdcValue(
InstrumentationContext.get(ExtLogRecord.class, AgentSpan.Context.class).get(record);

// Nothing to add so return early
if (context == null && !AgentTracer.traceConfig().isLogInjectionEnabled()) {
if (context == null && !AgentTracer.traceConfig().isLogsInjectionEnabled()) {
bantonsson marked this conversation as resolved.
Show resolved Hide resolved
return;
}

Expand Down Expand Up @@ -145,7 +145,7 @@ public static void onExit(
InstrumentationContext.get(ExtLogRecord.class, AgentSpan.Context.class).get(record);

// Nothing to add so return early
if (context == null && !AgentTracer.traceConfig().isLogInjectionEnabled()) {
if (context == null && !AgentTracer.traceConfig().isLogsInjectionEnabled()) {
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public static boolean attachContext(@Advice.Argument(0) ExtLogRecord record) {

if (span != null) {
TraceConfig traceConfig = span.traceConfig();
if (traceConfig != null && traceConfig.isLogInjectionEnabled()) {
if (traceConfig != null && traceConfig.isLogsInjectionEnabled()) {
InstrumentationContext.get(ExtLogRecord.class, AgentSpan.Context.class)
.put(record, span.context());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public StringMap injectContextData(List<Property> list, StringMap reusable) {

AgentSpan span = activeSpan();

if (!AgentTracer.traceConfig(activeSpan()).isLogInjectionEnabled()) {
if (!AgentTracer.traceConfig(activeSpan()).isLogsInjectionEnabled()) {
bantonsson marked this conversation as resolved.
Show resolved Hide resolved
return contextData;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public static void onEnter(@Advice.Argument(0) LoggingEvent event) {
if (span != null) {
TraceConfig traceConfig = span.traceConfig();

if (traceConfig != null && traceConfig.isLogInjectionEnabled()) {
if (traceConfig != null && traceConfig.isLogsInjectionEnabled()) {
InstrumentationContext.get(LoggingEvent.class, AgentSpan.Context.class)
.put(event, span.context());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public static void getMdcValue(
InstrumentationContext.get(LoggingEvent.class, AgentSpan.Context.class).get(event);

// Nothing to add so return early
if (context == null && !AgentTracer.traceConfig().isLogInjectionEnabled()) {
if (context == null && !AgentTracer.traceConfig().isLogsInjectionEnabled()) {
bantonsson marked this conversation as resolved.
Show resolved Hide resolved
return;
}

Expand Down Expand Up @@ -130,7 +130,7 @@ public static void onEnter(
InstrumentationContext.get(LoggingEvent.class, AgentSpan.Context.class).get(event);

// Nothing to add so return early
if (context == null && !AgentTracer.traceConfig().isLogInjectionEnabled()) {
if (context == null && !AgentTracer.traceConfig().isLogsInjectionEnabled()) {
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public static void onEnter(@Advice.Argument(0) ILoggingEvent event) {
if (span != null) {
TraceConfig traceConfig = span.traceConfig();

if (traceConfig != null && traceConfig.isLogInjectionEnabled()) {
if (traceConfig != null && traceConfig.isLogsInjectionEnabled()) {
InstrumentationContext.get(ILoggingEvent.class, AgentSpan.Context.class)
.put(event, span.context());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public static void onExit(
InstrumentationContext.get(ILoggingEvent.class, AgentSpan.Context.class).get(event);

// Nothing to add so return early
if (context == null && !AgentTracer.traceConfig().isLogInjectionEnabled()) {
if (context == null && !AgentTracer.traceConfig().isLogsInjectionEnabled()) {
return;
}

Expand Down
14 changes: 7 additions & 7 deletions dd-trace-core/src/main/java/datadog/trace/core/CoreTracer.java
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ public static class CoreTracerBuilder {
private ProfilingContextIntegration profilingContextIntegration =
ProfilingContextIntegration.NoOp.INSTANCE;
private boolean pollForTracingConfiguration;
private boolean logInjectionEnabled;
private boolean logsInjectionEnabled;
randomanderson marked this conversation as resolved.
Show resolved Hide resolved

public CoreTracerBuilder serviceName(String serviceName) {
this.serviceName = serviceName;
Expand Down Expand Up @@ -394,8 +394,8 @@ public CoreTracerBuilder pollForTracingConfiguration() {
return this;
}

public CoreTracerBuilder logInjectionEnabled(boolean logInjectionEnabled) {
this.logInjectionEnabled = logInjectionEnabled;
public CoreTracerBuilder logsInjectionEnabled(boolean logsInjectionEnabled) {
this.logsInjectionEnabled = logsInjectionEnabled;
return this;
}
randomanderson marked this conversation as resolved.
Show resolved Hide resolved

Expand Down Expand Up @@ -428,7 +428,7 @@ public CoreTracerBuilder config(final Config config) {
baggageMapping(config.getBaggageMapping());
partialFlushMinSpans(config.getPartialFlushMinSpans());
strictTraceWrites(config.isTraceStrictWritesEnabled());
logInjectionEnabled(config.isLogsInjectionEnabled());
logsInjectionEnabled(config.isLogsInjectionEnabled());
randomanderson marked this conversation as resolved.
Show resolved Hide resolved

return this;
}
Expand Down Expand Up @@ -459,7 +459,7 @@ public CoreTracer build() {
dataStreamsMonitoring,
profilingContextIntegration,
pollForTracingConfiguration,
logInjectionEnabled);
logsInjectionEnabled);
}
}

Expand Down Expand Up @@ -489,7 +489,7 @@ private CoreTracer(
final DataStreamsMonitoring dataStreamsMonitoring,
final ProfilingContextIntegration profilingContextIntegration,
final boolean pollForTracingConfiguration,
final boolean logInjectionEnabled) {
final boolean logsInjectionEnabled) {
randomanderson marked this conversation as resolved.
Show resolved Hide resolved

assert localRootSpanTags != null;
assert defaultSpanTags != null;
Expand All @@ -510,7 +510,7 @@ private CoreTracer(
.setServiceMapping(serviceNameMappings)
.setTaggedHeaders(taggedHeaders)
.setBaggageMapping(baggageMapping)
.setLogInjectionEnabled(logInjectionEnabled)
.setLogsInjectionEnabled(logsInjectionEnabled)
.apply();
this.sampler = sampler;
this.injector = injector;
Expand Down
6 changes: 3 additions & 3 deletions internal-api/src/main/java/datadog/trace/api/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ static class HostNameHolder {
private final Set<TracePropagationStyle> tracePropagationStylesToExtract;
private final Set<TracePropagationStyle> tracePropagationStylesToInject;
private final int clockSyncPeriod;
private final boolean logInjectionEnabled;
private final boolean logsInjectionEnabled;

private final String dogStatsDNamedPipe;
private final int dogStatsDStartDelay;
Expand Down Expand Up @@ -1076,7 +1076,7 @@ private Config(final ConfigProvider configProvider, final InstrumenterConfig ins

clockSyncPeriod = configProvider.getInteger(CLOCK_SYNC_PERIOD, DEFAULT_CLOCK_SYNC_PERIOD);

logInjectionEnabled =
logsInjectionEnabled =
configProvider.getBoolean(LOGS_INJECTION_ENABLED, DEFAULT_LOGS_INJECTION_ENABLED);

randomanderson marked this conversation as resolved.
Show resolved Hide resolved
dogStatsDNamedPipe = configProvider.getString(DOGSTATSD_NAMED_PIPE);
Expand Down Expand Up @@ -1908,7 +1908,7 @@ public int getTracerMetricsMaxPending() {
}

public boolean isLogsInjectionEnabled() {
return logInjectionEnabled;
return logsInjectionEnabled;
}

public boolean isReportHostName() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,19 +45,19 @@ public final class Builder {
Map<String, String> serviceMapping;
Map<String, String> taggedHeaders;
Map<String, String> baggageMapping;
boolean logInjectionEnabled;
boolean logsInjectionEnabled;

Builder(State state) {
if (null == state) {
this.serviceMapping = Collections.emptyMap();
this.taggedHeaders = Collections.emptyMap();
this.baggageMapping = Collections.emptyMap();
this.logInjectionEnabled = ConfigDefaults.DEFAULT_LOGS_INJECTION_ENABLED;
this.logsInjectionEnabled = ConfigDefaults.DEFAULT_LOGS_INJECTION_ENABLED;
} else {
this.serviceMapping = state.serviceMapping;
this.taggedHeaders = state.taggedHeaders;
this.baggageMapping = state.baggageMapping;
this.logInjectionEnabled = state.logInjectionEnabled;
this.logsInjectionEnabled = state.logsInjectionEnabled;
}
}

Expand All @@ -76,8 +76,8 @@ public Builder setBaggageMapping(Map<String, String> baggageMapping) {
return this;
}

public Builder setLogInjectionEnabled(boolean logInjectionEnabled) {
this.logInjectionEnabled = logInjectionEnabled;
public Builder setLogsInjectionEnabled(boolean logsInjectionEnabled) {
this.logsInjectionEnabled = logsInjectionEnabled;
return this;
}

Expand Down Expand Up @@ -123,13 +123,13 @@ static final class State implements TraceConfig {
final Map<String, String> serviceMapping;
final Map<String, String> taggedHeaders;
final Map<String, String> baggageMapping;
final boolean logInjectionEnabled;
final boolean logsInjectionEnabled;

State(Builder builder) {
this.serviceMapping = builder.serviceMapping;
this.taggedHeaders = builder.taggedHeaders;
this.baggageMapping = builder.baggageMapping;
this.logInjectionEnabled = builder.logInjectionEnabled;
this.logsInjectionEnabled = builder.logsInjectionEnabled;
}

public Map<String, String> getServiceMapping() {
Expand All @@ -144,8 +144,8 @@ public Map<String, String> getBaggageMapping() {
return baggageMapping;
}

public boolean isLogInjectionEnabled() {
return logInjectionEnabled;
public boolean isLogsInjectionEnabled() {
return logsInjectionEnabled;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ public interface TraceConfig {

Map<String, String> getBaggageMapping();

boolean isLogInjectionEnabled();
boolean isLogsInjectionEnabled();
}