cats-effect
cats-effect copied to clipboard
Add `IORuntimeMetrics` and `CpuStarvationMetrics`
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.