Skip to content

Latest commit

 

History

History

telemetry

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Telemetry

The metrics utility for offchain-sdk.

types.go defines the interface for the supported metrics methods.

By specifying the configuration, the metrics can be emitted via Datadog and/or Prometheus. Please see the following subsections for detailed configurations.

Datadog

Configuration

The first step is adding a section in your config file. See following subsection for details. The source code defining those configs can be found in config.go.

Datadog Configs

  • Enabled: Set to true to enable metrics emission to Datadog.

  • StatsdAddr: The address of the Datadog StatsD client. This is needed if the metrics should be emitted from Datadog.

  • Namespace: This will appear as the Namespace tag in Datadog.

Datadog Methods

metrics.go implements the Datadog version of the supported metrics methods defined in types.go. All implementations are simple wrappers around the native methods provided by the Datadog statsd client.

Prometheus

Configuration

The first step is to add a section in your config file. The source code defining these configs can be found in config.go.

Prometheus Configs

  • Enabled: Set to true to enable metrics emission to Prometheus.

  • Namespace and Subsystem: These fields will be added as prefixes to the metrics name. For example, if Namespace is app and Subsystem is api, then the full metrics name of request_success will be app_api_request_success.

  • HistogramBucketCount: The number of buckets used for Histogram typed metrics. Default is 10.

    • Note: Each bucket represents an observation that Prometheus scrapes. Therefore, it's recommended to keep the number of buckets within a manageable scale, typically in the tens.

Prometheus Methods

Different from Datadog, Prometheus only provides 4 basic metrics type. As a result, metrics.go implements the metrics methods defined in type.go using these four basic Prometheus metrics. The following subsection documents the methods with implementation notes. For more information on the four basic Prometheus metrics, please see here.

  • Gauge: This method wraps the Gauge metrics of Prometheus.

  • Decr and Incr: Implemented using the Gauge metrics of Prometheus.

  • Count: This method wraps the Count metrics of Prometheus. Note that after deployment or instance restart, Count will reset to 0. This is by design in Prometheus.

  • IncMonotonic and Error: Implemented using the Count metrics of Prometheus.

  • Histogram: This method wraps the Histogram metrics of Prometheus with linear buckets.

    • Note: The maximum value covered is determined by the product of BucketCount and the rate parameter.
    • TODO: Support different types of buckets beyond linear buckets in future implementations.
  • Time and Latency: Implemented using the Summary metrics of Prometheus, with pre-defined quantile observations: p50, p90, and p99.