Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add IORuntimeMetrics and CpuStarvationMetrics #4106

Open
wants to merge 2 commits into
base: series/3.x
Choose a base branch
from

Conversation

iRevive
Copy link
Contributor

@iRevive iRevive commented Jul 19, 2024

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 - #3317.

* @note
* the value may differ between invocations
*/
def clockDriftCurrent(): FiniteDuration
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Long could be more suitable and more memory efficient.

@djspiewak
Copy link
Member

What do you think about moving this stuff to cats.effect.unsafe.metrics? That feels like a more appropriate place, since we really don't want to wrap the impure interfaces in IO, but at the same time it's absolutely not a "safe" set of APIs in the sense we normally use the word.

@iRevive
Copy link
Contributor Author

iRevive commented Jul 31, 2024

Good point. I moved classes to the cats.effect.unsafe.metrics package.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants