Class GaugeRepresentation
- java.lang.Object
-
- de.iip_ecosphere.platform.services.environment.metricsProvider.meterRepresentation.MeterRepresentation
-
- de.iip_ecosphere.platform.services.environment.metricsProvider.meterRepresentation.GaugeRepresentation
-
- All Implemented Interfaces:
io.micrometer.core.instrument.Gauge,io.micrometer.core.instrument.Meter
public class GaugeRepresentation extends MeterRepresentation implements io.micrometer.core.instrument.Gauge
This class aims to provide a prototypical implementation of the Gauge Interface from Micrometer-API, allowing a client process to access the Gauge values collected from a Service in a uniform way.
Even though the methods are functional and will indeed offer an accurate implementation of the metric we are simulating with this prototype, it is highly recommended that an instance of this class is used solely to access data and not to modify it, as the changes will not be registered in any sort of registry under normal circumstances, and this will alter the read values of the actual metrics.
A gauge tracks a value that may go up or down. The value that is published for gauges is an instantaneous sample of the gauge at publishing time.
The JsonObject representing a Gauge will have the following format:
{ "name": "sample.name", "description": "sample description, can be null", "baseUnit": "sample's.baseUnit", "measurements": [ { "statistic": "VALUE", "value": 123.123 } ], "availableTags": [] }Special attention is required in the keys for the JsonValues as well as the type of Statistic and number of measurements.
The services offered by this class are:- Parse a JsonObject into a Gauge
- Check the gauge's value
- Author:
- Miguel Gomez
- See Also:
Gauge
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.List<io.micrometer.core.instrument.Measurement>measurementsprivate doublevalue
-
Constructor Summary
Constructors Modifier Constructor Description privateGaugeRepresentation(java.lang.String name)Initializes a new GaugeRepresentation.privateGaugeRepresentation(javax.json.JsonObject object, java.lang.String... tags)Initializes a new GaugeRepresentation.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static io.micrometer.core.instrument.GaugecreateNewGauge(java.lang.String name)Creates a new gauge with no value.javax.json.JsonObjectgetUpdater()Provides an updater for the Gauge.
The update information for a Gauge is simply the name an the value of the Gauge.This information is packed into a JSON Object with the following format:java.lang.Iterable<io.micrometer.core.instrument.Measurement>measure()static io.micrometer.core.instrument.GaugeparseGauge(javax.json.JsonObject object, java.lang.String... tags)Parses a new gauge from a JsonObject.
See the class documentation to see the format of a JsonObject representing a Gauge is expecting to have.voidsetValue(double value)Changes the value of this gauge to the requested value.doublevalue()-
Methods inherited from class de.iip_ecosphere.platform.services.environment.metricsProvider.meterRepresentation.MeterRepresentation
getId, parseMeter, parseMeter, parseMeterQuiet
-
-
-
-
Constructor Detail
-
GaugeRepresentation
private GaugeRepresentation(javax.json.JsonObject object, java.lang.String... tags)Initializes a new GaugeRepresentation.- Parameters:
object- JsonObject representing the Gaugetags- tags that the counter has- Throws:
java.lang.IllegalArgumentException- if the object isnull, or if the JsonObject doesn't represent a valid Gauge.
-
GaugeRepresentation
private GaugeRepresentation(java.lang.String name)
Initializes a new GaugeRepresentation.- Parameters:
name- URN of the gauge- Throws:
java.lang.IllegalArgumentException- if the name is null or empty
-
-
Method Detail
-
parseGauge
public static io.micrometer.core.instrument.Gauge parseGauge(javax.json.JsonObject object, java.lang.String... tags)Parses a new gauge from a JsonObject.
See the class documentation to see the format of a JsonObject representing a Gauge is expecting to have.- Parameters:
object- JsonObject representing the Gauge we wish to parsetags- tags that the gauge has following the formatkey:value- Returns:
- a Gauge representation of the JsonObject
- Throws:
java.lang.IllegalArgumentException- if the object isnull, or if the JsonObject doesn't represent a valid Gauge.
-
createNewGauge
public static io.micrometer.core.instrument.Gauge createNewGauge(java.lang.String name)
Creates a new gauge with no value.- Parameters:
name- URN of the gauge- Returns:
- a new Gauge ready to be used
- Throws:
java.lang.IllegalArgumentException- if the name is null or empty
-
value
public double value()
- Specified by:
valuein interfaceio.micrometer.core.instrument.Gauge
-
measure
public java.lang.Iterable<io.micrometer.core.instrument.Measurement> measure()
- Specified by:
measurein interfaceio.micrometer.core.instrument.Gauge- Specified by:
measurein interfaceio.micrometer.core.instrument.Meter- Specified by:
measurein classMeterRepresentation
-
getUpdater
public javax.json.JsonObject getUpdater()
Provides an updater for the Gauge.
The update information for a Gauge is simply the name an the value of the Gauge.This information is packed into a JSON Object with the following format:{ "name":"customgauge", "value":123.4 }- Specified by:
getUpdaterin classMeterRepresentation- Returns:
- a JsonObject representing the changes this meter has experienced
- See Also:
MeterRepresentation.getUpdater()
-
setValue
public void setValue(double value)
Changes the value of this gauge to the requested value.- Parameters:
value- new value we want this Gauge to have
-
-