Interface MetricsContext

All Superinterfaces:
Serializable
All Known Subinterfaces:
FileIOMetricsContext
All Known Implementing Classes:
DefaultMetricsContext, HadoopMetricsContext

public interface MetricsContext extends Serializable
Generalized interface for creating telemetry related instances for tracking operations. Implementations must take into account usage considerations like thread safety and serialization.
  • Method Details

    • initialize

      default void initialize(Map<String,String> properties)
    • counter

      @Deprecated default <T extends Number> MetricsContext.Counter<T> counter(String name, Class<T> type, MetricsContext.Unit unit)
      Deprecated.
      will be removed in 2.0.0, use counter(String, Unit) instead.
      Get a named counter of a specific type. Metric implementations may impose restrictions on what types are supported for specific counters.
      Parameters:
      name - name of the metric
      type - numeric type of the counter value
      unit - the unit designation of the metric
      Returns:
      a counter implementation
    • counter

      default Counter counter(String name, MetricsContext.Unit unit)
      Get a named counter.
      Parameters:
      name - The name of the counter
      unit - The unit designation of the counter
      Returns:
      a Counter implementation
    • counter

      default Counter counter(String name)
      Get a named counter using MetricsContext.Unit.COUNT
      Parameters:
      name - The name of the counter
      Returns:
      a Counter implementation
    • timer

      default Timer timer(String name, TimeUnit unit)
      Get a named timer.
      Parameters:
      name - name of the metric
      unit - the time unit designation of the metric
      Returns:
      a timer implementation
    • histogram

      default Histogram histogram(String name)
    • nullMetrics

      static MetricsContext nullMetrics()
      Utility method for producing no metrics.
      Returns:
      a non-recording metrics context