Versions Compared

Key

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

...

  • Some metrics may not be provided yet and user registers own.
  • Metrics for load balancing.
  • Various metrics of business processes or related to user application.
  • Administration metrics.
  • Security-related metrics.

Examples  Examples of databases with custom metrics

...

package org.apache.ignite;

public

...

interface

...

Ignite

...

{

...

    IgniteMetrics metrics();

}

3.  Interfaces for existing metrics.

Instead of #4, we could create interfaces for the existing metrics implementations.

3.1 IgniteMetric

package

...

org.apache.ignite.metric;

/**

...

*

...

Allows

...

to

...

manage

...

custom

...

metrics

...

and

...

to

...

obtain

...

read-only

...

internal

...

metrics.

...

*

...

*

...

Note:

...

Names

...

of

...

custom

...

metric

...

registries

...

are

...

required

...

to

...

start

...

with

...

'custom.'

...

(lower

...

case)

...

and

...

may

...

have

...

additional

...

*

...

dot-separated

...

qualifiers.

...

The

...

prefix

...

is

...

automatically

...

added

...

if

...

missed.

...

For

...

example,

...

if

...

provided

...

custom

...

registry

...

name

...


...

*

...

is

...

"a.b.c.mname",

...

it

...

is

...

automatically

...

extended

...

to

...

"custom.a.b.c.mname".

...

*

...


...

*

...

Any

...

custom

...

name

...

or

...

dot-separated

...

name

...

part

...

cannot

...

have

...

spaces

...

and

...

must

...

not

...

be

...

empty.

...

Spaces

...

are

...

removed.

...

*

...


...

*

...

Examples

...

of

...

custom

...

metric

...

registry

...

names:

...

"custom",

...

"custom.admin",

...

"custom.admin.sessions",

...

"custom.processes",

...

etc.

...

*

...

*

...

@see

...

ReadOnlyMetricRegistry

...

*

...

@see

...

IgniteMetricRegistry

...

*/
@IgniteExperimental
public

...

interface

...

IgniteMetrics

...

extends

...

Iterable<ReadOnlyMetricRegistry>

...

{

...

    /**

...

    * Gets or creates custom metric registry named "custom."

...

+

...

{@code

...

registryName}.

...

    *

...

    * @return {@link

...

IgniteMetricRegistry}

...

registry.

...

    */

...

    IgniteMetricRegistry customRegistry(String

...

registryName);

...


    /**

...

    * Gets or creates custom metric registry named "custom.".

...

    *

...

    * @return {@link

...

IgniteMetricRegistry}

...

registry.

...

   */

...

    default IgniteMetricRegistry customRegistry()

...

{

...

        return customRegistry(null);

...

    }

...


    /**

...

    * Gets metric registry including the Ignite's

...

internal

...

registries.

...

    *

...

    * @return Certain read-only

...

metric

...

registry.

...

    */

...

    @Nullable ReadOnlyMetricRegistry findRegistry(String

...

registryName);

...


    /**

...

*/

...

    void removeCustomRegistry(String

...

registryName);

...


    /**

...

Removes

...

custom

...

metric

...

registry

...

with

...

name

...

'.custom'./

...

    default void removeCustomRegistry()

...

{

...

        removeCustomRegistry(null);

...

    }
}

3.2 IgniteMetricRegistry

Probably should be named "MetricRegistry" with renaming of internal "MetricRegistry" to "MetricRegistryImpl".  


package

...

org.apache.ignite.metric;

/**

...

*

...

Metric

...

registry.

...

Allows

...

to

...

get,

...

add

...

or

...

remove

...

metrics.

...

*

...

*

...

@see

...

IgniteMetrics

...

*

...

@see

...

ReadOnlyMetricRegistry

...

*/
@IgniteExperimental
public

...

interface

...

IgniteMetricRegistry

...

extends

...

ReadOnlyMetricRegistry

...

{

...

    /**

...

    * Registers an int metric which value will be queried from the specified supplier.
    *
    * @return {@code True} if new metric was added. {@code False} is other metric already exists with the same name.
    */
    boolean gauge(String name, IntSupplier supplier, @Nullable String desc);

    /**
    * Registers a long which value will be queried from the specified supplier.
    *
    * @return {@code True} if new metric was added. {@code False} is other metric already exists with the same name.
    */
    boolean gauge(String name, LongSupplier supplier, @Nullable String desc);

    /**
    * Registers a double metric which value will be queried from the specified supplier.
    *
    * @return {@code True} if new metric was added. {@code False} is other metric already exists with the same name.
    */
    boolean gauge(String name, DoubleSupplier supplier, @Nullable String desc);

    /**
    * Registers an object metric which value will be queried from the specified supplier.
    *
    * @return {@code True} if new metric was added. {@code False} is other metric already exists with the same name.
    */
    <T> boolean gauge(String name, Supplier<T> supplier, Class<T> type, @Nullable String desc);

    /**
    * Registers a boolean metric which value will be queried from the specified supplier.
    *
    * @return {@code True} if new metric was added. {@code False} is other metric already exists with the same name.
    */
    boolean gauge(String name, BooleanSupplier supplier, @Nullable String desc);

    /**
    * Registers an updatable int metric.
    *
    * @return New {@link IntValueMetric} or previous one with the same name. {@code Null} if previous metric exists and
    * is not a {@link IntValueMetric}.
    */
    @Nullable IntValueMetric intMetric(String name, @Nullable String desc);

    /**
    * Registers an updatable long metric.
    *
   * @return New {@link LongValueMetric} or previous one with the same name. {@code Null} if previous metric exists and
    * is not a {@link LongValueMetric}.
    */
    @Nullable LongValueMetric longMetric(String name, @Nullable String desc);

    /**
    * Registers an updatable long adder metric.
    *
    * @return New {@link LongValueMetric} or previous one with the same name. {@code Null} if previous metric exists and
    * is not a {@link LongValueMetric}.
    */
    @Nullable LongSumMetric longAdderMetric(String name, @Nullable String desc);

    /**
    * Registers an updatable double metric.
    *
    * @return New {@link DoubleValueMetric} or previous one with the same name. {@code Null} if previous metric exists and
    * is not a {@link DoubleValueMetric}.
    */
    @Nullable DoubleValueMetric doubleMetric(String name, @Nullable String desc);

    /**
    * Registers an updatable double metric.
    *
    * @param <T> Metric value type.
    * @return New {@link CustomMetric} or previous one with the same name. {@code Null} if previous metric exists and
    * is not a {@link CustomMetric}.
    */
    @Nullable <T> AnyValueMetric<T> objectMetric(String name, Class<T> type, @Nullable String desc);

    /**
    * Removes metrics with the {@code name}.
    *
    * @param name Metric name..
    */
    void remove(String name);

    /** Resets all metrics of this metric registry. */
    void reset();
}

3.3 New writeable metric intefraces

...

3.4 Examples of new  writeable metric intefraces

package

...

org.apache.ignite.metric;

/**

...

Updatable

...

object

...

value

...

metric.

...

*/
@IgniteExperimental
public

...

interface

...

AnyValueMetric<T>

...

extends

...

ObjectMetric<T>

...

{

...

    /**

...

Sets

...

object

...

metric

...

value./

...

    void value(T

...

value);
}

...



/**

...

Updatable

...

simple

...

double

...

value

...

metric.

...

*/
@IgniteExperimental
public

...

interface

...

DoubleValueMetric

...

extends

...

DoubleMetric

...

{

...

    /**

...

Raises

...

metric

...

value.

...

*/

...

    void add(double

...

value);

...


    /**

...

Sets

...

double

...

metric

...

value.

...

*/

...

    void value(double

...

value);
}

/**

...

Updatable

...

long

...

metric

...

which

...

is

...

efficient

...

with

...

adding

...

values.

...

Calculates

...

sum

...

in

...

{@link

...

LongMetric#value()}.

...

*/
@IgniteExperimental
public

...

interface

...

LongSumMetric

...

extends

...

LongMetric

...

{

...

    /**

...

Raises

...

metric

...

value.

...

*/

...

    void add(long

...

value);

...


    /**

...

Increments

...

metric

...

value

...

with

...

1L.

...

*/

...

    void increment();

...


    /**

...

Decrements

...

metric

...

value

...

with

...

-1L.

...

*/

...

    void decrement();
}

/**

...

Updatable

...

simple

...

long

...

value

...

metric.

...

*/
@IgniteExperimental
public

...

interface

...

LongValueMetric

...

extends

...

LongSumMetric

...

{

...

    /**

...

Sets

...

long

...

metric

...

value.

...

*/

...

    void value(long

...

value);
}

4. Minimal Custom Metric interface

...

package org.apache.ignite;

/**

...

*

...

Allows

...

to

...

manage

...

custom

...

metrics

...

and

...

to

...

obtain

...

read-only

...

internal

...

metrics.

...

*

...

<p>

...

*

...

Metrics

...

are

...

grouped

...

into

...

registries

...

(groups).

...

Every

...

metric

...

has

...

full

...

name

...

which

...

is

...

the

...

conjunction

...

of

...

registry

...

name

...


...

*

...

and

...

the

...

metric

...

short

...

name.

...

Within

...

a

...

registry

...

metric

...

has

...

only

...

its

...

own

...

short

...

name.

...

*

...

<p>

...

*

...

Note:

...

Names

...

of

...

custom

...

metric

...

registries

...

are

...

required

...

to

...

start

...

with

...

'custom.'

...

(lower

...

case)

...

and

...

may

...

have

...

additional

...

*

...

dot-separated

...

qualifiers.

...

The

...

prefix

...

is

...

automatically

...

added

...

if

...

missed.

...

For

...

example,

...

if

...

provided

...

custom

...

registry

...

name

...

*

...

is

...

"a.b.c.mname",

...

it

...

is

...

automatically

...

extended

...

to

...

"custom.a.b.c.mname".

...

*

...

<p>

...

*

...

Any

...

custom

...

name

...

or

...

dot-separated

...

name

...

part

...

cannot

...

have

...

spaces

...

and

...

must

...

not

...

be

...

empty.

...

Spaces

...

are

...

removed.

...

*

...

<p>

...

*

...

Examples

...

of

...

custom

...

metric

...

registry

...

names:

...

"custom",

...

"custom.admin",

...

"custom.admin.sessions",

...

"custom.processes",

...

etc.

...

*

...

*

...

@see

...

ReadOnlyMetricRegistry

...

*

...

@see

...

IgniteMetricRegistry

...

*/
@IgniteExperimental
public

...

interface

...

IgniteMetrics

...

extends

...

Iterable<ReadOnlyMetricRegistry>

...

{

...

    /**

...

    * Adds a long value custom metric.
    *
    * @return New or previously registered long value metric. {@code Null} if previous metric is not a {@link LongConsumer}.
    */
    @Nullable LongConsumer longMetric(String registryName, String metricName, @Nullable String description);

    /**
    * Adds a double value custom metric.
    *
    * @return New or previously registered long value metric. {@code Null} if previous metric is not a {@link DoubleConsumer}.
    */
    @Nullable DoubleConsumer doubleMetric(String registryName, String metricName, @Nullable String description);

    /**
    * Adds a int value custom metric.
    *
    * @return New or previously registered long value metric. {@code Null} if previous metric is not an {@link IntConsumer}.
    */
    @Nullable IntConsumer booleanMetric(String registryName, String metricName, @Nullable String description);

    /**
    * Adds a long value custom metric.
    *
    * @return {@code True} if {@code supplier} has been registered as a new int metric. {@code False}, if a previous
    * value supplier already exists.
    */
    boolean longMetric(String registryName, String metricName, LongSupplier supplier, @Nullable String description);

    /**
    * Adds a double value custom metric.
    *
    * @return {@code True} if {@code supplier} has been registered as a new int metric. {@code False}, if a previous
    * value supplier already exists.
    */
    boolean doubleMetric(String registryName, String metricName, DoubleSupplier supplier, @Nullable String description);

    /**
    * Adds a int value custom metric.
    *
    * @return {@code True} if {@code supplier} has been registered as a new int metric. {@code False}, if a previous
    * value supplier already exists.
    */
    boolean intMetric(String registryName, String metricName, BooleanSupplier supplier, @Nullable String description);

    /** Removes certain custom metric. */
    void removeCustomMetric(String registryName, String metricName);

    /** Removes entire custom metric registry. */
    void removeCustomRegistry(String registryName);

    /** Provides custom or internal read-only metric registry. */
    @Nullable ReadOnlyMetricRegistry findRegistry(String registryName);
}

Further Steps


Further Steps

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

...