ID | IEP-114 |
Author | |
Sponsor | |
Created | |
Status | DRAFT |
It is useful for user to work with own metrics, not only with provided by Ignite. Current public metrics API doesn't expose any method to add or delete additional metrics.
The most important reason to provide custom is probably the convenience of collecting of desired metrics using one platform, the same client, through the same API. This feature can simplify user application.
Oracle DB , Postgres , Oracle Coherence , MS SQL Server , IBM DB2
In future, we might want to provide an internal API to obtain metrics like this. It could be quite different and we should split them.
package org.apache.ignite;
public interface Ignite {
public IgniteCustomMetrics metrics();
}
To keep custom metrics detached from the internals, we should either automaticall add a name prefix or throw an exception if provided name doesn't start with that prefix.
package org.apache.ignite;
/**
* Manages custom metrics.
*
* Metrics are grouped into registries. Every metric has full name which is conjunction of registry name and metric name.
* Registry name is part of the full name until last '.'. Metric name is the last part of the full name.
*
* 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 a registry name and "mname" is a metric name.
*/
@IgniteExperimental
public interface IgniteCustomMetrics {
<T extends Metric> T metric(String fullName, T metric);
void removeMetric(String fullName);
ReadOnlyMetricRegistry registry(String registryName);
void removeRegistry(String registryName);
// Essential metrics. Int, Long and Double should be enough. Return current or new metric.
LongConsumer longMetric(String fullName, @Nullable String description);
DoubleConsumer doubleMetric(String fullName, @Nullable String description);
IntConsumer booleanMetric(String fullName, @Nullable String description);
// Might be useful the gauges. Return true if new metric is registered of false if metric is already exists.
boolean longMetric(String fullName, LongSupplier valueSupplier, @Nullable String description);
boolean doubleMetric(String fullName, DoubleSupplier valueSupplier, @Nullable String description);
boolean intMetric(String fullName, BooleanSupplier valueSupplier, @Nullable String description);
}
We already have implementations of more complex and useful metrics. We could also store custom metrics. Thus, the development stages might be: