cats-effect icon indicating copy to clipboard operation
cats-effect copied to clipboard

Add `IORuntimeMetrics` and `CpuStarvationMetrics`

Open iRevive opened this issue 1 year ago • 2 comments
trafficstars

The first step towards cross-platform IORuntimeMetrics. This PR also introduces a cross-platform CpuStarvationMetrics.

Motivation

It would be nice to have an option to access runtime metrics without relying on MBeans. For example, you can use Scala OpenTelemetry SDK to collect starvation metrics on all platforms (JVM, JS, Native).

Usage

IO.delay(runtime.metrics.cpuStarvation.maxDrift())
  .flatMap(drift => IO.println(s"current drift: $drift"))
  .delayBy(2.seconds)
  .foreverM

Next steps

Add WSTP compute and local queue metrics. The draft - https://github.com/typelevel/cats-effect/pull/3317.

iRevive avatar Jul 19 '24 12:07 iRevive