šŸ“„ Update year in file headers
[Sone.git] / src / main / java / net / pterodactylus / sone / core / SoneInserter.java
index af180a0..7ccb374 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Sone - SoneInserter.java - Copyright Ā© 2010ā€“2019 David Roden
+ * Sone - SoneInserter.java - Copyright Ā© 2010ā€“2020 David Roden
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -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.
@@ -150,7 +151,8 @@ public class SoneInserter extends AbstractService {
                this.core = core;
                this.eventBus = eventBus;
                this.freenetInterface = freenetInterface;
-               this.soneInsertDurationHistogram = metricRegistry.histogram("sone.insert.duration");
+               this.soneInsertDurationHistogram = metricRegistry.histogram("sone.insert.duration", () -> new Histogram(new ExponentiallyDecayingReservoir(3000, 0)));
+               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 {