Skip to content

Commit

Permalink
Move Config.isLogsMDCTagsInjectionEnabled() to InstrumenterConfig (#4334
Browse files Browse the repository at this point in the history
)
  • Loading branch information
mcculls authored Nov 29, 2022
1 parent 3050a40 commit 250da7c
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ public static void onExit(

AgentSpan.Context context =
InstrumentationContext.get(ExtLogRecord.class, AgentSpan.Context.class).get(record);
boolean mdcTagsInjectionEnabled = Config.get().isLogsMDCTagsInjectionEnabled();
boolean mdcTagsInjectionEnabled = InstrumenterConfig.get().isLogsMDCTagsInjectionEnabled();

// Nothing to add so return early
if (context == null && !mdcTagsInjectionEnabled) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import datadog.trace.api.Config;
import datadog.trace.api.CorrelationIdentifier;
import datadog.trace.api.DDSpanId;
import datadog.trace.api.InstrumenterConfig;
import datadog.trace.bootstrap.instrumentation.api.AgentSpan;
import datadog.trace.bootstrap.instrumentation.api.Tags;
import java.util.List;
Expand All @@ -32,7 +33,7 @@ public StringMap injectContextData(List<Property> list, StringMap reusable) {
// We're at most adding 5 tags
StringMap newContextData = new SortedArrayStringMap(contextData.size() + 5);

if (Config.get().isLogsMDCTagsInjectionEnabled()) {
if (InstrumenterConfig.get().isLogsMDCTagsInjectionEnabled()) {
String env = Config.get().getEnv();
if (null != env && !env.isEmpty()) {
newContextData.putValue(Tags.DD_ENV, env);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public static void onEnter(

Hashtable mdc = new Hashtable();

if (Config.get().isLogsMDCTagsInjectionEnabled()) {
if (InstrumenterConfig.get().isLogsMDCTagsInjectionEnabled()) {
String serviceName = Config.get().getServiceName();
if (null != serviceName && !serviceName.isEmpty()) {
mdc.put(Tags.DD_SERVICE, serviceName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public static void onExit(

AgentSpan.Context context =
InstrumentationContext.get(ILoggingEvent.class, AgentSpan.Context.class).get(event);
boolean mdcTagsInjectionEnabled = Config.get().isLogsMDCTagsInjectionEnabled();
boolean mdcTagsInjectionEnabled = InstrumenterConfig.get().isLogsMDCTagsInjectionEnabled();

// Nothing to add so return early
if (context == null && !mdcTagsInjectionEnabled) {
Expand Down
9 changes: 0 additions & 9 deletions internal-api/src/main/java/datadog/trace/api/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,6 @@
import static datadog.trace.api.config.TraceInstrumentationConfig.JMS_PROPAGATION_DISABLED_TOPICS;
import static datadog.trace.api.config.TraceInstrumentationConfig.KAFKA_CLIENT_BASE64_DECODING_ENABLED;
import static datadog.trace.api.config.TraceInstrumentationConfig.KAFKA_CLIENT_PROPAGATION_DISABLED_TOPICS;
import static datadog.trace.api.config.TraceInstrumentationConfig.LOGS_MDC_TAGS_INJECTION_ENABLED;
import static datadog.trace.api.config.TraceInstrumentationConfig.MESSAGE_BROKER_SPLIT_BY_DESTINATION;
import static datadog.trace.api.config.TraceInstrumentationConfig.OBFUSCATION_QUERY_STRING_REGEXP;
import static datadog.trace.api.config.TraceInstrumentationConfig.PLAY_REPORT_HTTP_STATUS;
Expand Down Expand Up @@ -406,7 +405,6 @@ static class HostNameHolder {
private final int tracerMetricsMaxAggregates;
private final int tracerMetricsMaxPending;

private final boolean logsMDCTagsInjectionEnabled;
private final boolean reportHostName;

private final boolean traceAnalyticsEnabled;
Expand Down Expand Up @@ -876,7 +874,6 @@ && isJavaVersionAtLeast(8)
tracerMetricsMaxAggregates = configProvider.getInteger(TRACER_METRICS_MAX_AGGREGATES, 2048);
tracerMetricsMaxPending = configProvider.getInteger(TRACER_METRICS_MAX_PENDING, 2048);

logsMDCTagsInjectionEnabled = configProvider.getBoolean(LOGS_MDC_TAGS_INJECTION_ENABLED, true);
reportHostName =
configProvider.getBoolean(TRACE_REPORT_HOSTNAME, DEFAULT_TRACE_REPORT_HOSTNAME);

Expand Down Expand Up @@ -1509,10 +1506,6 @@ public boolean isLogsInjectionEnabled() {
return instrumenterConfig.isLogsInjectionEnabled();
}

public boolean isLogsMDCTagsInjectionEnabled() {
return logsMDCTagsInjectionEnabled;
}

public boolean isReportHostName() {
return reportHostName;
}
Expand Down Expand Up @@ -2698,8 +2691,6 @@ public String toString() {
+ tracerMetricsMaxAggregates
+ ", tracerMetricsMaxPending="
+ tracerMetricsMaxPending
+ ", logsMDCTagsInjectionEnabled="
+ logsMDCTagsInjectionEnabled
+ ", reportHostName="
+ reportHostName
+ ", traceAnalyticsEnabled="
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import static datadog.trace.api.config.TraceInstrumentationConfig.JDBC_CONNECTION_CLASS_NAME;
import static datadog.trace.api.config.TraceInstrumentationConfig.JDBC_PREPARED_STATEMENT_CLASS_NAME;
import static datadog.trace.api.config.TraceInstrumentationConfig.LOGS_INJECTION_ENABLED;
import static datadog.trace.api.config.TraceInstrumentationConfig.LOGS_MDC_TAGS_INJECTION_ENABLED;
import static datadog.trace.api.config.TraceInstrumentationConfig.RESOLVER_OUTLINE_POOL_ENABLED;
import static datadog.trace.api.config.TraceInstrumentationConfig.RESOLVER_OUTLINE_POOL_SIZE;
import static datadog.trace.api.config.TraceInstrumentationConfig.RESOLVER_RESET_INTERVAL;
Expand Down Expand Up @@ -62,6 +63,7 @@ public class InstrumenterConfig {

private final boolean traceEnabled;
private final boolean logsInjectionEnabled;
private final boolean logsMDCTagsInjectionEnabled;
private final boolean profilingEnabled;
private final boolean ciVisibilityEnabled;
private final ProductActivation appSecActivation;
Expand Down Expand Up @@ -109,6 +111,7 @@ private InstrumenterConfig() {
traceEnabled = configProvider.getBoolean(TRACE_ENABLED, DEFAULT_TRACE_ENABLED);
logsInjectionEnabled =
configProvider.getBoolean(LOGS_INJECTION_ENABLED, DEFAULT_LOGS_INJECTION_ENABLED);
logsMDCTagsInjectionEnabled = configProvider.getBoolean(LOGS_MDC_TAGS_INJECTION_ENABLED, true);
profilingEnabled = configProvider.getBoolean(PROFILING_ENABLED, PROFILING_ENABLED_DEFAULT);
ciVisibilityEnabled =
configProvider.getBoolean(CIVISIBILITY_ENABLED, DEFAULT_CIVISIBILITY_ENABLED);
Expand Down Expand Up @@ -190,6 +193,10 @@ public boolean isLogsInjectionEnabled() {
return logsInjectionEnabled;
}

public boolean isLogsMDCTagsInjectionEnabled() {
return logsMDCTagsInjectionEnabled && !Platform.isNativeImageBuilder();
}

public boolean isProfilingEnabled() {
return profilingEnabled;
}
Expand Down Expand Up @@ -267,7 +274,7 @@ public boolean isResolverUseLoadClassEnabled() {
}

public int getResolverResetInterval() {
return resolverResetInterval;
return Platform.isNativeImageBuilder() ? 0 : resolverResetInterval;
}

public boolean isRuntimeContextFieldInjection() {
Expand Down Expand Up @@ -317,6 +324,8 @@ public String toString() {
+ traceEnabled
+ ", logsInjectionEnabled="
+ logsInjectionEnabled
+ ", logsMDCTagsInjectionEnabled="
+ logsMDCTagsInjectionEnabled
+ ", profilingEnabled="
+ profilingEnabled
+ ", ciVisibilityEnabled="
Expand Down

0 comments on commit 250da7c

Please sign in to comment.