ID | IEP-114 | ||||||||
Author | |||||||||
Sponsor | |||||||||
Created | |||||||||
Status |
|
Table of Contents |
---|
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.
Famous databases with custom metrics: Oracle DB , Postgres , Oracle Coherence , MS SQL Server , IBM DB2
Examples of custom metric usages:
To give an user the ability to register additional metrics, we could either:
These two approaches are shown below.
The APIs are supposed to be experimental.
Code Block | ||
---|---|---|
| ||
package org.apache.ignite.metric; public interface IgniteMetrics extends Iterable<ReadOnlyMetricRegistry> { MetricRegistry customRegistry(String registryName); @Nullable ReadOnlyMetricRegistry findRegistry(String registryName); void removeCustomRegistry(String registryName); } |
Code Block | ||
---|---|---|
| ||
package org.apache.ignite.metric; public interface MetricRegistry extends ReadOnlyMetricRegistry { IntMetric register(String name, IntSupplier supplier, @Nullable String desc); LongMetric register(String name, LongSupplier supplier, @Nullable String desc); DoubleMetric register(String name, DoubleSupplier supplier, @Nullable String desc); <T> ObjectMetric<T> register(String name, Supplier<T> supplier, Class<T> type, @Nullable String desc); BooleanMetric register(String name, BooleanSupplier supplier, @Nullable String desc); IntValueMetric intMetric(String name, @Nullable String desc); LongValueMetric longMetric(String name, @Nullable String desc); LongSumMetric longAdderMetric(String name, @Nullable String desc); DoubleValueMetric doubleMetric(String name, @Nullable String desc); <T> ObjectValueMetric<T> objectMetric(String name, Class<T> type, @Nullable String desc); void remove(String name); void reset(); } |
To the package "org.apache.ignite.metric" we add:
Names like "LongMetric" or "ObjectMetric" we already have in the package "org.apache.ignite.spi.metric".
Code Block | ||
---|---|---|
| ||
package org.apache.ignite.metric; public interface ObjectValueMetric<T> extends ObjectMetric<T> { void value(T value); } public interface DoubleValueMetric extends DoubleMetric { void add(double value); void value(double value); } public interface LongSumMetric extends LongMetric { void add(long value); void increment(); void decrement(); } public interface LongValueMetric extends LongSumMetric { void value(long value); } |
Instead of the interfeces set above, we could bring only a minimal metric management interface.
Code Block | ||
---|---|---|
| ||
package org.apache.ignite; public interface IgniteMetrics extends Iterable<ReadOnlyMetricRegistry> { LongConsumer longMetric(String registryName, String metricName, @Nullable String description); DoubleConsumer doubleMetric(String registryName, String metricName, @Nullable String description); IntConsumer booleanMetric(String registryName, String metricName, @Nullable String description); void longMetric(String registryName, String metricName, LongSupplier supplier, @Nullable String description); void doubleMetric(String registryName, String metricName, DoubleSupplier supplier, @Nullable String description); void intMetric(String registryName, String metricName, BooleanSupplier supplier, @Nullable String description); void removeCustomMetric(String registryName, String metricName); void removeCustomRegistry(String registryName); @Nullable ReadOnlyMetricRegistry findRegistry(String registryName); } |
Expand | ||
---|---|---|
| ||
/** */ // Registers metric "custom.service.svc.filteredInvocation" ignite.metrics().customRegistry(regName(ctx.name())).gauge("filteredInvocation", metricValue::get, "Counter of speceific service invocation."); // Registers metric "custom.service.svc.loaded" // Registers metric "custom.service.svc.remote.classId" |
Expand | ||
---|---|---|
| ||
/** */ // Registers metric "custom.task.test.current" LongValueMetric metricCur = ignite.metrics().customRegistry("task.test").longMetric("current", null); // Registers metric "custom.task.test.total.sum" LongSumMetric metricTotal = ignite.metrics().customRegistry("task.test").longAdderMetric("total.sum", null); // Registers metric "custom.task.test.ticks" LongSumMetric metricTicks = ignite.metrics().customRegistry("task.test").longAdderMetric("ticks", null); } |
We already have implementations of more complex and useful metrics. We could also store custom metrics. Thus, the development stages might be:
Custom metric introduction | IGNITE-21156 |
---|