Skip to content

Commit f127aa7

Browse files
author
Cecile Terpin
committed
changes after review
1 parent 955e382 commit f127aa7

File tree

6 files changed

+28
-30
lines changed

6 files changed

+28
-30
lines changed

dd-trace-api/src/main/java/datadog/trace/api/ConfigDefaults.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@ public final class ConfigDefaults {
6969
static final boolean DEFAULT_DB_CLIENT_HOST_SPLIT_BY_INSTANCE_TYPE_SUFFIX = false;
7070
static final boolean DEFAULT_DB_CLIENT_HOST_SPLIT_BY_HOST = false;
7171
static final String DEFAULT_DB_DBM_PROPAGATION_MODE_MODE = "disabled";
72-
// Default value is set to -1, it disables the latency trace interceptor
73-
static final int DEFAULT_TRACE_LATENCY_INTERCEPTOR_VALUE = -1;
72+
// Default value is set to 0, it disables the latency trace interceptor
73+
static final int DEFAULT_TRACE_KEEP_LATENCY_THRESHOLD_MS = 0;
7474
static final int DEFAULT_SCOPE_DEPTH_LIMIT = 100;
7575
static final int DEFAULT_SCOPE_ITERATION_KEEP_ALIVE = 30; // in seconds
7676
static final int DEFAULT_PARTIAL_FLUSH_MIN_SPANS = 1000;

dd-trace-api/src/main/java/datadog/trace/api/config/TracerConfig.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public final class TracerConfig {
7474

7575
public static final String SPLIT_BY_TAGS = "trace.split-by-tags";
7676
// trace latency interceptor value should be in ms
77-
public static final String TRACE_LATENCY_INTERCEPTOR_VALUE = "trace.latency.interceptor.value";
77+
public static final String TRACE_KEEP_LATENCY_THRESHOLD_MS = "trace.keep.latency.threshold.ms";
7878
public static final String SCOPE_DEPTH_LIMIT = "trace.scope.depth.limit";
7979
public static final String SCOPE_STRICT_MODE = "trace.scope.strict.mode";
8080
public static final String SCOPE_ITERATION_KEEP_ALIVE = "trace.scope.iteration.keep.alive";

dd-trace-core/src/main/java/datadog/trace/core/CoreTracer.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -746,7 +746,7 @@ private CoreTracer(
746746
addTraceInterceptor(GitMetadataTraceInterceptor.INSTANCE);
747747
}
748748

749-
if (config.isTraceLatencyInterceptorEnabled()) {
749+
if (config.isTraceKeepLatencyThresholdEnabled()) {
750750
addTraceInterceptor(LatencyTraceInterceptor.INSTANCE);
751751
}
752752

dd-trace-core/src/main/java/datadog/trace/core/traceinterceptor/LatencyTraceInterceptor.java

+10-12
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,19 @@
99
import org.slf4j.Logger;
1010
import org.slf4j.LoggerFactory;
1111

12-
// This trace latency interceptor is disabled by default.
13-
// We can activate it by setting the value of dd.trace.latency.interceptor.value to a positive value
14-
// This value should be in milliseconds and this interceptor will retain any local trace who has a
15-
// root
16-
// span duration greater than this value.
17-
// The activation of this interceptor is ignored if partial flush is enabled in order to avoid
18-
// incomplete local trace (incomplete chunk of trace).
19-
// Note that since we're changing the sampling priority at the end of local trace, there is no
20-
// guarantee to get complete traces,
21-
// since the original sampling priority for this trace may have already been propagated.
22-
12+
/**
13+
* This trace latency interceptor is disabled by default. We can activate it by setting the value of
14+
* dd.trace.latency.interceptor.value to a positive value This value should be in milliseconds and
15+
* this interceptor will retain any local trace who has a root span duration greater than this
16+
* value. The activation of this interceptor is ignored if partial flush is enabled in order to
17+
* avoid incomplete local trace (incomplete chunk of trace). Note that since we're changing the
18+
* sampling priority at the end of local trace, there is no guarantee to get complete traces, since
19+
* the original sampling priority for this trace may have already been propagated.
20+
*/
2321
public class LatencyTraceInterceptor extends AbstractTraceInterceptor {
2422
private static final Logger log = LoggerFactory.getLogger(LatencyTraceInterceptor.class);
2523
// duration configured in ms, need to be converted in nano seconds
26-
private static final int LATENCY = Config.get().getTraceLatencyInterceptorValue() * 1000000;
24+
private static final long LATENCY = Config.get().getTraceKeepLatencyThreshold() * 1000000L;
2725

2826
public static final TraceInterceptor INSTANCE =
2927
new LatencyTraceInterceptor(Priority.ROOT_SPAN_LATENCY);

dd-trace-core/src/test/groovy/datadog/trace/core/traceinterceptor/LatencyTraceInterceptorTest.groovy

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class LatencyTraceInterceptorTest extends DDCoreSpecification {
1515
setup:
1616

1717
injectSysConfig("trace.partial.flush.enabled", partialFlushEnabled)
18-
injectSysConfig("trace.latency.interceptor.value", latencyThreshold)
18+
injectSysConfig("trace.keep.latency.threshold.ms", latencyThreshold)
1919

2020
when:
2121
def writer = new ListWriter()

internal-api/src/main/java/datadog/trace/api/Config.java

+13-13
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,8 @@ public static String getHostName() {
176176
private final boolean scopeStrictMode;
177177
private final int scopeIterationKeepAlive;
178178
private final int partialFlushMinSpans;
179-
private final int traceLatencyInterceptorValue;
180-
private final boolean traceLatencyInterceptorEnabled;
179+
private final int traceKeepLatencyThreshold;
180+
private final boolean traceKeepLatencyThresholdEnabled;
181181
private final boolean traceStrictWritesEnabled;
182182
private final boolean logExtractHeaderNames;
183183
private final Set<PropagationStyle> propagationStylesToExtract;
@@ -862,11 +862,11 @@ private Config(final ConfigProvider configProvider, final InstrumenterConfig ins
862862
? 0
863863
: configProvider.getInteger(PARTIAL_FLUSH_MIN_SPANS, DEFAULT_PARTIAL_FLUSH_MIN_SPANS);
864864

865-
traceLatencyInterceptorValue =
865+
traceKeepLatencyThreshold =
866866
configProvider.getInteger(
867-
TRACE_LATENCY_INTERCEPTOR_VALUE, DEFAULT_TRACE_LATENCY_INTERCEPTOR_VALUE);
867+
TRACE_KEEP_LATENCY_THRESHOLD_MS, DEFAULT_TRACE_KEEP_LATENCY_THRESHOLD_MS);
868868

869-
traceLatencyInterceptorEnabled = !partialFlushEnabled && (traceLatencyInterceptorValue >= 0);
869+
traceKeepLatencyThresholdEnabled = !partialFlushEnabled && (traceKeepLatencyThreshold > 0);
870870

871871
traceStrictWritesEnabled = configProvider.getBoolean(TRACE_STRICT_WRITES_ENABLED, false);
872872

@@ -2083,12 +2083,12 @@ public int getPartialFlushMinSpans() {
20832083
return partialFlushMinSpans;
20842084
}
20852085

2086-
public int getTraceLatencyInterceptorValue() {
2087-
return traceLatencyInterceptorValue;
2086+
public int getTraceKeepLatencyThreshold() {
2087+
return traceKeepLatencyThreshold;
20882088
}
20892089

2090-
public boolean isTraceLatencyInterceptorEnabled() {
2091-
return traceLatencyInterceptorEnabled;
2090+
public boolean isTraceKeepLatencyThresholdEnabled() {
2091+
return traceKeepLatencyThresholdEnabled;
20922092
}
20932093

20942094
public boolean isTraceStrictWritesEnabled() {
@@ -4174,10 +4174,10 @@ public String toString() {
41744174
+ scopeIterationKeepAlive
41754175
+ ", partialFlushMinSpans="
41764176
+ partialFlushMinSpans
4177-
+ ", traceLatencyInterceptorEnabled="
4178-
+ traceLatencyInterceptorEnabled
4179-
+ ", traceLatencyInterceptorValue="
4180-
+ traceLatencyInterceptorValue
4177+
+ ", traceKeepLatencyThresholdEnabled="
4178+
+ traceKeepLatencyThresholdEnabled
4179+
+ ", traceKeepLatencyThreshold="
4180+
+ traceKeepLatencyThreshold
41814181
+ ", traceStrictWritesEnabled="
41824182
+ traceStrictWritesEnabled
41834183
+ ", tracePropagationStylesToExtract="

0 commit comments

Comments
 (0)