Skip to content

Commit

Permalink
updated prometheus client to 1.10
Browse files Browse the repository at this point in the history
  • Loading branch information
Awethon committed Dec 27, 2023
1 parent 9f60af6 commit d928063
Show file tree
Hide file tree
Showing 20 changed files with 904 additions and 878 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ This file summarizes **notable** changes for each release, but does not describe
Initial Stable Release of Epimetheus. This exposes a set of tools for safely abstacting over Prometheus metrics.
We start with the epic of epimetheus to walk through all the tools you need to know, where we expose the core mechanics.

A central collection of the shared mutable state of the metrics being aggregated called a `CollectorRegistry`.
A central collection of the shared mutable state of the metrics being aggregated called a `PrometheusRegistry`.

There are 4 metric types Counter, Gauge, Histogram and Summary.

Expand Down
17 changes: 8 additions & 9 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ ThisBuild / developers := List(
ThisBuild / tlSonatypeUseLegacyHost := true
ThisBuild / githubWorkflowJavaVersions := Seq(JavaSpec.temurin("17"))

val Scala213 = "2.13.8"
val Scala213 = "2.13.12"

ThisBuild / crossScalaVersions := Seq("2.12.15", "3.2.2", Scala213)
ThisBuild / crossScalaVersions := Seq("2.12.18", "3.2.2", Scala213)
ThisBuild / scalaVersion := crossScalaVersions.value.last

lazy val `epimetheus` = tlCrossRootProject
Expand All @@ -32,7 +32,7 @@ lazy val site = project.in(file("site"))
.dependsOn(core)


val prometheusV = "0.16.0"
val prometheusV = "1.1.0"
val catsV = "2.9.0"
val catsEffectV = "3.4.8"
val shapelessV = "2.3.9"
Expand All @@ -51,14 +51,13 @@ lazy val commonSettings = Seq(
Compile / doc / scalacOptions ++= Opts.doc.title("epimetheus"),

libraryDependencies ++= Seq(
"io.prometheus" % "simpleclient" % prometheusV,
"io.prometheus" % "simpleclient_common" % prometheusV,
"io.prometheus" % "simpleclient_hotspot" % prometheusV,
"io.prometheus" % "prometheus-metrics-core" % prometheusV,
"io.prometheus" % "prometheus-metrics-instrumentation-jvm" % prometheusV,

"org.typelevel" %% "cats-core" % catsV,
"org.typelevel" %% "cats-effect" % catsEffectV,
"org.typelevel" %% "cats-core" % catsV,
"org.typelevel" %% "cats-effect" % catsEffectV,

"org.typelevel" %%% "munit-cats-effect-3" % munitCatsEffectV % Test
"org.typelevel" %%% "munit-cats-effect-3" % munitCatsEffectV % Test
),
libraryDependencies ++= PartialFunction.condOpt(CrossVersion.partialVersion(scalaVersion.value)) { case Some((2, _)) =>
Seq(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package io.chrisdavenport.epimetheus

import cats._
import io.prometheus.client.{Summary => JSummary}
import io.prometheus.metrics.core.metrics.{Summary => JSummary}

import scala.language.experimental.macros
import scala.reflect.macros.whitebox
Expand Down
80 changes: 28 additions & 52 deletions core/src/main/scala/io/chrisdavenport/epimetheus/Collector.scala
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
package io.chrisdavenport.epimetheus

import cats.implicits._
import cats.effect._
import io.prometheus.client.{Collector => JCollector}
import io.prometheus.client.hotspot._
import io.prometheus.metrics.model.registry.{Collector => JCollector}
import io.prometheus.metrics.instrumentation.jvm._

/**
* A [[Collector]] Represents a Metric or Group of Metrics that
* can be registered with a [[CollectorRegistry]].
*
* can be registered with a [[PrometheusRegistry]].
*
* This is generally used for wrapping and bringing in Collectors
* as defined for Java Components
*
*
*/
final class Collector private (private val underlying: JCollector)
object Collector {
Expand All @@ -24,54 +23,31 @@ object Collector {
/**
* Register all defaults with the supplied registry.
*/
def registerDefaults[F[_]: Sync](cr: CollectorRegistry[F]): F[Unit] =
for {
bpe <- BufferPoolsExports[F]
_ <- cr.register(bpe)
cle <- ClassLoadingExports
_ <- cr.register(cle)
gce <- GarbageCollectorExports
_ <- cr.register(gce)
mae <- MemoryAllocationExports
_ <- cr.register(mae)
mpe <- MemoryPoolsExports
_ <- cr.register(mpe)
se <- StandardExports
_ <- cr.register(se)
te <- ThreadExports
_ <- cr.register(te)
vie <- VersionInfoExports
_ <- cr.register(vie)
} yield ()
def registerDefaults[F[_]: Sync](pr: PrometheusRegistry[F]): F[Unit] =
registerJvmMetrics[F](pr)

def defaultCollectorRegisterDefaults[F[_]: Sync]: F[Unit] = Sync[F].delay{
DefaultExports.initialize
}
// registers all jvm metrics
def registerJvmMetrics[F[_] : Sync](pr: PrometheusRegistry[F]): F[Unit] =
Sync[F].delay(JvmMetrics.builder().register(pr.underlying))

def BufferPoolsExports[F[_]: Sync]: F[Collector] =
Sync[F].delay(new BufferPoolsExports())
.map(Unsafe.fromJava(_))
def ClassLoadingExports[F[_]: Sync]: F[Collector] =
Sync[F].delay(new ClassLoadingExports())
.map(Unsafe.fromJava(_))
def GarbageCollectorExports[F[_]: Sync]: F[Collector] =
Sync[F].delay(new GarbageCollectorExports())
.map(Unsafe.fromJava(_))
def MemoryAllocationExports[F[_]: Sync]: F[Collector] =
Sync[F].delay(new MemoryAllocationExports())
.map(Unsafe.fromJava(_))
def MemoryPoolsExports[F[_]: Sync]: F[Collector] =
Sync[F].delay(new MemoryPoolsExports())
.map(Unsafe.fromJava(_))
def StandardExports[F[_]: Sync]: F[Collector] =
Sync[F].delay(new StandardExports())
.map(Unsafe.fromJava(_))
def ThreadExports[F[_]: Sync]: F[Collector] =
Sync[F].delay(new ThreadExports())
.map(Unsafe.fromJava(_))
def VersionInfoExports[F[_]: Sync]: F[Collector] =
Sync[F].delay(new VersionInfoExports())
.map(Unsafe.fromJava(_))
def registerJvmBufferPoolMetrics[F[_]: Sync](pr: PrometheusRegistry[F]): F[Unit] =
Sync[F].delay(JvmBufferPoolMetrics.builder().register(pr.underlying))
def registerJvmClassLoadingMetrics[F[_]: Sync](pr: PrometheusRegistry[F]): F[Unit] =
Sync[F].delay(JvmClassLoadingMetrics.builder().register(pr.underlying))
def registerJvmCompilationMetrics[F[_]: Sync](pr: PrometheusRegistry[F]): F[Unit] =
Sync[F].delay(JvmCompilationMetrics.builder().register(pr.underlying))
def registerJvmGarbageCollectorMetrics[F[_]: Sync](pr: PrometheusRegistry[F]): F[Unit] =
Sync[F].delay(JvmGarbageCollectorMetrics.builder().register(pr.underlying))
def registerJvmMemoryMetrics[F[_] : Sync](pr: PrometheusRegistry[F]): F[Unit] =
Sync[F].delay(JvmMemoryMetrics.builder().register(pr.underlying))
def registerJvmMemoryPoolAllocationMetrics[F[_]: Sync](pr: PrometheusRegistry[F]): F[Unit] =
Sync[F].delay(JvmMemoryPoolAllocationMetrics.builder().register(pr.underlying))
def registerProcessMetrics[F[_] : Sync](pr: PrometheusRegistry[F]): F[Unit] =
Sync[F].delay(ProcessMetrics.builder().register(pr.underlying))
def registerJvmRuntimeInfoMetric[F[_] : Sync](pr: PrometheusRegistry[F]): F[Unit] =
Sync[F].delay(JvmRuntimeInfoMetric.builder().register(pr.underlying))
def registerJvmThreadsMetrics[F[_]: Sync](pr: PrometheusRegistry[F]): F[Unit] =
Sync[F].delay(JvmThreadsMetrics.builder().register(pr.underlying))
}

object Unsafe {
Expand Down

This file was deleted.

Loading

0 comments on commit d928063

Please sign in to comment.