Interface Metric


  • public interface Metric

    This interface provides an API for writing metric data to the configured MetricConsumer. If no Provider for the MetricConsumer class has been bound by the application, all calls to this interface are no-ops. The implementation of this interface uses thread local consumer instances, so as long as the MetricConsumer is thread-safe, so is this.

    An instance of this class can be injected anywhere.

    Author:
    Simon Thoresen Hult
    • Method Detail

      • set

        void set​(java.lang.String key,
                 java.lang.Number val,
                 Metric.Context ctx)
        Set a metric value. This is typically used with histogram-type metrics.
        Parameters:
        key - The name of the metric to modify.
        val - The value to assign to the named metric.
        ctx - The context to further describe this entry.
      • add

        void add​(java.lang.String key,
                 java.lang.Number val,
                 Metric.Context ctx)
        Add to a metric value. This is typically used with counter-type metrics.
        Parameters:
        key - the name of the metric to modify
        val - the value to add to the named metric
        ctx - the context to further describe this entry