Class MockMetric

java.lang.Object
com.yahoo.jdisc.test.MockMetric
All Implemented Interfaces:
Metric

public class MockMetric extends Object implements Metric
Metric implementation for tests.
Author:
jonmv
  • Constructor Details

    • MockMetric

      public MockMetric()
  • Method Details

    • set

      public void set(String key, Number val, Metric.Context ctx)
      Description copied from interface: Metric
      Set a metric value. This is typically used with histogram-type metrics.
      Specified by:
      set in interface Metric
      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

      public void add(String key, Number val, Metric.Context ctx)
      Description copied from interface: Metric
      Add to a metric value. This is typically used with counter-type metrics.
      Specified by:
      add in interface Metric
      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
    • createContext

      public Metric.Context createContext(Map<String,?> properties)
      Description copied from interface: Metric
      Creates a MetricConsumer-specific Metric.Context object that encapsulates the given properties. The returned Context object should be passed along every future call to Metric.set(String, Number, Context) and Metric.add(String, Number, Context) where the properties match those given here.
      Specified by:
      createContext in interface Metric
      Parameters:
      properties - the properties to incorporate in the context
      Returns:
      the created context
    • metrics

      public Map<String,Map<Map<String,?>,Double>> metrics()
    • toString

      public String toString()
      Overrides:
      toString in class Object