Class Metrics

java.lang.Object
org.jpos.util.Metrics
All Implemented Interfaces:
Loggeable

public class Metrics extends Object implements Loggeable
HdrHistogram-backed metrics aggregator with on-demand histogram creation per name.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Metrics(org.HdrHistogram.Histogram template)
    Constructs a Metrics instance using the given Histogram as a template for new buckets.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    dump(PrintStream ps, String indent)
    Dumps all metric percentile summaries to the given stream.
    void
    dumpHistograms(File dir, String prefix)
    Writes HDR histogram files for all metrics to the given directory.
    Map<String, org.HdrHistogram.Histogram>
    Returns a snapshot copy of all recorded histograms.
    Map<String, org.HdrHistogram.Histogram>
    metrics(String prefix)
    Returns a snapshot copy of all histograms whose name starts with the given prefix.
    void
    record(String name, long elapsed)
    Records an elapsed time observation for the named metric.
    void
    setConversion(double conversion)
    Sets the conversion divisor applied to percentile values during dump.

    Methods inherited from class Object

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

    Methods inherited from interface Loggeable

    dump
    Modifier and Type
    Method
    Description
    default void
    Dumps a representation of this object using the specified renderer type.
  • Constructor Details

    • Metrics

      public Metrics(org.HdrHistogram.Histogram template)
      Constructs a Metrics instance using the given Histogram as a template for new buckets.
      Parameters:
      template - the Histogram template; may be null
  • Method Details

    • metrics

      public Map<String, org.HdrHistogram.Histogram> metrics()
      Returns a snapshot copy of all recorded histograms.
      Returns:
      map of metric name to histogram copy
    • metrics

      public Map<String, org.HdrHistogram.Histogram> metrics(String prefix)
      Returns a snapshot copy of all histograms whose name starts with the given prefix.
      Parameters:
      prefix - the metric name prefix to filter by
      Returns:
      map of matching metric name to histogram copy
    • record

      public void record(String name, long elapsed)
      Records an elapsed time observation for the named metric.
      Parameters:
      name - the metric name
      elapsed - the elapsed value to record
    • dump

      public void dump(PrintStream ps, String indent)
      Dumps all metric percentile summaries to the given stream.
      Specified by:
      dump in interface Loggeable
      Parameters:
      ps - the output stream
      indent - indent prefix
    • dumpHistograms

      public void dumpHistograms(File dir, String prefix)
      Writes HDR histogram files for all metrics to the given directory.
      Parameters:
      dir - output directory
      prefix - filename prefix for histogram files
    • setConversion

      public void setConversion(double conversion)
      Sets the conversion divisor applied to percentile values during dump.
      Parameters:
      conversion - This is used to divide the percentile values while dumping. If you are using nano seconds to record and want to display the numbers in millis then conversion can be set to 1000000. By default conversion is set to 1.