From a06a436c03b1fdd49acbede611ba37ba7cad2cdd Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Sun, 17 Nov 2019 22:09:25 +0100 Subject: [PATCH] =?utf8?q?=E2=9C=A8=20Add=20histogram=20for=20configuratio?= =?utf8?q?n=20saving=20times?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/main/java/net/pterodactylus/sone/core/Core.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/java/net/pterodactylus/sone/core/Core.java b/src/main/java/net/pterodactylus/sone/core/Core.java index 6525ac3..d79cd40 100644 --- a/src/main/java/net/pterodactylus/sone/core/Core.java +++ b/src/main/java/net/pterodactylus/sone/core/Core.java @@ -88,6 +88,7 @@ import net.pterodactylus.util.service.AbstractService; import net.pterodactylus.util.thread.NamedThreadFactory; import com.google.common.annotations.VisibleForTesting; +import com.google.common.base.Stopwatch; import com.google.common.collect.FluentIterable; import com.google.common.collect.HashMultimap; import com.google.common.collect.Multimap; @@ -176,6 +177,7 @@ public class Core extends AbstractService implements SoneProvider, PostProvider, private volatile long lastConfigurationUpdate; private final MetricRegistry metricRegistry; + private final Histogram configurationSaveTimeHistogram; /** * Creates a new core. @@ -207,6 +209,7 @@ public class Core extends AbstractService implements SoneProvider, PostProvider, this.database = database; this.metricRegistry = metricRegistry; preferences = new Preferences(eventBus); + this.configurationSaveTimeHistogram = metricRegistry.histogram("configuration.save.duration", () -> new Histogram(new ExponentiallyDecayingReservoir(3000, 0))); } // @@ -1546,7 +1549,9 @@ public class Core extends AbstractService implements SoneProvider, PostProvider, database.save(); /* now save it. */ + Stopwatch stopwatch = Stopwatch.createStarted(); configuration.save(); + configurationSaveTimeHistogram.update(stopwatch.elapsed(TimeUnit.MICROSECONDS)); } catch (ConfigurationException ce1) { logger.log(Level.SEVERE, "Could not store configuration!", ce1); -- 2.7.4