Skip to content

Commit

Permalink
Merge pull request #338 from Awethon/promtheus-client-update
Browse files Browse the repository at this point in the history
updated prometheus client to 1.10
  • Loading branch information
ChristopherDavenport authored Jan 6, 2024
2 parents 9f60af6 + 8b0cf4f commit 4a2c61e
Show file tree
Hide file tree
Showing 22 changed files with 973 additions and 917 deletions.
24 changes: 12 additions & 12 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
scala: [2.12.15, 3.2.2, 2.13.8]
scala: [2.12.18, 3.3.1, 2.13.12]
java: [temurin@17]
project: [rootJVM]
runs-on: ${{ matrix.os }}
Expand Down Expand Up @@ -102,7 +102,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
scala: [2.13.8]
scala: [2.13.12]
java: [temurin@17]
runs-on: ${{ matrix.os }}
steps:
Expand Down Expand Up @@ -139,32 +139,32 @@ jobs:
~/Library/Caches/Coursier/v1
key: ${{ runner.os }}-sbt-cache-v2-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }}

- name: Download target directories (2.12.15, rootJVM)
- name: Download target directories (2.12.18, rootJVM)
uses: actions/download-artifact@v3
with:
name: target-${{ matrix.os }}-${{ matrix.java }}-2.12.15-rootJVM
name: target-${{ matrix.os }}-${{ matrix.java }}-2.12.18-rootJVM

- name: Inflate target directories (2.12.15, rootJVM)
- name: Inflate target directories (2.12.18, rootJVM)
run: |
tar xf targets.tar
rm targets.tar
- name: Download target directories (3.2.2, rootJVM)
- name: Download target directories (3.3.1, rootJVM)
uses: actions/download-artifact@v3
with:
name: target-${{ matrix.os }}-${{ matrix.java }}-3.2.2-rootJVM
name: target-${{ matrix.os }}-${{ matrix.java }}-3.3.1-rootJVM

- name: Inflate target directories (3.2.2, rootJVM)
- name: Inflate target directories (3.3.1, rootJVM)
run: |
tar xf targets.tar
rm targets.tar
- name: Download target directories (2.13.8, rootJVM)
- name: Download target directories (2.13.12, rootJVM)
uses: actions/download-artifact@v3
with:
name: target-${{ matrix.os }}-${{ matrix.java }}-2.13.8-rootJVM
name: target-${{ matrix.os }}-${{ matrix.java }}-2.13.12-rootJVM

- name: Inflate target directories (2.13.8, rootJVM)
- name: Inflate target directories (2.13.12, rootJVM)
run: |
tar xf targets.tar
rm targets.tar
Expand All @@ -188,7 +188,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
scala: [2.13.8]
scala: [2.13.12]
java: [temurin@17]
runs-on: ${{ matrix.os }}
steps:
Expand Down
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
23 changes: 14 additions & 9 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import com.typesafe.tools.mima.core._

ThisBuild / tlBaseVersion := "0.5" // your current series x.y

ThisBuild / organization := "io.chrisdavenport"
Expand All @@ -12,9 +14,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.3.1", Scala213)
ThisBuild / scalaVersion := crossScalaVersions.value.last

lazy val `epimetheus` = tlCrossRootProject
Expand All @@ -32,7 +34,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 @@ -43,6 +45,8 @@ val munitCatsEffectV = "1.0.7"
// General Settings
lazy val commonSettings = Seq(

mimaBinaryIssueFilters := List({(_: Problem) => false}), // TODO: remove this once switched to next major version

javacOptions ++= Seq("--release", "8"),

scalacOptions --= List("-source", "future", "-Xfatal-warnings"),
Expand All @@ -51,14 +55,15 @@ 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,
"io.prometheus" % "prometheus-metrics-exposition-formats" % 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,
"org.scala-lang.modules" %%% "scala-collection-compat" % "2.11.0" % 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
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.quoted.*

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(PrometheusRegistry.Unsafe.asJava(pr)))

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(PrometheusRegistry.Unsafe.asJava(pr)))
def registerJvmClassLoadingMetrics[F[_]: Sync](pr: PrometheusRegistry[F]): F[Unit] =
Sync[F].delay(JvmClassLoadingMetrics.builder().register(PrometheusRegistry.Unsafe.asJava(pr)))
def registerJvmCompilationMetrics[F[_]: Sync](pr: PrometheusRegistry[F]): F[Unit] =
Sync[F].delay(JvmCompilationMetrics.builder().register(PrometheusRegistry.Unsafe.asJava(pr)))
def registerJvmGarbageCollectorMetrics[F[_]: Sync](pr: PrometheusRegistry[F]): F[Unit] =
Sync[F].delay(JvmGarbageCollectorMetrics.builder().register(PrometheusRegistry.Unsafe.asJava(pr)))
def registerJvmMemoryMetrics[F[_] : Sync](pr: PrometheusRegistry[F]): F[Unit] =
Sync[F].delay(JvmMemoryMetrics.builder().register(PrometheusRegistry.Unsafe.asJava(pr)))
def registerJvmMemoryPoolAllocationMetrics[F[_]: Sync](pr: PrometheusRegistry[F]): F[Unit] =
Sync[F].delay(JvmMemoryPoolAllocationMetrics.builder().register(PrometheusRegistry.Unsafe.asJava(pr)))
def registerProcessMetrics[F[_] : Sync](pr: PrometheusRegistry[F]): F[Unit] =
Sync[F].delay(ProcessMetrics.builder().register(PrometheusRegistry.Unsafe.asJava(pr)))
def registerJvmRuntimeInfoMetric[F[_] : Sync](pr: PrometheusRegistry[F]): F[Unit] =
Sync[F].delay(JvmRuntimeInfoMetric.builder().register(PrometheusRegistry.Unsafe.asJava(pr)))
def registerJvmThreadsMetrics[F[_]: Sync](pr: PrometheusRegistry[F]): F[Unit] =
Sync[F].delay(JvmThreadsMetrics.builder().register(PrometheusRegistry.Unsafe.asJava(pr)))
}

object Unsafe {
Expand Down

This file was deleted.

Loading

0 comments on commit 4a2c61e

Please sign in to comment.