Skip to main content
Version: ZIO 2.x

Introduction

In highly concurrent applications, things are interconnected, so maintaining such setup to run smoothly and without application downtimes is very challenging.

Imagine we have a complex infrastructure with lots of services. Services are replicated and distributed across our servers. So we have no insight on what happening on the across our services at level of errors, response latency, service uptime, etc. With ZIO Metrics, we can capture these different metrics and provide them to a metric service for later investigation.

ZIO supports 5 types of Metrics:

  • Counter — The Counter is used for any value that increases over time like request counts.
  • Gauge — The gauge is a single numerical value that can arbitrary goes up or down over time like memory usage.
  • Histogram — The Histogram is used to track the distribution of a set of observed values across a set of buckets like request latencies.
  • Summary — The Summary represents a sliding window of a time series along with metrics for certain percentiles of the time series, referred to as quantiles like request latencies.
  • Frequency — The Frequency is a metric that counts the number of occurrences of distinct string values.

All ZIO Metrics are defined in the form of ZIO Aspects that can be applied to effects without changing the signature of the effect it is applied to:

TODO

After adding metrics into our application, whenever we want we can capture snapshot of all metrics recorded by our application:

TODO

Also, a metric service can implement the MetricListener interface:

TODO

And then we can install that to our application which will be notified every time a metric is updated:

TODO