From 67c307faa434dff01362363ab896875b36e3d696 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Wed, 31 Jul 2019 13:54:00 +0200 Subject: [PATCH] =?utf8?q?=F0=9F=94=8A=20Count=20errors=20on=20Sone=20inse?= =?utf8?q?rts?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/main/java/net/pterodactylus/sone/core/SoneInserter.java | 3 +++ src/test/kotlin/net/pterodactylus/sone/core/SoneInserterTest.kt | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/java/net/pterodactylus/sone/core/SoneInserter.java b/src/main/java/net/pterodactylus/sone/core/SoneInserter.java index af180a0..e138f79 100644 --- a/src/main/java/net/pterodactylus/sone/core/SoneInserter.java +++ b/src/main/java/net/pterodactylus/sone/core/SoneInserter.java @@ -109,6 +109,7 @@ public class SoneInserter extends AbstractService { private final long delay; private final String soneId; private final Histogram soneInsertDurationHistogram; + private final Meter soneInsertErrorMeter; /** * Creates a new Sone inserter. @@ -151,6 +152,7 @@ public class SoneInserter extends AbstractService { 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; @@ -250,6 +252,7 @@ public class SoneInserter extends AbstractService { 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 { diff --git a/src/test/kotlin/net/pterodactylus/sone/core/SoneInserterTest.kt b/src/test/kotlin/net/pterodactylus/sone/core/SoneInserterTest.kt index d2bb3b4..8b061a7 100644 --- a/src/test/kotlin/net/pterodactylus/sone/core/SoneInserterTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/core/SoneInserterTest.kt @@ -258,7 +258,7 @@ class SoneInserterTest { } @Test - fun `unsuccessful insert does not update metrics`() { + fun `unsuccessful insert does not update histogram but records error`() { val insertUri = mock() createSone(insertUri) val soneModificationDetector = mock() @@ -271,6 +271,8 @@ class SoneInserterTest { 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)) } } -- 2.7.4