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:
{
    "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
  • 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

    Fields
    Modifier and Type
    Field
    Description
    private List<de.iip_ecosphere.platform.support.metrics.Measurement>
     
    private double
     
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    private
    GaugeRepresentation(de.iip_ecosphere.platform.support.json.JsonObject object, String... tags)
    Initializes a new GaugeRepresentation.
    private
    Initializes a new GaugeRepresentation.
  • Method Summary

    Modifier and Type
    Method
    Description
    static de.iip_ecosphere.platform.support.metrics.Gauge
    Creates a new gauge with no value.
    de.iip_ecosphere.platform.support.json.JsonObject
    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:
    Iterable<de.iip_ecosphere.platform.support.metrics.Measurement>
     
    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.
    void
    setValue(double value)
    Changes the value of this gauge to the requested value.
    double
     

    Methods inherited from class de.iip_ecosphere.platform.services.environment.metricsProvider.meterRepresentation.MeterRepresentation

    getId, getName, parseMeter, parseMeter, parseMeterQuiet

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface de.iip_ecosphere.platform.support.metrics.Meter

    getId, getName
  • Field Details

    • value

      private double value
    • measurements

      private List<de.iip_ecosphere.platform.support.metrics.Measurement> 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 Gauge
      tags - tags that the counter has
      Throws:
      IllegalArgumentException - if the object is null, or if the JsonObject doesn't represent a valid Gauge.
    • GaugeRepresentation

      private GaugeRepresentation(String name)
      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 parse
      tags - tags that the gauge has following the format key:value
      Returns:
      a Gauge representation of the JsonObject
      Throws:
      IllegalArgumentException - if the object is null, or if the JsonObject doesn't represent a valid Gauge.
    • createNewGauge

      public static de.iip_ecosphere.platform.support.metrics.Gauge createNewGauge(String name)
      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:
      value in interface de.iip_ecosphere.platform.support.metrics.Gauge
    • measure

      public Iterable<de.iip_ecosphere.platform.support.metrics.Measurement> measure()
      Specified by:
      measure in interface de.iip_ecosphere.platform.support.metrics.Meter
      Specified by:
      measure in class MeterRepresentation
    • 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:
      getUpdater in class MeterRepresentation
      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