Skip to content

Commit

Permalink
Move IORuntimeMetrics to cats.effect.unsafe.metrics package
Browse files Browse the repository at this point in the history
  • Loading branch information
iRevive committed Jul 31, 2024
1 parent ce1fa92 commit c66b328
Show file tree
Hide file tree
Showing 13 changed files with 26 additions and 18 deletions.
7 changes: 6 additions & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -679,7 +679,12 @@ lazy val core = crossProject(JSPlatform, JVMPlatform, NativePlatform)
"cats.effect.unsafe.FiberMonitorCompanionPlatform"),
// internal API change, makes CpuStarvationMetrics available on all platforms
ProblemFilters.exclude[MissingClassProblem](
"cats.effect.metrics.JvmCpuStarvationMetrics$NoOpCpuStarvationMetrics")
"cats.effect.metrics.JvmCpuStarvationMetrics$NoOpCpuStarvationMetrics"),
ProblemFilters.exclude[MissingClassProblem]("cats.effect.metrics.CpuStarvationMetrics"),
// package-private classes moved to the `cats.effect.unsafe.metrics` package
ProblemFilters.exclude[MissingClassProblem]("cats.effect.metrics.CpuStarvation"),
ProblemFilters.exclude[MissingClassProblem]("cats.effect.metrics.CpuStarvation$"),
ProblemFilters.exclude[MissingClassProblem]("cats.effect.metrics.CpuStarvationMBean")
) ++ {
if (tlIsScala3.value) {
// Scala 3 specific exclusions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
* limitations under the License.
*/

package cats.effect.metrics
package cats.effect.unsafe.metrics

private[metrics] abstract class IORuntimeMetricsCompanionPlatform {
this: IORuntimeMetrics.type =>

private[effect] def apply(): IORuntimeMetrics =
private[unsafe] def apply(): IORuntimeMetrics =
new IORuntimeMetrics {
private[effect] val cpuStarvationSampler: CpuStarvationSampler =
CpuStarvationSampler()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@
* limitations under the License.
*/

package cats.effect.metrics
package cats.effect.unsafe.metrics

private[metrics] trait IORuntimeMetricsPlatform { this: IORuntimeMetrics => }
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package cats.effect.metrics

import cats.effect.{IO, Resource}
import cats.effect.std.Console
import cats.effect.unsafe.metrics.{CpuStarvation, CpuStarvationSampler}
import cats.syntax.functor._

import java.io.{PrintWriter, StringWriter}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,12 @@
* limitations under the License.
*/

package cats.effect.metrics
package cats.effect.unsafe.metrics

private[effect] final class CpuStarvation(
sampler: CpuStarvationSampler
) extends CpuStarvationMBean {

private final class CpuStarvation(sampler: CpuStarvationSampler) extends CpuStarvationMBean {
def getCpuStarvationCount(): Long =
sampler.cpuStarvationCount()

Expand All @@ -26,5 +29,3 @@ private final class CpuStarvation(sampler: CpuStarvationSampler) extends CpuStar
def getCurrentClockDriftMs(): Long =
sampler.clockDriftCurrentMs()
}

private object CpuStarvation
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
* limitations under the License.
*/

package cats.effect.metrics
package cats.effect.unsafe.metrics

/**
* An MBean interfaces for monitoring when CPU starvation occurs.
*/
private[metrics] trait CpuStarvationMBean {
private[unsafe] trait CpuStarvationMBean {

/**
* Returns the number of times CPU starvation has occurred.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
* limitations under the License.
*/

package cats.effect.metrics
package cats.effect.unsafe.metrics

private[metrics] abstract class IORuntimeMetricsCompanionPlatform {
this: IORuntimeMetrics.type =>

private[effect] def apply(): IORuntimeMetrics =
private[unsafe] def apply(): IORuntimeMetrics =
new IORuntimeMetrics {
private[effect] val cpuStarvationSampler: CpuStarvationSampler =
CpuStarvationSampler()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@
* limitations under the License.
*/

package cats.effect.metrics
package cats.effect.unsafe.metrics

private[metrics] trait IORuntimeMetricsPlatform { this: IORuntimeMetrics => }
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@

package cats.effect

import cats.effect.metrics.{CpuStarvationSampler, CpuStarvationWarningMetrics}
import cats.effect.metrics.CpuStarvationWarningMetrics
import cats.effect.std.Console
import cats.effect.unsafe.IORuntimeConfig
import cats.effect.unsafe.metrics.CpuStarvationSampler
import cats.syntax.all._

import scala.concurrent.duration.{Duration, FiniteDuration}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ package cats.effect
package unsafe

import cats.effect.Platform.static
import cats.effect.metrics.IORuntimeMetrics
import cats.effect.unsafe.metrics.IORuntimeMetrics

import scala.concurrent.ExecutionContext

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package cats.effect.metrics
package cats.effect.unsafe.metrics

import scala.concurrent.duration._

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package cats.effect.metrics
package cats.effect.unsafe.metrics

import cats.effect.IO

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package cats.effect.metrics
package cats.effect.unsafe.metrics

/**
* The runtime-specific metrics.
Expand Down

0 comments on commit c66b328

Please sign in to comment.