Skip to content

Commit 0117972

Browse files
authored
Merge pull request DataDog#4228 from DataDog/jpbempel/rate-limiting-no-condition
Modify rate limit regarding probe conditions
2 parents 667c67d + 4de999b commit 0117972

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

dd-java-agent/agent-debugger/debugger-bootstrap/src/main/java/datadog/trace/bootstrap/debugger/Snapshot.java

+6-3
Original file line numberDiff line numberDiff line change
@@ -181,9 +181,12 @@ public void commit() {
181181
}
182182
return;
183183
}
184-
if (!ProbeRateLimiter.tryProbe(probe.id)) {
185-
DebuggerContext.skipSnapshot(probe.id, DebuggerContext.SkipCause.RATE);
186-
return;
184+
// only rate limit if a condition is defined
185+
if (probe.getScript() != null) {
186+
if (!ProbeRateLimiter.tryProbe(probe.id)) {
187+
DebuggerContext.skipSnapshot(probe.id, DebuggerContext.SkipCause.RATE);
188+
return;
189+
}
187190
}
188191
// generates id only when effectively committing
189192
this.id = UUID.randomUUID().toString();

dd-java-agent/agent-debugger/debugger-bootstrap/src/main/java/datadog/trace/bootstrap/debugger/SnapshotProvider.java

+7
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@ public static Snapshot newSnapshot(String uuid, Class<?> callingClass) {
1616
LOG.info("Cannot resolve the probe: {}", uuid);
1717
probeDetails = Snapshot.ProbeDetails.UNKNOWN;
1818
}
19+
// only rate limit if no condition are defined
20+
if (probeDetails.getScript() == null) {
21+
if (!ProbeRateLimiter.tryProbe(probeDetails.getId())) {
22+
DebuggerContext.skipSnapshot(probeDetails.getId(), DebuggerContext.SkipCause.RATE);
23+
return null;
24+
}
25+
}
1926
return new Snapshot(Thread.currentThread(), probeDetails, callingClass.getTypeName());
2027
}
2128
}

0 commit comments

Comments
 (0)