Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  • Counters -- these are the workhorse of the metrics system. These gather information on how many times some event occurs, or some piece of code is executed during a period of time. These can give you information on where most of the work is happening in the system.
  • Range Samplers -- Not currently used in RNode
  • Gauges -- Currently used to record numbers of peers (see comm/rp/Connect.scala and comm/discovery/KademliaNodeDiscovery.scala). In addition, a variety of information derived from the JVM is recorded using Gauges. These are collected in node/diagnostics/JvmMetrics.scala and use a wrapper called simply “g”.
  • Histograms -- Currently used to record the amount of time to connect to a peer. See comm/rp/Connect.scala.
  • Timers – Are not currently exposed in node/diagnostics/package.scala. Timers can record a start and stop time for an individual event.

...

Future Metrics Migration

As noted, Gauges are currently used in several places. Notably the JVM metrics. Since Gauges are an instantaneous snapshot, and suffer from the Nyquist problems mentioned above, we intend to migrate these to other Kamon metric types. Some will migrate to Counters. Metrics that cannot be expressed as a counter will migrate to either Histograms or Timers. Support for Timers will be added to node/diagnostics/package.scala.

Adding Metrics

Counters

As mentioned above, most metrics should use Counters. Counters are used in cases where we are interested in the numbers of events over time. If you are looking for a metric that shows how many of Event A happens during time T, then a Counter is what you should use. All that is required to add a counter is to call the diagnostics.metrics.incrementCounter method with an appropriate name at a strategic spot in your code. See examples in

  • casper/util/comm/ApproveBlockProtocol.scala
  • comm/rp/Connect.scala
  • blockstorage/*BlockStore.scala

Range Samplers

Not currently used in RNode.

Gauges

The use of Gauges in RNode is deprecated.

Histograms

Metrics that show the quantity or current consumption of resources e.g. memory or disk space should use a Histogram. We will be adding support for these in node/diagnostics/package.scala soon. These will be polled periodically and added to Kamon. Most of the current use of Gauges in node/diagnostics/JvmMetrics.scala will migrate to Histograms.

Timers

Metrics that show how long some class of task takes to perform should use Timers. Support for them will be added in node/diagnostics/package.scala soon. Examples of the use of Timers are time to process a transaction, achieve consensus on a block, ping times, or resource latency.

Prometheus

The Prometheus interface in RNode is created in node/diagnostics/NewPrometheusReporter.scala. Here, a singleton object is created, and a configuration file is read.

...