Metrics
ZIO Metrics allows you to apply special aspects to the workflows of any ZIO based application. This is called instrumentation. The type of the original ZIO workflow will not change by adding one or more aspects to it. (From here on, we'll use the word effect instead of workflow.)
Whenever an instrumented effect executes, all the aspects will be executed as well. Each of the aspects will capture some data of interest and update some Metric internal state. Which data will be captured and how it can be used later on is dependent on the metric type associated with the aspect. Capturing metrics data is usually called 'measuring'.
Metrics are normally collected to be displayed in an application like Grafana or a cloud based platform like DatadogHQ or NewRelic. In order to support such a range of different platforms, the metric state is kept in an internal data structure which is optimized to update as efficiently as possible. The data required by the collecting platforms is generated only when it is required.
ZIO Metrics Connectors also allows us to dump current metric states (in one of the next minor releases) out of the box to analyze the metrics in the development phase before the decision for a metric platform has been made or in cases when the platform might not be feasible to use in development.
Changing which platform the metrics are reported to has no impact on the application at all. Once instrumented properly, the decision where to report to happens 'at the end of the world', that is, in the ZIO application's main entry point, by providing one or more of the available reporting clients.
Currently, ZIO Metrics Connectors provides integrations with the following reporting clients:
Adding ZIO Metrics Connectors to your project​
Import the corresponding dependency based on your reporting infrastructure:
libraryDependencies ++= {
Seq(
"dev.zio" %% "zio-metrics-connectors" % "2.4.2", // core library
"dev.zio" %% "zio-metrics-connectors-prometheus" % "2.4.2", // Prometheus client
"dev.zio" %% "zio-metrics-connectors-datadog" % "2.4.2", // DataDog client
"dev.zio" %% "zio-metrics-connectors-newrelic" % "2.4.2", // NewRelic client
"dev.zio" %% "zio-metrics-connectors-statsd" % "2.4.2", // StatsD client
"dev.zio" %% "zio-metrics-connectors-micrometer" % "2.4.2" // Micrometer client
)
}
Please refer to:
- Metrics Reference for more information on the metrics currently supported
- Prometheus Client to learn more about the mapping from ZIO Metrics to Prometheus
- StatsD Client to learn more about the mapping from ZIO Metrics to StatsD
- DataDog Client to learn more about the mapping from ZIO Metrics to DataDog
- Micrometer to learn more about the mapping from ZIO Metrics to Micrometer