private final long delay;
private final String soneId;
private final Histogram soneInsertDurationHistogram;
+ private final Meter soneInsertErrorMeter;
/**
* Creates a new Sone inserter.
this.eventBus = eventBus;
this.freenetInterface = freenetInterface;
this.soneInsertDurationHistogram = metricRegistry.histogram("sone.insert.duration");
+ this.soneInsertErrorMeter = metricRegistry.meter("sone.insert.errors");
this.soneId = soneId;
this.soneModificationDetector = soneModificationDetector;
this.delay = delay;
success = true;
logger.log(Level.INFO, String.format("Inserted Sone “%s” at %s.", sone.getName(), finalUri));
} catch (SoneException se1) {
+ soneInsertErrorMeter.mark();
eventBus.post(new SoneInsertAbortedEvent(sone, se1));
logger.log(Level.WARNING, String.format("Could not insert Sone “%s”!", sone.getName()), se1);
} finally {
}
@Test
- fun `unsuccessful insert does not update metrics`() {
+ fun `unsuccessful insert does not update histogram but records error`() {
val insertUri = mock<FreenetURI>()
createSone(insertUri)
val soneModificationDetector = mock<SoneModificationDetector>()
soneInserter.serviceRun()
val histogram = metricRegistry.histogram("sone.insert.duration")
assertThat(histogram.count, equalTo(0L))
+ val meter = metricRegistry.meter("sone.insert.errors")
+ assertThat(meter.count, equalTo(1L))
}
}