Skip to content

Add IORuntimeMetrics and CpuStarvationMetrics #4106

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

Closed
wants to merge 2 commits into 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.

@iRevive iRevive force-pushed the cpu-starvation-metrics branch from 2d3ff52 to aa20e9c Compare July 19, 2024 12:09
@iRevive iRevive force-pushed the cpu-starvation-metrics branch from aa20e9c to 8a5a3da Compare July 19, 2024 12:20
* @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.

@iRevive iRevive force-pushed the cpu-starvation-metrics branch from 8a5a3da to ce1fa92 Compare July 19, 2024 18:13
@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.

@iRevive iRevive force-pushed the cpu-starvation-metrics branch from c66b328 to 50ab02a Compare November 22, 2024 07:33
@iRevive
Copy link
Contributor Author

iRevive commented Nov 22, 2024

Closing this one in favor of #3317.

@iRevive iRevive closed this Nov 22, 2024
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