Class StatsScope

java.lang.Object
org.microproxy.stats.StatsScope

public final class StatsScope extends Object
Metrics named <prefix>.<name> whose names come from outside the proxy, such as a script's (script.<name>), and of which there may be at most a fixed number: past it, new names get metrics that do nothing (and a warning is logged once), so their number stays bounded whatever names are asked for. Names already made keep working. Made by StatsRegistry.scope(java.lang.String, int).
  • Method Details

    • prefix

      public String prefix()
      Returns the prefix of this scope's names.
      Returns:
      the prefix of this scope's names
    • maxStats

      public int maxStats()
      Returns how many metrics the scope may make.
      Returns:
      how many metrics the scope may make
    • size

      public int size()
      Returns how many metrics the scope has made.
      Returns:
      how many metrics the scope has made
    • counter

      public Counter counter(String name)
      The counter <prefix>.<name>, made the first time while there is room.
      Parameters:
      name - the name within the scope
      Returns:
      the counter, or one that does nothing once the scope is full
      Throws:
      IllegalArgumentException - if the name is not valid, or names a metric of another kind
    • gauge

      public Gauge gauge(String name)
      The gauge <prefix>.<name>, made the first time while there is room.
      Parameters:
      name - the name within the scope
      Returns:
      the gauge, or one that does nothing once the scope is full
      Throws:
      IllegalArgumentException - if the name is not valid, or names a metric of another kind
    • histogram

      public Histogram histogram(String name)
      The histogram <prefix>.<name>, with the registry's bounds, made the first time while there is room.
      Parameters:
      name - the name within the scope
      Returns:
      the histogram, or one that does nothing once the scope is full
      Throws:
      IllegalArgumentException - if the name is not valid, or names a metric of another kind