Class FileMetricsPublisher

java.lang.Object
com.j256.simplemetrics.utils.FileMetricsPublisher
All Implemented Interfaces:
MetricsUpdater

public class FileMetricsPublisher extends Object implements MetricsUpdater
Exposes metrics that can be found from files on file-system. This is often used to read from the /proc file-system under Linux. Metrics are configured with the FileMetric class. A common file metric is the number of open file-descriptors being used by the JVM.

NOTE: If you are using the no-arg constructor (like with Spring) you will need to make sure that initialize() is called.

Author:
graywatson
  • Constructor Details

    • FileMetricsPublisher

      public FileMetricsPublisher()
    • FileMetricsPublisher

      public FileMetricsPublisher(MetricsManager metricsManager, List<FileMetric> fileMetrics)
      Constructs our publisher and calls initialize().
  • Method Details

    • initialize

      public void initialize()
      Should be called if the no-arg construct is being used and after the various setters have been called. Maybe by Springs init mechanism?
    • setMetricsManager

      public void setMetricsManager(MetricsManager metricsManager)
      Metrics manager that we add our metrics to.
    • setFileMetrics

      public void setFileMetrics(FileMetric[] fileMetrics)
      Sets the file metrics that we are publishing.
    • updateMetrics

      public void updateMetrics()
      Description copied from interface: MetricsUpdater
      Called by MetricsManager right before it is to persist the metrics.
      Specified by:
      updateMetrics in interface MetricsUpdater
    • getFailedUpdateCount

      public long getFailedUpdateCount()
      Number of times we were unable to update a metric because of some i/o or parse problem.
    • getMetricsValues

      public String[] getMetricsValues()
      Get the values for all of the metric managed by this class.