Versions Compared

Key

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

...

  • Custom Metrics are based on the New Metric System.
  • Provide essential ready-to-use metrics like LongMetric which can be exported by a existing metric exporter.
  • User can store own metrics in different registers corresponding to metrics groups.
  • Custom metrics are separated from the internals by registry name by name prefix "custom.".
  • Custom metrics management might require a permission.
  • We should document examples of effecient metrics implementations like LongAdder.

...

/**
* Manages custom metrics. Metrics have full name and are grouped 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 are always storedprefixed with the prefix "custom.".
* For example, Ifif provided registryfull name is "a.b.c.regnamemname", it is automatically converted to "custom.a.b.c.regnamemname".
* If thefull name is "custom.a.b.c.regnamemname", it is used as is. Where "custom.a.b.c" is the registry name and "mname" is the metric name.
*/
public interface IgniteCustomMetrics {
/**
* Registers metric in registry {@code registryName}. Adds new metric registry if absent.
*
* @return Previous metric if it already exists. with the same name. Otherwise, {@code metric} otherwise.
*/
<T extends Metric> T metric(String registryName, String metricNamefullName, T metric);

/** Removes metric from registry {@code registryName}. */
void removeMetric(String registryName, String metricNamefullName);

/** @return Certain Metricmetric registry named '{@code registryName}'. */
ReadOnlyMetricRegistry registry(String registryName);

/** Removes 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} in registry {@code registryName}. Adds new metric registry if absent.
*
* @return Previous long value setter if it already exists with the same name. A new one otherwise.
*/
LongConsumer longMetric(String registryName, String metricNamefullName, @Nullable String description);

/**
* Registers a {@link DoubleMetric} in registry {@code registryName}. Adds new metric registry if absent.
*
* @return Previous double value setter if it already exists with the same name. A new one otherwise.
*/
DoubleConsumer doubleMetric(String registryNamefullName, String metricName, @Nullable String description);

/**
* Registers a {@link IntMetric} in registry {@code registryName}. Adds new metric registry if absent.
*
* @return Previous int value setter if it already exists with the same name. A new one otherwise.
*/
IntConsumer booleanMetric(String registryName, String metricNamefullName, @Nullable String description);



// Might be useful the gauges.

/**
* Registers a {@link LongMetric} metric in registry {@code registryName} with long value supplier {@code valueSupplier}.
* Adds new metric 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 metricNamefullName, LongSupplier valueSupplier, @Nullable String description);

/**
* Registers a {@link DoubleMetric} metric in registry {@code registryName} with double value supplier {@code valueSupplier}.
*
Adds new metric 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 metricNamefullName, DoubleSupplier valueSupplier, @Nullable String description);

/**
* Registers a {@link IntMetric} metric in registry {@code registryName} with int value supplier {@code valueSupplier}.
* Adds new metric registry if absent.
*
* @return {@code True} if metric was added. {@code False} if another meric already exists under the same name.
*/
boolean intMetric(String registryName, String metricNamefullName, BooleanSupplier valueSupplier, @Nullable String description);
}

...