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. We should allow user to register custom 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
GridMetricManager handles custom metrics.
package org.apache.ignite;
public interface Ignite {
public IgniteMetrics metrics();
}
package org.apache.ignite;
/**
* Custom metric manager. Allows to add own metrics in registers with names starting with "custom.".
*/
public interface IgniteMetrics {
/**
* Registers metric in register 'custom.' + {@code registryName}. Adds new register if absent.
*
* @return New {@code metric} or previous metric if it already exists with the same name.
*/
<T extends Metric> T metric(String registryName, String metricName, T metric);
/** Removes metric from register 'custom.' + {@code registryName}. */
void removeMetric(String registryName, String metricName);
/** @return Metric registry named '"custom." + {@code registryName}'. */
ReadOnlyMetricRegistry registry(String registryName);
/** Removes registry named '"custom." + {@code registryName}'. */
void removeRegistry(String registryName);
// Simple type metrics.
/**
* Registers a {@link LongMetric} in register 'custom.' + {@code registryName}. Adds registry if absent.
*
* @return New or previously registered long value setter.
*/
LongConsumer longMetric(String registryName, String metricName, @Nullable String description);
/**
* Registers a {@link DoubleMetric} in register 'custom.' + {@code registryName}. Adds registry if absent.
*
* @return New or previously registered double value setter.
*/
DoubleConsumer doubleMetric(String registryName, String metricName, @Nullable String description);
/**
* Registers a {@link BooleanMetric} in register 'custom.' + {@code registryName}. Adds registry if absent.
*
* @return New or previously registered boolean value setter.
*/
Consumer<Boolean> booleanMetric(String registryName, String metricName, @Nullable String description);
/**
* Registers a {@link ObjectMetric} in register 'custom.' + {@code registryName}. Adds registry if absent.
*
* @return New or previously registered object setter.
*/
<T> Consumer<T> objectMetric(String registryName, String metricName, Class<T> valueType, @Nullable String description);
// Might be useful the gauges:
/**
* Registers a {@link LongMetric} metric in register 'custom.' + {@code registryName} with long value supplier {@code valueSupplier}.
* Adds registry if absent.
*
* @return {@code True} if metric was added. {@code False} if another meric already exists under the same name.
*/
boolean longMetric(String registryName, String metricName, LongSupplier valueSupplier, @Nullable String description);
/**
* Registers a {@link DoubleMetric} metric in register 'custom.' + {@code registryName} with double value supplier {@code valueSupplier}.
* Adds registry if absent.
*
* @return {@code True} if metric was added. {@code False} if another meric already exists under the same name.
*/
boolean doubleMetric(String registryName, String metricName, DoubleSupplier valueSupplier, @Nullable String description);
/**
* Registers a {@link BooleanMetric} metric in register 'custom.' + {@code registryName} with boolean value supplier {@code valueSupplier}.
* Adds registry if absent.
*
* @return {@code True} if metric was added. {@code False} if another meric already exists under the same name.
*/
boolean booleanMetric(String registryName, String metricName, BooleanSupplier valueSupplier, @Nullable String description);
/**
* Registers a {@link ObjectMetric} metric in register 'custom.' + {@code registryName} with object value supplier {@code valueSupplier}.
* Adds registry if absent.
*
* @return {@code True} if metric was added. {@code False} if another meric already exists under the same name.
*/
<T> boolean objectMetric(String registryName, String metricName, Class<T> valueType, Supplier<T> valueSupplier, @Nullable String description);
}
The custom metric API might be also enriched with more complex metrics like historgams. We could also store custom metrics and their configurations. Thus, the development steps might be: