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:
de.iip_ecosphere.platform.support.metrics.Gauge,de.iip_ecosphere.platform.support.metrics.Meter
public class GaugeRepresentation
extends MeterRepresentation
implements de.iip_ecosphere.platform.support.metrics.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:
The services offered by this class are:
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:
-
Nested Class Summary
Nested classes/interfaces inherited from interface de.iip_ecosphere.platform.support.metrics.Gauge
de.iip_ecosphere.platform.support.metrics.Gauge.GaugeBuilder<T>Nested classes/interfaces inherited from interface de.iip_ecosphere.platform.support.metrics.Meter
de.iip_ecosphere.platform.support.metrics.Meter.Id, de.iip_ecosphere.platform.support.metrics.Meter.Type -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate List<de.iip_ecosphere.platform.support.metrics.Measurement> private double -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateGaugeRepresentation(de.iip_ecosphere.platform.support.json.JsonObject object, String... tags) Initializes a new GaugeRepresentation.privateGaugeRepresentation(String name) Initializes a new GaugeRepresentation. -
Method Summary
Modifier and TypeMethodDescriptionstatic de.iip_ecosphere.platform.support.metrics.GaugecreateNewGauge(String name) Creates a new gauge with no value.de.iip_ecosphere.platform.support.json.JsonObjectProvides 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:Iterable<de.iip_ecosphere.platform.support.metrics.Measurement> measure()static de.iip_ecosphere.platform.support.metrics.GaugeparseGauge(de.iip_ecosphere.platform.support.json.JsonObject object, 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, getName, parseMeter, parseMeter, parseMeterQuietMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface de.iip_ecosphere.platform.support.metrics.Meter
getId, getName
-
Field Details
-
value
private double value -
measurements
-
-
Constructor Details
-
GaugeRepresentation
private GaugeRepresentation(de.iip_ecosphere.platform.support.json.JsonObject object, String... tags) Initializes a new GaugeRepresentation.- Parameters:
object- JsonObject representing the Gaugetags- tags that the counter has- Throws:
IllegalArgumentException- if the object isnull, or if the JsonObject doesn't represent a valid Gauge.
-
GaugeRepresentation
Initializes a new GaugeRepresentation.- Parameters:
name- URN of the gauge- Throws:
IllegalArgumentException- if the name is null or empty
-
-
Method Details
-
parseGauge
public static de.iip_ecosphere.platform.support.metrics.Gauge parseGauge(de.iip_ecosphere.platform.support.json.JsonObject object, 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:
IllegalArgumentException- if the object isnull, or if the JsonObject doesn't represent a valid Gauge.
-
createNewGauge
Creates a new gauge with no value.- Parameters:
name- URN of the gauge- Returns:
- a new Gauge ready to be used
- Throws:
IllegalArgumentException- if the name is null or empty
-
value
public double value()- Specified by:
valuein interfacede.iip_ecosphere.platform.support.metrics.Gauge
-
measure
- Specified by:
measurein interfacede.iip_ecosphere.platform.support.metrics.Meter- Specified by:
measurein classMeterRepresentation
-
getUpdater
public de.iip_ecosphere.platform.support.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:
-
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
-