Interface MetricsSystem

All Superinterfaces:
BesuService

public interface MetricsSystem extends BesuService
An interface for creating various Metrics components.
  • Method Details

    • createCounter

      default Counter createCounter(MetricCategory category, String name, String help)
      Creates a Counter.
      Parameters:
      category - The MetricCategory this counter is assigned to.
      name - A name for this metric.
      help - A human readable description of the metric.
      Returns:
      The created Counter instance.
    • createCounter

      default void createCounter(MetricCategory category, String name, String help, DoubleSupplier valueSupplier)
      Creates a Counter that gets its value from the specified supplier. To be used when the value of the counter is calculated outside the metric system.
      Parameters:
      category - The MetricCategory this counter is assigned to.
      name - A name for this metric.
      help - A human readable description of the metric.
      valueSupplier - The supplier of the value.
    • createLabelledCounter

      LabelledMetric<Counter> createLabelledCounter(MetricCategory category, String name, String help, String... labelNames)
      Creates a Counter with assigned labels.
      Parameters:
      category - The MetricCategory this counter is assigned to.
      name - A name for this metric.
      help - A human readable description of the metric.
      labelNames - An array of labels to assign to the Counter.
      Returns:
      The created LabelledMetric instance.
    • createLabelledSuppliedCounter

      LabelledSuppliedMetric createLabelledSuppliedCounter(MetricCategory category, String name, String help, String... labelNames)
      Creates a Counter with assigned labels, that gets its values from suppliers. To be used when the values of the counter are calculated outside the metric system.
      Parameters:
      category - The MetricCategory this counter is assigned to.
      name - A name for this metric.
      help - A human readable description of the metric.
      labelNames - An array of labels to assign to the Counter.
      Returns:
      The created LabelledSupplierMetric instance.
    • createLabelledSuppliedGauge

      LabelledSuppliedMetric createLabelledSuppliedGauge(MetricCategory category, String name, String help, String... labelNames)
      Creates a Gauge with assigned labels, that gets its values from suppliers. To be used when the values of the gauge are calculated outside the metric system.
      Parameters:
      category - The MetricCategory this gauge is assigned to.
      name - A name for this metric.
      help - A human readable description of the metric.
      labelNames - An array of labels to assign to the Gauge.
      Returns:
      The created LabelledGauge instance.
    • createTimer

      default OperationTimer createTimer(MetricCategory category, String name, String help)
      Creates a Timer.
      Parameters:
      category - The MetricCategory this timer is assigned to.
      name - A name for this metric.
      help - A human readable description of the metric.
      Returns:
      The created Timer instance.
    • createLabelledTimer

      LabelledMetric<OperationTimer> createLabelledTimer(MetricCategory category, String name, String help, String... labelNames)
      Creates a Timer with assigned labels.
      Parameters:
      category - The MetricCategory this timer is assigned to.
      name - A name for this metric.
      help - A human readable description of the metric.
      labelNames - An array of labels to assign to the Timer.
      Returns:
      The created LabelledMetric instance.
    • createSimpleTimer

      default OperationTimer createSimpleTimer(MetricCategory category, String name, String help)
      Creates a simple Timer.
      Parameters:
      category - The MetricCategory this timer is assigned to.
      name - A name for this metric.
      help - A human readable description of the metric.
      Returns:
      The created Timer instance.
    • createSimpleLabelledTimer

      LabelledMetric<OperationTimer> createSimpleLabelledTimer(MetricCategory category, String name, String help, String... labelNames)
      Creates a simple Timer with assigned labels.
      Parameters:
      category - The MetricCategory this timer is assigned to.
      name - A name for this metric.
      help - A human readable description of the metric.
      labelNames - An array of labels to assign to the Timer.
      Returns:
      The created Timer instance.
    • createGauge

      default void createGauge(MetricCategory category, String name, String help, DoubleSupplier valueSupplier)
      Creates a gauge for displaying double vales. A gauge is a metric to report the current value. The metric value may go up or down.
      Parameters:
      category - The MetricCategory this gauge is assigned to.
      name - A name for this metric.
      help - A human readable description of the metric.
      valueSupplier - A supplier for the double value to be presented.
    • createIntegerGauge

      default void createIntegerGauge(MetricCategory category, String name, String help, IntSupplier valueSupplier)
      Creates a gauge for displaying integer values.
      Parameters:
      category - The MetricCategory this gauge is assigned to.
      name - A name for this metric.
      help - A human readable description of the metric.
      valueSupplier - A supplier for the integer value to be presented.
    • createLongGauge

      default void createLongGauge(MetricCategory category, String name, String help, LongSupplier valueSupplier)
      Creates a gauge for displaying long values.
      Parameters:
      category - The MetricCategory this gauge is assigned to.
      name - A name for this metric.
      help - A human readable description of the metric.
      valueSupplier - A supplier for the long value to be presented.
    • createLabelledHistogram

      LabelledMetric<Histogram> createLabelledHistogram(MetricCategory category, String name, String help, double[] buckets, String... labelNames)
      Creates a histogram with assigned labels
      Parameters:
      category - The MetricCategory this histogram is assigned to.
      name - A name for this metric.
      help - A human-readable description of the metric.
      buckets - An array of buckets to assign to the histogram
      labelNames - An array of labels to assign to the histogram.
      Returns:
      The labelled histogram.
    • createHistogram

      default Histogram createHistogram(MetricCategory category, String name, String help, double[] buckets)
      Creates a histogram
      Parameters:
      category - The MetricCategory this histogram is assigned to.
      name - A name for this metric.
      help - A human-readable description of the metric.
      buckets - An array of buckets to assign to the histogram
      Returns:
      The labelled histogram.
    • createLabelledSuppliedSummary

      LabelledSuppliedSummary createLabelledSuppliedSummary(MetricCategory category, String name, String help, String... labelNames)
      Create a summary with assigned labels, that is computed externally to this metric system. Useful when existing libraries calculate the summary data on their own, and we want to export that summary via the configured metric system. A notable example are RocksDB statistics.
      Parameters:
      category - The MetricCategory this external summary is assigned to.
      name - A name for the metric.
      help - A human readable description of the metric.
      labelNames - An array of labels to assign to the supplier summary.
      Returns:
      The created labelled supplied summary
    • createSummary

      default void createSummary(MetricCategory category, String name, String help, Supplier<ExternalSummary> summarySupplier)
      Create a summary that is computed externally to this metric system. Useful when existing libraries calculate the summary data on their own, and we want to export that summary via the configured metric system. A notable example are RocksDB statistics.
      Parameters:
      category - The MetricCategory this external summary is assigned to.
      name - A name for the metric.
      help - A human readable description of the metric.
      summarySupplier - A supplier to retrieve the summary data when needed.
    • createGuavaCacheCollector

      void createGuavaCacheCollector(MetricCategory category, String name, com.google.common.cache.Cache<?,?> cache)
      Collect metrics from Guava cache.
      Parameters:
      category - The MetricCategory this Guava cache is assigned to.
      name - the name to identify this Guava cache, must be unique.
      cache - the Guava cache
    • getEnabledCategories

      Set<MetricCategory> getEnabledCategories()
      Provides an immutable view into the metric categories enabled for metric collection.
      Returns:
      the set of enabled metric categories.
    • isCategoryEnabled

      default boolean isCategoryEnabled(MetricCategory category)
      Checks if a particular category of metrics is enabled.
      Parameters:
      category - the category to check
      Returns:
      true if the category is enabled, false otherwise