From c2183f3cec2e88f8b7ccef8e958f62883335ae53 Mon Sep 17 00:00:00 2001 From: Per Minborg Date: Tue, 15 Dec 2020 10:19:05 +0100 Subject: [PATCH] Announce the existence of analytics on startup, Fix #248 --- .../net/openhft/chronicle/map/VanillaChronicleMap.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main/java/net/openhft/chronicle/map/VanillaChronicleMap.java b/src/main/java/net/openhft/chronicle/map/VanillaChronicleMap.java index 465f44c64..bcffece96 100644 --- a/src/main/java/net/openhft/chronicle/map/VanillaChronicleMap.java +++ b/src/main/java/net/openhft/chronicle/map/VanillaChronicleMap.java @@ -18,11 +18,13 @@ package net.openhft.chronicle.map; import net.openhft.chronicle.algo.bitset.ReusableBitSet; import net.openhft.chronicle.algo.hashing.LongHashFunction; +import net.openhft.chronicle.analytics.Analytics; import net.openhft.chronicle.bytes.Bytes; import net.openhft.chronicle.bytes.BytesStore; import net.openhft.chronicle.bytes.PointerBytesStore; import net.openhft.chronicle.core.Jvm; import net.openhft.chronicle.core.analytics.AnalyticsFacade; +import net.openhft.chronicle.core.announcer.Announcer; import net.openhft.chronicle.core.io.IOTools; import net.openhft.chronicle.hash.ChronicleHashClosedException; import net.openhft.chronicle.hash.ChronicleHashCorruption; @@ -47,12 +49,15 @@ import java.io.IOException; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.lang.reflect.Type; +import java.util.Collections; import java.util.HashMap; import java.util.Map; import java.util.Set; import java.util.function.BiFunction; import java.util.function.Function; +import static java.util.Collections.emptyMap; +import static java.util.Collections.singletonMap; import static net.openhft.chronicle.map.ChronicleMapBuilder.greatestCommonDivisor; @SuppressWarnings("JavadocReference") @@ -122,7 +127,10 @@ public class VanillaChronicleMap } catch (RuntimeException ignored) { // The ChronicleMapBuilder::entries may throw an Exception. If so, just ignore this parameter } - + Announcer.announce("net.openhft", "chronicle-map", + AnalyticsFacade.isEnabled() + ? singletonMap("Analytics", "Chronicle Map reports usage statistics. Learn more or turn off: https://github.com/OpenHFT/Chronicle-Map/blob/master/DISCLAIMER.adoc") + : emptyMap()); AnalyticsHolder.instance().sendEvent("started", additionalEventParameters); }