Versions Compared

Key

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

...

/**
* Manages custom metrics. Names of custom metrics registers are always stored with the 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);


// 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 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);
}

Risks and Assumptions

  • 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.

...