...
...
To keep custom metrics detached from the internals, we should either automaticall add a name prefix to custom name or throw an exception if provided registry name doesn't start with that prefix.
...
/**
* Manages custom metrics.
*
* Metrics have are grouped into registries. Every metric has full name which is conjunction of registry name and aremetric groupedname. into
registries.* Registry name is part of the full metric name until last '.'.
* Metric name is the last part of the full name. Names of custom metrics registers
*
* Full names and registry names are always prefixed with "custom.".
* For example, if provided full name is "a.b.c.mname",
* it is automatically converted to "custom.a.b.c.mname".
* If full name is "custom.a.b.c.mname", it is used as is.
* Where "custom.a.b.c" is thea registry name and "mname" is thea metric name.
*/
public interface IgniteCustomMetrics {
/**
* Registers metric. Adds new metric registry if absent.
*
* @return Previous metric if it already exists. Otherwise, {@code metric}.
*/
<T extends Metric> T metric(String fullName, T metric);
/** Removes metric. */
void removeMetric(String fullName);
/** @return Certain metric registry. */
ReadOnlyMetricRegistry registry(String registryName);
/** Removes certain registry named '{@code registryName}' and all its metrics. */
void removeRegistry(String registryName);
// Essential metrics. Int, Long and Double should be enough.
/**
* Registers a {@link LongMetric}. Adds new metric registry if absent.
*
* @return Previous long value setter if it already exists. A new one otherwise.
*/
LongConsumer longMetric(String fullName, @Nullable String description);
/**
* Registers a {@link DoubleMetric}. Adds new metric registry if absent.
*
* @return Previous double value setter if it already exists. A new one otherwise.
*/
DoubleConsumer doubleMetric(String fullName, @Nullable String description);
/**
* Registers a {@link IntMetric}. Adds new metric registry if absent.
*
* @return Previous int value setter if it already exists. A new one otherwise.
*/
IntConsumer booleanMetric(String fullName, @Nullable String description);
// Might be useful the gauges.
/**
* Registers a {@link LongMetric} metric with long value supplier {@code valueSupplier}. Adds new metric registry if absent.
*
* @return {@code True} if metric was added. {@code False} if meric already exists.
*/
boolean longMetric(String fullName, LongSupplier valueSupplier, @Nullable String description);
/**
* Registers a {@link DoubleMetric} metric with double value supplier {@code valueSupplier}. Adds new metric registry if absent.
*
* @return {@code True} if metric was added. {@code False} if meric already exists.
*/
boolean doubleMetric(String fullName, DoubleSupplier valueSupplier, @Nullable String description);
/**
* Registers a {@link IntMetric} metric with int value supplier {@code valueSupplier}. Adds new metric registry if absent.
*
* @return {@code True} if metric was added. {@code False} if meric already exists.
*/
boolean intMetric(String fullName, BooleanSupplier valueSupplier, @Nullable String description);
}
...