Package com.ultikits.ultitools.utils
Class Metrics.MetricsBase
java.lang.Object
com.ultikits.ultitools.utils.Metrics.MetricsBase
- Enclosing class:
Metrics
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Consumer<Metrics.JsonObjectBuilder> private final Consumer<Metrics.JsonObjectBuilder> private final Set<Metrics.CustomChart> private final booleanprivate final BiConsumer<String, Throwable> private final booleanprivate final booleanprivate final booleanstatic final StringThe version of the Metrics class.private final Stringprivate static final Stringprivate final ScheduledExecutorServiceprivate final Stringprivate final int -
Constructor Summary
ConstructorsConstructorDescriptionMetricsBase(String platform, String serverUuid, int serviceId, boolean enabled, Consumer<Metrics.JsonObjectBuilder> appendPlatformDataConsumer, Consumer<Metrics.JsonObjectBuilder> appendServiceDataConsumer, Consumer<Runnable> submitTaskConsumer, Supplier<Boolean> checkServiceEnabledSupplier, BiConsumer<String, Throwable> errorLogger, Consumer<String> infoLogger, boolean logErrors, boolean logSentData, boolean logResponseStatusText) Creates a new MetricsBase class instance. -
Method Summary
Modifier and TypeMethodDescriptionvoidprivate voidChecks that the class was properly relocated.private static byte[]Gzips the given string.private voidvoidshutdown()private voidprivate void
-
Field Details
-
METRICS_VERSION
The version of the Metrics class.- See Also:
-
REPORT_URL
- See Also:
-
scheduler
-
platform
-
serverUuid
-
serviceId
private final int serviceId -
appendPlatformDataConsumer
-
appendServiceDataConsumer
-
submitTaskConsumer
-
checkServiceEnabledSupplier
-
errorLogger
-
infoLogger
-
logErrors
private final boolean logErrors -
logSentData
private final boolean logSentData -
logResponseStatusText
private final boolean logResponseStatusText -
customCharts
-
enabled
private final boolean enabled
-
-
Constructor Details
-
MetricsBase
public MetricsBase(String platform, String serverUuid, int serviceId, boolean enabled, Consumer<Metrics.JsonObjectBuilder> appendPlatformDataConsumer, Consumer<Metrics.JsonObjectBuilder> appendServiceDataConsumer, Consumer<Runnable> submitTaskConsumer, Supplier<Boolean> checkServiceEnabledSupplier, BiConsumer<String, Throwable> errorLogger, Consumer<String> infoLogger, boolean logErrors, boolean logSentData, boolean logResponseStatusText) Creates a new MetricsBase class instance.- Parameters:
platform- The platform of the service.serverUuid- The server uuid.serviceId- The id of the service.enabled- Whether or not data sending is enabled.appendPlatformDataConsumer- A consumer that receives aJsonObjectBuilderand appends all platform-specific data.appendServiceDataConsumer- A consumer that receives aJsonObjectBuilderand appends all service-specific data.submitTaskConsumer- A consumer that takes a runnable with the submit task. This can be used to delegate the data collection to a another thread to prevent errors caused by concurrency. Can benull.checkServiceEnabledSupplier- A supplier to check if the service is still enabled.errorLogger- A consumer that accepts log message and an error.infoLogger- A consumer that accepts info log messages.logErrors- Whether or not errors should be logged.logSentData- Whether or not the sent data should be logged.logResponseStatusText- Whether or not the response status text should be logged.
-
-
Method Details
-
addCustomChart
-
shutdown
public void shutdown() -
startSubmitting
private void startSubmitting() -
submitData
private void submitData() -
sendData
- Throws:
Exception
-
checkRelocation
private void checkRelocation()Checks that the class was properly relocated. -
compress
Gzips the given string.- Parameters:
str- The string to gzip.- Returns:
- The gzipped string.
- Throws:
IOException
-