Skip to content

Commit

Permalink
refactor config to have a property that determines if tracing is need…
Browse files Browse the repository at this point in the history
…ed with apm disabled
  • Loading branch information
jandro996 committed May 21, 2024
1 parent 38dce87 commit ad49247
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ public static Set<InstrumenterModule.TargetSystem> getEnabledSystems() {
EnumSet<InstrumenterModule.TargetSystem> enabledSystems =
EnumSet.noneOf(InstrumenterModule.TargetSystem.class);
InstrumenterConfig cfg = InstrumenterConfig.get();
if (cfg.isTraceEnabled() || cfg.isApmTracingEnabled()) {
if (cfg.isTraceEnabled() || cfg.areTracingDependantProductsEnabled()) {
enabledSystems.add(InstrumenterModule.TargetSystem.TRACING);
}
if (cfg.isProfilingEnabled()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public static synchronized void installGlobalTracer(
ProfilingContextIntegration profilingContextIntegration) {
if (Config.get().isTraceEnabled()
|| Config.get().isCiVisibilityEnabled()
|| Config.get().isApmTracingEnabled()) {
|| Config.get().areTracingDependantProductsEnabled()) {
if (!(GlobalTracer.get() instanceof CoreTracer)) {
CoreTracer tracer =
CoreTracer.builder()
Expand Down
2 changes: 2 additions & 0 deletions dd-trace-api/src/main/java/datadog/trace/api/DDTags.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,6 @@ public class DDTags {
public static final String PROFILING_CONTEXT_ENGINE = "_dd.profiling.ctx";
public static final String BASE_SERVICE = "_dd.base_service";
public static final String APM_ENABLED = "_dd.apm.enabled";

public static final String APPSEC = "_dd.p.appsec";
}
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,8 @@ public Response sendSerializedTraces(final Payload payload) {
.addHeader(
DATADOG_CLIENT_COMPUTED_STATS,
(metricsEnabled && featuresDiscovery.supportsMetrics())
|| Config.get().isApmTracingEnabled()
|| (!Config.get().isTraceEnabled()
&& Config.get().areTracingDependantProductsEnabled())
? "true"
: "")
.put(payload.toRequest())
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 @@ -2165,8 +2165,8 @@ public boolean isTraceEnabled() {
return instrumenterConfig.isTraceEnabled();
}

public boolean isApmTracingEnabled() {
return instrumenterConfig.isApmTracingEnabled();
public boolean areTracingDependantProductsEnabled() {
return instrumenterConfig.areTracingDependantProductsEnabled();
}

public boolean isLongRunningTraceEnabled() {
Expand Down Expand Up @@ -3476,7 +3476,7 @@ public Map<String, Object> getLocalRootSpanTags() {
result.put(PROFILING_ENABLED, isProfilingEnabled() ? 1 : 0);
result.put(DSM_ENABLED, isDataStreamsEnabled() ? 1 : 0);
result.put(DJM_ENABLED, isDataJobsEnabled() ? 1 : 0);
if (isApmTracingEnabled()) {
if (areTracingDependantProductsEnabled()) {
result.put(APM_ENABLED, 0);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ public class InstrumenterConfig {

private final Collection<String> additionalJaxRsAnnotations;

private final boolean apmTracinEnabled;
private final boolean tracingDependantProductsEnabled;

private InstrumenterConfig() {
this(ConfigProvider.createDefault());
Expand Down Expand Up @@ -266,10 +266,9 @@ private InstrumenterConfig() {
this.additionalJaxRsAnnotations =
tryMakeImmutableSet(configProvider.getList(JAX_RS_ADDITIONAL_ANNOTATIONS));

apmTracinEnabled =
!isTraceEnabled()
&& (getAppSecActivation() == ProductActivation.FULLY_ENABLED
|| getIastActivation() == ProductActivation.FULLY_ENABLED);
tracingDependantProductsEnabled =
getAppSecActivation() == ProductActivation.FULLY_ENABLED
|| getIastActivation() == ProductActivation.FULLY_ENABLED;
}

public boolean isSpanOriginEnabled() {
Expand Down Expand Up @@ -299,8 +298,8 @@ public boolean isTraceEnabled() {
return traceEnabled;
}

public boolean isApmTracingEnabled() {
return apmTracinEnabled;
public boolean areTracingDependantProductsEnabled() {
return tracingDependantProductsEnabled;
}

public boolean isTraceOtelEnabled() {
Expand Down

0 comments on commit ad49247

Please sign in to comment.