Versions Compared

Key

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

...

To keep custom metrics detached from the internals, we should either automaticall add a prefix to custom name or throw an exception if provided metric registry name doesn't start with that prefix.

...

package org.apache.ignite;

/**
* Allows to addManages custom metrics. CustomNames of custom metrics registers isare always stored with namethe prefix "custom.".
* If provided registry name is "a.b.regname", it is automatically converted to "custom.a.b.regname".
* If the name is "custom.a.b.regname", it is used as is.
*/
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. {@code metric} otherwise.
*/
<T extends Metric> T metric(String registryName, String metricName, T metric);

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

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

/** Removes registry named '{@code registryName}'. */
void removeRegistry(String registryName);


// Simple typeEssential 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 metricName, @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 registryName, 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 metricName, @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 metricName, 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 metricName, 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 metricName, BooleanSupplier valueSupplier, @Nullable String description);


   // Additionnaly, we might expose an object metrics API.

/**
* Registers a {@link ObjectMetric} metric in registry {@code registryName} with object 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.
*/
<T> boolean objectMetric(String registryName, String metricName, Class<T> valueType, Supplier<T> valueSupplier, @Nullable String description);

/**
* Registers a {@link ObjectMetric} in registry {@code registryName} with object value supplier {@code valueSupplier}.
* Adds new metric registry if absent.
*
* @return New or previously registered object setter.
*/
<T> Consumer<T> objectMetric(String registryName, String metricName, Class<T> valueType, Supplier<T> valueSupplier, @Nullable String description);
}

...

  • Custom metrics can affect the performance.
  • There could be race conditions on metric registrations.
  • We do not provide varuous useful metric implementatons.
  • Custom metrics aren't stored and require re-registration after node restart. At least at the first phase.

Further Steps

We already have implementations of more complex and useful metrics. We could also store custom metrics. Thus, the development stages might be:

  1. Implementation of the initial API.
  2. Extending this API with metrics like Histogram, HitRate, LongAdder.
  3. Introduce a permission of custom metric management.
  4. Storing registered custom metrics.
  5. Allowing to change settings of configurable custom metrics like histograms.

References

  1. IEP-35 Monitoring & Profiling
  2. Ticket of a public metric API
  3. IEP-116 : Ignite 3 metric

Discussion Links

Tickets