zio / zio-zmx

Monitoring, Metrics and Diagnostics for ZIO
https://zio.github.io/zio-zmx/
Apache License 2.0
85 stars 47 forks source link

Migrate StatsD Client To ZIO 2.0 #303

Closed adamgfraser closed 3 years ago

adamgfraser commented 3 years ago

This ticket is to migrate the existing implementation of the StatsD metric client to ZIO 2.0. The metric client will call the MetricClient.unsafeInstallListener and unsafeRemoveListener methods from ZIO 2.0 here to install a listener that will receive all metric events from the ZIO application. The functionality to start up and shut down the client should be encompassed in a ZIOApp that can be composed with other ZIOApp values using the <> operator on ZIOApp.

object MetricClient {

  /**
   * Unsafely installs the specified metric listener.
   */
  final def unsafeInstallListener(listener: MetricListener): Unit =
    metricState.installListener(listener)

  /**
   * Unsafely removed the specified metric listener.
   */
  final def unsafeRemoveListener(listener: MetricListener): Unit =
    metricState.removeListener(listener)
}
atooni commented 3 years ago

The code has been migrated, we now need to refactor the test suite to verify that we are exposing our metrics using the statsd protocol.

Also see #317