Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Implementation proposal

General approach

  • Custom metrics might be experimental.
  • Custom Metrics are based on the New Metric System.
  • Allow to register essential ready-to-use metrics like LongMetric which can be exported by a existing metric exporter.
  • User can register own metrics into different registries.
  • Custom metrics are separated from the internals by registry name prefix "custom.".
  • Naming strategy of metrics and their registries are the same as of the provided metrics.
  • Management of custom metrics might require a permission.
  • We should document examples of effecient metrics implementations like LongAdder.

...

/**
* 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 {
/**
* 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) and all its metrics. */;
/** Removes certain registry

void removeRegistry(String registryName);


// Essential metrics. Int, Long and Double should be enough.
Return
/**
* Registers a {@link LongMetric}. Adds new metric registry if absent.
*
* @return Previous long value setter if it already exists. A new one otherwise.
*/
current or new metric.

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.
Return
/**
* Registers a {@link LongMetric} metric with value supplier {@code valueSupplier}. Addstrue if new metric registryis ifregistered absent.
*
* @return {@code True}of false if metric was added. {@code False} if mericis already exists.
*/

boolean longMetric(String fullName, LongSupplier valueSupplier, @Nullable String description)/**;

* Registers a {@link DoubleMetric} metric
with 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 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);
}

...