Skip to content

Commit a95fbb0

Browse files
committed
PendingTraceBuffer: Keep track of how often we write around the buffer
1 parent f10c146 commit a95fbb0

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ private static class DelayingPendingTraceBuffer extends PendingTraceBuffer {
6464
private final MpscBlockingConsumerArrayQueue<Element> queue;
6565
private final Thread worker;
6666
private final TimeSource timeSource;
67+
private final HealthMetrics healthMetrics;
6768

6869
private volatile boolean closed = false;
6970
private final AtomicInteger flushCounter = new AtomicInteger(0);
@@ -102,6 +103,7 @@ public void enqueue(Element pendingTrace) {
102103
if (!pendingTrace.writeOnBufferFull()) {
103104
return;
104105
}
106+
healthMetrics.onPendingWriteAround();
105107
pendingTrace.write();
106108
}
107109
}
@@ -324,6 +326,7 @@ public DelayingPendingTraceBuffer(
324326
this.queue = new MpscBlockingConsumerArrayQueue<>(bufferSize);
325327
this.worker = newAgentThread(TRACE_MONITOR, new Worker());
326328
this.timeSource = timeSource;
329+
this.healthMetrics = healthMetrics;
327330
boolean runningSpansEnabled = config.isLongRunningTraceEnabled();
328331
this.runningTracesTracker =
329332
runningSpansEnabled

dd-trace-core/src/main/java/datadog/trace/core/monitor/HealthMetrics.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ public void onSend(
7171
public void onFailedSend(
7272
final int traceCount, final int sizeInBytes, final RemoteApi.Response response) {}
7373

74+
public void onPendingWriteAround() {}
75+
7476
public void onLongRunningUpdate(
7577
final int dropped, final int write, final int expired, final int droppedSampling) {}
7678

dd-trace-core/src/main/java/datadog/trace/core/monitor/TracerHealthMetrics.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@ public class TracerHealthMetrics extends HealthMetrics implements AutoCloseable
8484
private final LongAdder scopeCloseErrors = new LongAdder();
8585
private final LongAdder userScopeCloseErrors = new LongAdder();
8686

87+
private final LongAdder pendingWriteAround = new LongAdder();
88+
8789
private final LongAdder longRunningTracesWrite = new LongAdder();
8890
private final LongAdder longRunningTracesDropped = new LongAdder();
8991
private final LongAdder longRunningTracesExpired = new LongAdder();
@@ -295,6 +297,11 @@ public void onFailedSend(
295297
onSendAttempt(traceCount, sizeInBytes, response);
296298
}
297299

300+
@Override
301+
public void onPendingWriteAround() {
302+
pendingWriteAround.increment();
303+
}
304+
298305
@Override
299306
public void onLongRunningUpdate(
300307
final int dropped, final int write, final int expired, final int droppedSampling) {
@@ -473,6 +480,8 @@ public void run(TracerHealthMetrics target) {
473480
reportIfChanged(
474481
target.statsd, "scope.user.close.error", target.userScopeCloseErrors, NO_TAGS);
475482

483+
reportIfChanged(target.statsd, "pending.write_around", target.pendingWriteAround, NO_TAGS);
484+
476485
reportIfChanged(
477486
target.statsd, "long-running.write", target.longRunningTracesWrite, NO_TAGS);
478487
reportIfChanged(
@@ -607,6 +616,9 @@ public String summary() {
607616
+ "\nuserScopeCloseErrors="
608617
+ userScopeCloseErrors.sum()
609618
+ "\n"
619+
+ "\npendingWriteAround="
620+
+ pendingWriteAround.sum()
621+
+ "\n"
610622
+ "\nlongRunningTracesWrite="
611623
+ longRunningTracesWrite.sum()
612624
+ "\nlongRunningTracesDropped="

0 commit comments

Comments
 (0)