Class AbstractMetricsClient

java.lang.Object
com.itrsgroup.collection.instr.AbstractMetricsClient
All Implemented Interfaces:
MetricsClient, AutoCloseable
Direct Known Subclasses:
StatsdClientImpl

public abstract class AbstractMetricsClient extends Object implements MetricsClient
Base class for MetricsClient implementations.
  • Field Details

    • NO_DIMENSIONS

      protected static final Set<Dimension> NO_DIMENSIONS
  • Constructor Details

    • AbstractMetricsClient

      protected AbstractMetricsClient(long samplingInterval, Consumer<Throwable> errorCallback)
      Create a client with a single-threaded task executor.
      Parameters:
      samplingInterval - interval (in millis) for periodic metric sampling
      errorCallback - callback via which post-construction exceptions are reported
      Throws:
      IllegalArgumentException - if samplingInterval or threadPoolSize is less than one
      NullPointerException - if errorCallback is null
    • AbstractMetricsClient

      protected AbstractMetricsClient(long samplingInterval, Consumer<Throwable> errorCallback, int threadPoolSize)
      Create a client.
      Parameters:
      samplingInterval - interval (in millis) for periodic metric sampling
      errorCallback - callback via which post-construction exceptions are reported
      threadPoolSize - number of threads to create in the executor's thread pool
      Throws:
      IllegalArgumentException - if samplingInterval or threadPoolSize is less than one
      NullPointerException - if errorCallback is null
  • Method Details

    • shouldSample

      protected boolean shouldSample(double sampleRate)
      Whether an instrumentation should be sampled based on the given sample rate.
      Parameters:
      sampleRate - sample rate
      Returns:
      whether to sample
    • attribute

      public void attribute(String metric, String value)
      Description copied from interface: MetricsClient
      Set the specified attribute's value.
      Specified by:
      attribute in interface MetricsClient
      Parameters:
      metric - attribute name
      value - attribute value
    • attribute

      public void attribute(String namespace, String metric, String value)
      Description copied from interface: MetricsClient
      Set the specified attribute's value.
      Specified by:
      attribute in interface MetricsClient
      Parameters:
      namespace - attribute namespace
      metric - attribute name
      value - attribute value
    • attribute

      public void attribute(String metric, String value, Set<Dimension> dimensions)
      Description copied from interface: MetricsClient
      Set the specified attribute's value.
      Specified by:
      attribute in interface MetricsClient
      Parameters:
      metric - attribute name
      value - attribute value
      dimensions - dimensions identifying the entity
    • attribute

      public void attribute(String namespace, String metric, String value, Set<Dimension> dimensions)
      Description copied from interface: MetricsClient
      Set the specified attribute's value.
      Specified by:
      attribute in interface MetricsClient
      Parameters:
      namespace - attribute namespace
      metric - attribute name
      value - attribute value
      dimensions - dimensions identifying the entity
    • increment

      public void increment(String metric)
      Description copied from interface: MetricsClient
      Increment the counter by 1.
      Specified by:
      increment in interface MetricsClient
      Parameters:
      metric - metric name
    • increment

      public void increment(String namespace, String metric)
      Description copied from interface: MetricsClient
      Increment the counter by 1.
      Specified by:
      increment in interface MetricsClient
      Parameters:
      namespace - metric namespace
      metric - metric name
    • increment

      public void increment(String metric, double sampleRate)
      Description copied from interface: MetricsClient
      Increment the counter by 1.

      This uses sampling in order to approximate the actual number of increments. An update will be reported for only sampleRate * 100 percent of all invocations.

      Specified by:
      increment in interface MetricsClient
      Parameters:
      metric - metric name
      sampleRate - Percentage of invocations to actually report. If the specified value is zero or negative, nothing will be reported. If the value is 1 or greater, it will always report.
    • increment

      public void increment(String namespace, String metric, double sampleRate)
      Description copied from interface: MetricsClient
      Increment the counter by 1.

      This uses sampling in order to approximate the actual number of increments. An update will be reported for only sampleRate * 100 percent of all invocations.

      Specified by:
      increment in interface MetricsClient
      Parameters:
      namespace - metric namespace
      metric - metric name
      sampleRate - Percentage of invocations to actually report. If the specified value is zero or negative, nothing will be reported. If the value is 1 or greater, it will always report.
    • increment

      public void increment(String metric, Set<Dimension> dimensions)
      Description copied from interface: MetricsClient
      Increment the counter by 1.
      Specified by:
      increment in interface MetricsClient
      Parameters:
      metric - metric name
      dimensions - dimensions identifying the entity
    • increment

      public void increment(String namespace, String metric, Set<Dimension> dimensions)
      Description copied from interface: MetricsClient
      Increment the counter by 1.
      Specified by:
      increment in interface MetricsClient
      Parameters:
      namespace - metric namespace
      metric - metric name
      dimensions - dimensions identifying the entity
    • increment

      public void increment(String metric, double sampleRate, Set<Dimension> dimensions)
      Description copied from interface: MetricsClient
      Increment the counter by 1.

      This uses sampling in order to approximate the actual number of increments. An update will be reported for only sampleRate * 100 percent of all invocations.

      Specified by:
      increment in interface MetricsClient
      Parameters:
      metric - metric name
      sampleRate - Percentage of invocations to actually report. If the specified value is zero or negative, nothing will be reported. If the value is 1 or greater, it will always report.
      dimensions - dimensions identifying the entity
    • increment

      public void increment(String namespace, String metric, double sampleRate, Set<Dimension> dimensions)
      Description copied from interface: MetricsClient
      Increment the counter by 1.

      This uses sampling in order to approximate the actual number of increments. An update will be reported for only sampleRate * 100 percent of all invocations.

      Specified by:
      increment in interface MetricsClient
      Parameters:
      namespace - metric namespace
      metric - metric name
      sampleRate - Percentage of invocations to actually report. If the specified value is zero or negative, nothing will be reported. If the value is 1 or greater, it will always report.
      dimensions - dimensions identifying the entity
    • decrement

      public void decrement(String metric)
      Description copied from interface: MetricsClient
      Decrement the counter by 1.
      Specified by:
      decrement in interface MetricsClient
      Parameters:
      metric - metric name
    • decrement

      public void decrement(String namespace, String metric)
      Description copied from interface: MetricsClient
      Decrement the counter by 1.
      Specified by:
      decrement in interface MetricsClient
      Parameters:
      namespace - metric namespace
      metric - metric name
    • decrement

      public void decrement(String metric, double sampleRate)
      Description copied from interface: MetricsClient
      Decrement the counter by 1.

      This uses sampling in order to approximate the actual number of increments. An update will be reported for only sampleRate * 100 percent of all invocations.

      Specified by:
      decrement in interface MetricsClient
      Parameters:
      metric - metric name
      sampleRate - Percentage of invocations to actually report. If the specified value is zero or negative, nothing will be reported. If the value is 1 or greater, it will always report.
    • decrement

      public void decrement(String namespace, String metric, double sampleRate)
      Description copied from interface: MetricsClient
      Decrement the counter by 1.

      This uses sampling in order to approximate the actual number of increments. An update will be reported for only sampleRate * 100 percent of all invocations.

      Specified by:
      decrement in interface MetricsClient
      Parameters:
      namespace - metric namespace
      metric - metric name
      sampleRate - Percentage of invocations to actually report. If the specified value is zero or negative, nothing will be reported. If the value is 1 or greater, it will always report.
    • decrement

      public void decrement(String metric, Set<Dimension> dimensions)
      Description copied from interface: MetricsClient
      Decrement the counter by 1.
      Specified by:
      decrement in interface MetricsClient
      Parameters:
      metric - metric name
      dimensions - dimensions identifying the entity
    • decrement

      public void decrement(String namespace, String metric, Set<Dimension> dimensions)
      Description copied from interface: MetricsClient
      Decrement the counter by 1.
      Specified by:
      decrement in interface MetricsClient
      Parameters:
      namespace - metric namespace
      metric - metric name
      dimensions - dimensions identifying the entity
    • decrement

      public void decrement(String metric, double sampleRate, Set<Dimension> dimensions)
      Description copied from interface: MetricsClient
      Decrement the counter by 1.

      This uses sampling in order to approximate the actual number of increments. An update will be reported for only sampleRate * 100 percent of all invocations.

      Specified by:
      decrement in interface MetricsClient
      Parameters:
      metric - metric name
      sampleRate - Percentage of invocations to actually report. If the specified value is zero or negative, nothing will be reported. If the value is 1 or greater, it will always report.
      dimensions - dimensions identifying the entity
    • decrement

      public void decrement(String namespace, String metric, double sampleRate, Set<Dimension> dimensions)
      Description copied from interface: MetricsClient
      Decrement the counter by 1.

      This uses sampling in order to approximate the actual number of increments. An update will be reported for only sampleRate * 100 percent of all invocations.

      Specified by:
      decrement in interface MetricsClient
      Parameters:
      namespace - metric namespace
      metric - metric name
      sampleRate - Percentage of invocations to actually report. If the specified value is zero or negative, nothing will be reported. If the value is 1 or greater, it will always report.
      dimensions - dimensions identifying the entity
    • count

      public void count(String metric, long delta)
      Description copied from interface: MetricsClient
      Adjust the counter value.
      Specified by:
      count in interface MetricsClient
      Parameters:
      metric - metric name
      delta - adjustment value
    • count

      public void count(String namespace, String metric, long delta)
      Description copied from interface: MetricsClient
      Adjust the counter value.
      Specified by:
      count in interface MetricsClient
      Parameters:
      namespace - metric namespace
      metric - metric name
      delta - adjustment value
    • count

      public void count(String metric, long delta, double sampleRate)
      Description copied from interface: MetricsClient
      Adjust the counter value.

      This uses sampling in order to approximate the actual number of increments. An update will be reported for only sampleRate * 100 percent of all invocations.

      Specified by:
      count in interface MetricsClient
      Parameters:
      metric - metric name
      delta - adjustment value
      sampleRate - Percentage of invocations to actually report. If the specified value is zero or negative, nothing will be reported. If the value is 1 or greater, it will always report.
    • count

      public void count(String namespace, String metric, long delta, double sampleRate)
      Description copied from interface: MetricsClient
      Adjust the counter value.

      This uses sampling in order to approximate the actual number of increments. An update will be reported for only sampleRate * 100 percent of all invocations.

      Specified by:
      count in interface MetricsClient
      Parameters:
      namespace - metric namespace
      metric - metric name
      delta - adjustment value
      sampleRate - Percentage of invocations to actually report. If the specified value is zero or negative, nothing will be reported. If the value is 1 or greater, it will always report.
    • count

      public void count(String metric, long delta, Set<Dimension> dimensions)
      Description copied from interface: MetricsClient
      Adjust the counter value.
      Specified by:
      count in interface MetricsClient
      Parameters:
      metric - metric name
      delta - adjustment value
      dimensions - dimensions identifying the entity
    • count

      public void count(String namespace, String metric, long delta, Set<Dimension> dimensions)
      Description copied from interface: MetricsClient
      Adjust the counter value.
      Specified by:
      count in interface MetricsClient
      Parameters:
      namespace - metric namespace
      metric - metric name
      delta - adjustment value
      dimensions - dimensions identifying the entity
    • count

      public void count(String metric, long delta, double sampleRate, Set<Dimension> dimensions)
      Description copied from interface: MetricsClient
      Adjust the counter value.

      This uses sampling in order to approximate the actual number of increments. An update will be reported for only sampleRate * 100 percent of all invocations.

      Specified by:
      count in interface MetricsClient
      Parameters:
      metric - metric name
      delta - adjustment value
      sampleRate - Percentage of invocations to actually report. If the specified value is zero or negative, nothing will be reported. If the value is 1 or greater, it will always report.
      dimensions - dimensions identifying the entity
    • count

      public void count(String namespace, String metric, long delta, double sampleRate, Set<Dimension> dimensions)
      Description copied from interface: MetricsClient
      Adjust the counter value.

      This uses sampling in order to approximate the actual number of increments. An update will be reported for only sampleRate * 100 percent of all invocations.

      Specified by:
      count in interface MetricsClient
      Parameters:
      namespace - metric namespace
      metric - metric name
      delta - adjustment value
      sampleRate - Percentage of invocations to actually report. If the specified value is zero or negative, nothing will be reported. If the value is 1 or greater, it will always report.
      dimensions - dimensions identifying the entity
    • event

      public void event(String name, String message, Severity severity)
      Description copied from interface: MetricsClient
      Report an event.

      The event will be immediately reported for.

      Specified by:
      event in interface MetricsClient
      Parameters:
      name - event name
      message - message
      severity - severity
    • event

      public void event(String namespace, String name, String message, Severity severity)
      Description copied from interface: MetricsClient
      Report an event.

      The event will be immediately reported for.

      Specified by:
      event in interface MetricsClient
      Parameters:
      namespace - event namespace
      name - event name
      message - message
      severity - severity
    • event

      public void event(String name, String message, Severity severity, Set<Dimension> dimensions)
      Description copied from interface: MetricsClient
      Report an event.

      The event will be immediately reported for.

      Specified by:
      event in interface MetricsClient
      Parameters:
      name - event name
      message - message
      severity - severity
      dimensions - dimensions identifying the entity
    • event

      public void event(String namespace, String name, String message, Severity severity, Set<Dimension> dimensions)
      Description copied from interface: MetricsClient
      Report an event.

      The event will be immediately reported for.

      Specified by:
      event in interface MetricsClient
      Parameters:
      namespace - event namespace
      name - event name
      message - message
      severity - severity
      dimensions - dimensions identifying the entity
    • gauge

      public void gauge(String metric, double absoluteValue)
      Description copied from interface: MetricsClient
      Set the specified gauge's value.
      Specified by:
      gauge in interface MetricsClient
      Parameters:
      metric - metric name
      absoluteValue - absolute value
    • gauge

      public void gauge(String namespace, String metric, double absoluteValue)
      Description copied from interface: MetricsClient
      Set the specified gauge's value.
      Specified by:
      gauge in interface MetricsClient
      Parameters:
      namespace - metric namespace
      metric - metric name
      absoluteValue - absolute value
    • gauge

      public void gauge(String metric, double absoluteValue, Unit unit)
      Description copied from interface: MetricsClient
      Set the specified gauge's value.
      Specified by:
      gauge in interface MetricsClient
      Parameters:
      metric - metric name
      absoluteValue - absolute value
      unit - unit of measure
    • gauge

      public void gauge(String namespace, String metric, double absoluteValue, Unit unit)
      Description copied from interface: MetricsClient
      Set the specified gauge's value.
      Specified by:
      gauge in interface MetricsClient
      Parameters:
      namespace - metric namespace
      metric - metric name
      absoluteValue - absolute value
      unit - unit of measure
    • gauge

      public void gauge(String metric, double absoluteValue, Set<Dimension> dimensions)
      Description copied from interface: MetricsClient
      Set the specified gauge's value.
      Specified by:
      gauge in interface MetricsClient
      Parameters:
      metric - metric name
      absoluteValue - absolute value
      dimensions - dimensions identifying the entity
    • gauge

      public void gauge(String namespace, String metric, double absoluteValue, Set<Dimension> dimensions)
      Description copied from interface: MetricsClient
      Set the specified gauge's value.
      Specified by:
      gauge in interface MetricsClient
      Parameters:
      namespace - metric namespace
      metric - metric name
      absoluteValue - absolute value
      dimensions - dimensions identifying the entity
    • gauge

      public void gauge(String metric, double absoluteValue, Unit unit, Set<Dimension> dimensions)
      Description copied from interface: MetricsClient
      Set the specified gauge's value.
      Specified by:
      gauge in interface MetricsClient
      Parameters:
      metric - metric name
      absoluteValue - absolute value
      unit - unit of measure
      dimensions - dimensions identifying the entity
    • gauge

      public void gauge(String namespace, String metric, double absoluteValue, Unit unit, Set<Dimension> dimensions)
      Description copied from interface: MetricsClient
      Set the specified gauge's value.
      Specified by:
      gauge in interface MetricsClient
      Parameters:
      namespace - metric namespace
      metric - metric name
      absoluteValue - absolute value
      unit - unit of measure
      dimensions - dimensions identifying the entity
    • adjustGauge

      public void adjustGauge(String metric, double delta)
      Description copied from interface: MetricsClient
      Adjust the specified gauge's value.
      Specified by:
      adjustGauge in interface MetricsClient
      Parameters:
      metric - metric name
      delta - amount to adjust by
    • adjustGauge

      public void adjustGauge(String namespace, String metric, double delta)
      Description copied from interface: MetricsClient
      Adjust the specified gauge's value.
      Specified by:
      adjustGauge in interface MetricsClient
      Parameters:
      namespace - metric namespace
      metric - metric name
      delta - amount to adjust by
    • adjustGauge

      public void adjustGauge(String metric, double delta, Unit unit)
      Description copied from interface: MetricsClient
      Adjust the specified gauge's value.
      Specified by:
      adjustGauge in interface MetricsClient
      Parameters:
      metric - metric name
      delta - amount to adjust by
      unit - unit of measure
    • adjustGauge

      public void adjustGauge(String namespace, String metric, double delta, Unit unit)
      Description copied from interface: MetricsClient
      Adjust the specified gauge's value.
      Specified by:
      adjustGauge in interface MetricsClient
      Parameters:
      namespace - metric namespace
      metric - metric name
      delta - amount to adjust by
      unit - unit of measure
    • adjustGauge

      public void adjustGauge(String metric, double delta, Set<Dimension> dimensions)
      Description copied from interface: MetricsClient
      Adjust the specified gauge's value.
      Specified by:
      adjustGauge in interface MetricsClient
      Parameters:
      metric - metric name
      delta - amount to adjust by
      dimensions - dimensions identifying the entity
    • adjustGauge

      public void adjustGauge(String namespace, String metric, double delta, Set<Dimension> dimensions)
      Description copied from interface: MetricsClient
      Adjust the specified gauge's value.
      Specified by:
      adjustGauge in interface MetricsClient
      Parameters:
      namespace - metric namespace
      metric - metric name
      delta - amount to adjust by
      dimensions - dimensions identifying the entity
    • adjustGauge

      public void adjustGauge(String metric, double delta, Unit unit, Set<Dimension> dimensions)
      Description copied from interface: MetricsClient
      Adjust the specified gauge's value.
      Specified by:
      adjustGauge in interface MetricsClient
      Parameters:
      metric - metric name
      delta - amount to adjust by
      unit - unit of measure
      dimensions - dimensions identifying the entity
    • adjustGauge

      public void adjustGauge(String namespace, String metric, double delta, Unit unit, Set<Dimension> dimensions)
      Description copied from interface: MetricsClient
      Adjust the specified gauge's value.
      Specified by:
      adjustGauge in interface MetricsClient
      Parameters:
      namespace - metric namespace
      metric - metric name
      delta - amount to adjust by
      unit - unit of measure
      dimensions - dimensions identifying the entity
    • gauge

      public void gauge(String metric, DoubleSupplier supplier)
      Description copied from interface: MetricsClient
      Register periodic sampling of a gauge.

      The client will sample the value at its configured sampling interval.

      This method should only be called once per unique combination of metric name and dimensions. Duplicate registrations are ignored and may be reported via an implementation-specific error handler.

      Specified by:
      gauge in interface MetricsClient
      Parameters:
      metric - metric name
      supplier - value supplier called once per sampling interval
    • gauge

      public void gauge(String namespace, String metric, DoubleSupplier supplier)
      Description copied from interface: MetricsClient
      Register periodic sampling of a gauge.

      The client will sample the value at its configured sampling interval.

      This method should only be called once per unique combination of metric name and dimensions. Duplicate registrations are ignored and may be reported via an implementation-specific error handler.

      Specified by:
      gauge in interface MetricsClient
      Parameters:
      namespace - metric namespace
      metric - metric name
      supplier - value supplier called once per sampling interval
    • gauge

      public void gauge(String metric, DoubleSupplier supplier, Set<Dimension> dimensions)
      Description copied from interface: MetricsClient
      Register periodic sampling of a gauge.

      The client will sample the value at its configured sampling interval.

      This method should only be called once per unique combination of metric name and dimensions. Duplicate registrations are ignored and may be reported via an implementation-specific error handler.

      Specified by:
      gauge in interface MetricsClient
      Parameters:
      metric - metric name
      supplier - value supplier called once per sampling interval
      dimensions - dimensions identifying the entity
    • gauge

      public void gauge(String namespace, String metric, DoubleSupplier supplier, Set<Dimension> dimensions)
      Description copied from interface: MetricsClient
      Register periodic sampling of a gauge.

      The client will sample the value at its configured sampling interval.

      This method should only be called once per unique combination of metric name and dimensions. Duplicate registrations are ignored and may be reported via an implementation-specific error handler.

      Specified by:
      gauge in interface MetricsClient
      Parameters:
      namespace - metric namespace
      metric - metric name
      supplier - value supplier called once per sampling interval
      dimensions - dimensions identifying the entity
    • gauge

      public void gauge(String metric, DoubleSupplier supplier, Unit unit)
      Description copied from interface: MetricsClient
      Register periodic sampling of a gauge.

      The client will sample the value at its configured sampling interval.

      This method should only be called once per unique combination of metric name and dimensions. Duplicate registrations are ignored and may be reported via an implementation-specific error handler.

      Specified by:
      gauge in interface MetricsClient
      Parameters:
      metric - metric name
      supplier - value supplier called once per sampling interval
      unit - unit of measure
    • gauge

      public void gauge(String namespace, String metric, DoubleSupplier supplier, Unit unit)
      Description copied from interface: MetricsClient
      Register periodic sampling of a gauge.

      The client will sample the value at its configured sampling interval.

      This method should only be called once per unique combination of metric name and dimensions. Duplicate registrations are ignored and may be reported via an implementation-specific error handler.

      Specified by:
      gauge in interface MetricsClient
      Parameters:
      namespace - metric namespace
      metric - metric name
      supplier - value supplier called once per sampling interval
      unit - unit of measure
    • gauge

      public void gauge(String metric, DoubleSupplier supplier, Unit unit, Set<Dimension> dimensions)
      Description copied from interface: MetricsClient
      Register periodic sampling of a gauge.

      The client will sample the value at its configured sampling interval.

      This method should only be called once per unique combination of metric name and dimensions. Duplicate registrations are ignored and may be reported via an implementation-specific error handler.

      Specified by:
      gauge in interface MetricsClient
      Parameters:
      metric - metric name
      supplier - value supplier called once per sampling interval
      unit - unit of measure
      dimensions - dimensions identifying the entity
    • gauge

      public void gauge(String namespace, String metric, DoubleSupplier supplier, Unit unit, Set<Dimension> dimensions)
      Description copied from interface: MetricsClient
      Register periodic sampling of a gauge.

      The client will sample the value at its configured sampling interval.

      This method should only be called once per unique combination of metric name and dimensions. Duplicate registrations are ignored and may be reported via an implementation-specific error handler.

      Specified by:
      gauge in interface MetricsClient
      Parameters:
      namespace - metric namespace
      metric - metric name
      supplier - value supplier called once per sampling interval
      unit - unit of measure
      dimensions - dimensions identifying the entity
    • removeGaugeSampler

      public void removeGaugeSampler(String metric)
      Description copied from interface: MetricsClient
      Remove a periodically sampled gauge that was registered via MetricsClient.gauge(String, DoubleSupplier) or MetricsClient.gauge(String, DoubleSupplier, Unit).

      The metric name must correspond exactly to the original registration. The unit is ignored.

      Specified by:
      removeGaugeSampler in interface MetricsClient
      Parameters:
      metric - metric name
    • removeGaugeSampler

      public void removeGaugeSampler(String namespace, String metric)
      Description copied from interface: MetricsClient
      Remove a periodically sampled gauge that was registered via MetricsClient.gauge(String, DoubleSupplier) or MetricsClient.gauge(String, DoubleSupplier, Unit).

      The metric name must correspond exactly to the original registration. The unit is ignored.

      Specified by:
      removeGaugeSampler in interface MetricsClient
      Parameters:
      namespace - metric namespace
      metric - metric name
    • removeGaugeSampler

      public void removeGaugeSampler(String metric, Set<Dimension> dimensions)
      Description copied from interface: MetricsClient
      Remove a periodically sampled gauge that was registered via MetricsClient.gauge(String, DoubleSupplier, Set) or MetricsClient.gauge(String, DoubleSupplier, Unit, Set).

      The metric name and dimensions must correspond exactly to the original registration. The unit is ignored.

      Specified by:
      removeGaugeSampler in interface MetricsClient
      Parameters:
      metric - metric name
      dimensions - dimensions
    • removeGaugeSampler

      public void removeGaugeSampler(String namespace, String metric, Set<Dimension> dimensions)
      Description copied from interface: MetricsClient
      Remove a periodically sampled gauge that was registered via MetricsClient.gauge(String, DoubleSupplier, Set) or MetricsClient.gauge(String, DoubleSupplier, Unit, Set).

      The metric name and dimensions must correspond exactly to the original registration. The unit is ignored.

      Specified by:
      removeGaugeSampler in interface MetricsClient
      Parameters:
      namespace - metric namespace
      metric - metric name
      dimensions - dimensions
    • clearGaugeSamplers

      public void clearGaugeSamplers()
      Description copied from interface: MetricsClient
      Clear all periodically sampled gauges.
      Specified by:
      clearGaugeSamplers in interface MetricsClient
    • timer

      public void timer(String metric, long millis)
      Description copied from interface: MetricsClient
      Report elapsed time (in milliseconds) of an operation.
      Specified by:
      timer in interface MetricsClient
      Parameters:
      metric - timer name
      millis - elapsed milliseconds
    • timer

      public void timer(String namespace, String metric, long millis)
      Description copied from interface: MetricsClient
      Report elapsed time (in milliseconds) of an operation.
      Specified by:
      timer in interface MetricsClient
      Parameters:
      namespace - metric namespace
      metric - timer name
      millis - elapsed milliseconds
    • timer

      public void timer(String metric, long millis, double sampleRate)
      Description copied from interface: MetricsClient
      Report elapsed time (in milliseconds) of an operation.

      This uses sampling in order to approximate the actual number of invocations. An update will be reported for only sampleRate * 100 percent of all invocations.

      Specified by:
      timer in interface MetricsClient
      Parameters:
      metric - timer name
      millis - elapsed milliseconds
      sampleRate - Percentage of invocations to actually report. If the specified value is zero or negative, nothing will be reported. If the value is 1 or greater, it will always report.
    • timer

      public void timer(String namespace, String metric, long millis, double sampleRate)
      Description copied from interface: MetricsClient
      Report elapsed time (in milliseconds) of an operation.

      This uses sampling in order to approximate the actual number of invocations. An update will be reported for only sampleRate * 100 percent of all invocations.

      Specified by:
      timer in interface MetricsClient
      Parameters:
      namespace - metric namespace
      metric - timer name
      millis - elapsed milliseconds
      sampleRate - Percentage of invocations to actually report. If the specified value is zero or negative, nothing will be reported. If the value is 1 or greater, it will always report.
    • timer

      public void timer(String metric, long millis, Set<Dimension> dimensions)
      Description copied from interface: MetricsClient
      Report elapsed time (in milliseconds) of an operation.
      Specified by:
      timer in interface MetricsClient
      Parameters:
      metric - timer name
      millis - elapsed milliseconds
      dimensions - dimensions identifying the entity
    • timer

      public void timer(String namespace, String metric, long millis, Set<Dimension> dimensions)
      Description copied from interface: MetricsClient
      Report elapsed time (in milliseconds) of an operation.
      Specified by:
      timer in interface MetricsClient
      Parameters:
      namespace - metric namespace
      metric - timer name
      millis - elapsed milliseconds
      dimensions - dimensions identifying the entity
    • timer

      public void timer(String metric, long millis, double sampleRate, Set<Dimension> dimensions)
      Description copied from interface: MetricsClient
      Report elapsed time (in milliseconds) of an operation.

      This uses sampling in order to approximate the actual number of invocations. An update will be reported for only sampleRate * 100 percent of all invocations.

      Specified by:
      timer in interface MetricsClient
      Parameters:
      metric - timer name
      millis - elapsed milliseconds
      sampleRate - Percentage of invocations to actually report. If the specified value is zero or negative, nothing will be reported. If the value is 1 or greater, it will always report.
      dimensions - dimensions identifying the entity
    • timer

      public void timer(String namespace, String metric, long millis, double sampleRate, Set<Dimension> dimensions)
      Description copied from interface: MetricsClient
      Report elapsed time (in milliseconds) of an operation.

      This uses sampling in order to approximate the actual number of invocations. An update will be reported for only sampleRate * 100 percent of all invocations.

      Specified by:
      timer in interface MetricsClient
      Parameters:
      namespace - metric namespace
      metric - timer name
      millis - elapsed milliseconds
      sampleRate - Percentage of invocations to actually report. If the specified value is zero or negative, nothing will be reported. If the value is 1 or greater, it will always report.
      dimensions - dimensions identifying the entity
    • timer

      public void timer(String metric, long value, TimeUnit unit)
      Description copied from interface: MetricsClient
      Report elapsed time of an operation.
      Specified by:
      timer in interface MetricsClient
      Parameters:
      metric - timer name
      value - elapsed time
      unit - value unit
    • timer

      public void timer(String namespace, String metric, long value, TimeUnit unit)
      Description copied from interface: MetricsClient
      Report elapsed time of an operation.
      Specified by:
      timer in interface MetricsClient
      Parameters:
      namespace - metric namespace
      metric - timer name
      value - elapsed time
      unit - value unit
    • timer

      public void timer(String metric, long value, TimeUnit unit, double sampleRate)
      Description copied from interface: MetricsClient
      Report elapsed time of an operation.

      This uses sampling in order to approximate the actual number of invocations. An update will be reported for only sampleRate * 100 percent of all invocations.

      Specified by:
      timer in interface MetricsClient
      Parameters:
      metric - timer name
      value - elapsed time
      unit - value unit
      sampleRate - Percentage of invocations to actually report. If the specified value is zero or negative, nothing will be reported. If the value is 1 or greater, it will always report.
    • timer

      public void timer(String namespace, String metric, long value, TimeUnit unit, double sampleRate)
      Description copied from interface: MetricsClient
      Report elapsed time of an operation.

      This uses sampling in order to approximate the actual number of invocations. An update will be reported for only sampleRate * 100 percent of all invocations.

      Specified by:
      timer in interface MetricsClient
      Parameters:
      namespace - metric namespace
      metric - timer name
      value - elapsed time
      unit - value unit
      sampleRate - Percentage of invocations to actually report. If the specified value is zero or negative, nothing will be reported. If the value is 1 or greater, it will always report.
    • timer

      public void timer(String metric, long value, TimeUnit unit, Set<Dimension> dimensions)
      Description copied from interface: MetricsClient
      Report elapsed time of an operation.
      Specified by:
      timer in interface MetricsClient
      Parameters:
      metric - timer name
      value - elapsed time
      unit - value unit
      dimensions - dimensions identifying the entity
    • timer

      public void timer(String namespace, String metric, long value, TimeUnit unit, Set<Dimension> dimensions)
      Description copied from interface: MetricsClient
      Report elapsed time of an operation.
      Specified by:
      timer in interface MetricsClient
      Parameters:
      namespace - metric namespace
      metric - timer name
      value - elapsed time
      unit - value unit
      dimensions - dimensions identifying the entity
    • timer

      public void timer(String metric, long value, TimeUnit unit, double sampleRate, Set<Dimension> dimensions)
      Description copied from interface: MetricsClient
      Report elapsed time of an operation.

      This uses sampling in order to approximate the actual number of invocations. An update will be reported for only sampleRate * 100 percent of all invocations.

      Specified by:
      timer in interface MetricsClient
      Parameters:
      metric - timer name
      value - elapsed time
      unit - value unit
      sampleRate - Percentage of invocations to actually report. If the specified value is zero or negative, nothing will be reported. If the value is 1 or greater, it will always report.
      dimensions - dimensions identifying the entity
    • timer

      public void timer(String namespace, String metric, long value, TimeUnit unit, double sampleRate, Set<Dimension> dimensions)
      Description copied from interface: MetricsClient
      Report elapsed time of an operation.

      This uses sampling in order to approximate the actual number of invocations. An update will be reported for only sampleRate * 100 percent of all invocations.

      Specified by:
      timer in interface MetricsClient
      Parameters:
      namespace - metric namespace
      metric - timer name
      value - elapsed time
      unit - value unit
      sampleRate - Percentage of invocations to actually report. If the specified value is zero or negative, nothing will be reported. If the value is 1 or greater, it will always report.
      dimensions - dimensions identifying the entity
    • unique

      public void unique(String metric, String identifier)
      Description copied from interface: MetricsClient
      Report a unique value in a bucket or "set".

      The server will track the number of unique identifiers in the named set and report as a counter.

      Specified by:
      unique in interface MetricsClient
      Parameters:
      metric - set name
      identifier - unique identifier
    • unique

      public void unique(String namespace, String metric, String identifier)
      Description copied from interface: MetricsClient
      Report a unique value in a bucket or "set".

      The server will track the number of unique identifiers in the named set and report as a counter.

      Specified by:
      unique in interface MetricsClient
      Parameters:
      namespace - metric namespace
      metric - set name
      identifier - unique identifier
    • unique

      public void unique(String metric, String identifier, Set<Dimension> dimensions)
      Description copied from interface: MetricsClient
      Report a unique value in a bucket or "set".

      The server will track the number of unique identifiers in the named set and report as a counter.

      Specified by:
      unique in interface MetricsClient
      Parameters:
      metric - set name
      identifier - unique identifier
      dimensions - dimensions identifying the entity
    • unique

      public void unique(String namespace, String metric, String identifier, Set<Dimension> dimensions)
      Description copied from interface: MetricsClient
      Report a unique value in a bucket or "set".

      The server will track the number of unique identifiers in the named set and report as a counter.

      Specified by:
      unique in interface MetricsClient
      Parameters:
      namespace - metric namespace
      metric - set name
      identifier - unique identifier
      dimensions - dimensions identifying the entity
    • doAttribute

      protected abstract void doAttribute(String metric, String value, Set<Dimension> dimensions)
    • doAttribute

      protected void doAttribute(String namespace, String metric, String value, Set<Dimension> dimensions)
    • doCount

      protected abstract void doCount(String metric, long delta, double sampleRate, Set<Dimension> dimensions)
    • doCount

      protected void doCount(String ns, String metric, long delta, double sampleRate, Set<Dimension> dimensions)
    • doEvent

      protected abstract void doEvent(String name, String message, Severity severity, Set<Dimension> dimensions)
    • doEvent

      protected void doEvent(String namespace, String name, String message, Severity severity, Set<Dimension> dimensions)
    • doGauge

      protected abstract void doGauge(String metric, double value, boolean isDelta, Unit unit, Set<Dimension> dimensions)
    • doGauge

      protected void doGauge(String namespace, String metric, double value, boolean isDelta, Unit unit, Set<Dimension> dimensions)
    • doTimer

      protected abstract void doTimer(String metric, long value, TimeUnit unit, double sampleRate, Set<Dimension> dimensions)
    • doTimer

      protected void doTimer(String namespace, String metric, long value, TimeUnit unit, double sampleRate, Set<Dimension> dimensions)
    • doUnique

      protected abstract void doUnique(String metric, String identifier, Set<Dimension> dimensions)
    • doUnique

      protected void doUnique(String namespace, String metric, String identifier, Set<Dimension> dimensions)
    • fractionalMillis

      protected static double fractionalMillis(long value, TimeUnit unit)
      Convert an integer timer value to milliseconds with possible fractional component.
      Parameters:
      value - value
      unit - value unit
      Returns:
      the equivalent value in milliseconds
    • close

      public final void close()
      Description copied from interface: MetricsClient
      Overridden to remove checked exception constraint.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface MetricsClient
    • doClose

      protected void doClose()
      Close hook for implementations.
    • getSamplingInterval

      public final long getSamplingInterval()
      Returns:
      the configured sampling interval
    • isClosing

      protected final boolean isClosing()
      Returns:
      whether the client has been instructed to close
    • submitTask

      protected void submitTask(Runnable task)
      Submit a task.

      Depending on the number of submitted tasks, it may be necessary to create a larger thread pool. See AbstractMetricsClient(long, Consumer, int).

      Parameters:
      task - task to execute
    • scheduleTask

      protected void scheduleTask(Runnable task, long interval)
      Schedule a periodic task.

      Depending on the number of scheduled tasks, it may be necessary to create a thread pool. See AbstractMetricsClient(long, Consumer, int).

      Parameters:
      task - task to execute
      interval - fixed interval millis
    • requireNotEmpty

      protected static void requireNotEmpty(String param, String val)
    • requireNotNull

      protected static void requireNotNull(String param, Object val)