Skip to content

Commit

Permalink
add monitoring for backups
Browse files Browse the repository at this point in the history
  • Loading branch information
richardstartin committed Jun 30, 2020
1 parent 1d79f43 commit 9dc0378
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
public class DispatchingDisruptor implements AutoCloseable {

private final Disruptor<TraceBuffer> disruptor;
private final Monitor monitor;

public DispatchingDisruptor(
int disruptorSize,
Expand All @@ -35,6 +36,7 @@ public DispatchingDisruptor(
// block (and use no resources) until there's a batch of data to dispatch
new BlockingWaitStrategy());
disruptor.handleEventsWith(new TraceDispatchingHandler(api, monitor, writer));
this.monitor = monitor;
}

public void start() {
Expand All @@ -53,6 +55,7 @@ long beginTransaction() {
try {
return disruptor.getRingBuffer().tryNext();
} catch (InsufficientCapacityException insufficientCapacity) {
monitor.onBackedUpTraceBuffer();
long now = System.currentTimeMillis();
backoffMillis = Math.min(backoffMillis * 2, 1000);
if (now > nextLogTime) { // log every 20 seconds
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ public interface Monitor {

void onScheduleFlush(final DDAgentWriter agentWriter, final boolean previousIncomplete);

void onBackedUpTraceBuffer();

void onSerialize(
final DDAgentWriter agentWriter, final List<DDSpan> trace, final int serializedSizeInBytes);

Expand Down Expand Up @@ -114,6 +116,11 @@ public void onScheduleFlush(final DDAgentWriter agentWriter, final boolean previ
// not recorded
}

@Override
public void onBackedUpTraceBuffer() {
statsd.incrementCounter("trace.buffer.backlog");
}

@Override
public void onFlush(final DDAgentWriter agentWriter, final boolean early) {}

Expand Down Expand Up @@ -203,6 +210,9 @@ public void onFlush(final DDAgentWriter agentWriter, final boolean early) {}
public void onScheduleFlush(
final DDAgentWriter agentWriter, final boolean previousIncomplete) {}

@Override
public void onBackedUpTraceBuffer() {}

@Override
public void onSerialize(
final DDAgentWriter agentWriter,
Expand Down

0 comments on commit 9dc0378

Please sign in to comment.