Skip to content

Commit fe24cbb

Browse files
committed
add compatibility test for http4s-prometheus-metrics
1 parent ca57a9e commit fe24cbb

File tree

3 files changed

+51
-5
lines changed

3 files changed

+51
-5
lines changed

build.sbt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -513,7 +513,12 @@ lazy val micrometerPrometheus = project
513513
.settings(BuildSettings.common)
514514
.settings(
515515
name := "sst-micrometer-prometheus",
516-
libraryDependencies += Dependencies.micrometerPrometheus
516+
libraryDependencies ++= Seq(
517+
Dependencies.micrometerPrometheus,
518+
Dependencies.monixEval % Test,
519+
Dependencies.monixExecution % Test,
520+
Dependencies.http4sPrometheus % Test
521+
)
517522
)
518523

519524
lazy val micrometerPrometheusPureConfig = project
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
package com.avast.sst.micrometer.prometheus
2+
3+
import cats.effect.*
4+
import monix.eval.Task
5+
import monix.eval.instances.CatsConcurrentEffectForTask
6+
import monix.execution.Scheduler
7+
import org.http4s.metrics.prometheus.PrometheusExportService
8+
import org.scalatest.funsuite.AnyFunSuite
9+
10+
import java.util.concurrent.{SynchronousQueue, ThreadPoolExecutor, TimeUnit}
11+
import scala.concurrent.ExecutionContext
12+
13+
class Http4sPrometheusCompatibilityTest extends AnyFunSuite {
14+
15+
implicit def scheduler: Scheduler = Scheduler.global
16+
17+
protected def options: Task.Options = Task.defaultOptions.withSchedulerFeatures(scheduler)
18+
19+
protected implicit lazy val catsEffect: ConcurrentEffect[Task] =
20+
new CatsConcurrentEffectForTask()(scheduler, options)
21+
22+
test("Http4s Prometheus compatibility test") {
23+
24+
val config = MicrometerPrometheusConfig()
25+
26+
val blockingExecutor = new ThreadPoolExecutor(1, 1, 10, TimeUnit.SECONDS, new SynchronousQueue())
27+
val blocker = Blocker.liftExecutionContext(ExecutionContext.fromExecutor(blockingExecutor))
28+
29+
val test = for {
30+
31+
prometheusMeterRegistry <- MicrometerPrometheusModule.make(config, blocker)
32+
_ = PrometheusExportService(prometheusMeterRegistry.getPrometheusRegistry)
33+
_ <- PrometheusExportService.addDefaults(prometheusMeterRegistry.getPrometheusRegistry)
34+
} yield ()
35+
36+
test.use(_ => Task.unit).runSyncUnsafe()
37+
38+
}
39+
}

project/Dependencies.scala

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ object Dependencies {
1717
val http4sEmberServer = "org.http4s" %% "http4s-ember-server" % Versions.http4s
1818
val http4sClient = "org.http4s" %% "http4s-client" % Versions.http4s
1919
val http4sDsl = "org.http4s" %% "http4s-dsl" % Versions.http4s
20+
val http4sPrometheus = "org.http4s" %% "http4s-prometheus-metrics" % Versions.http4s
2021
val http4sServer = "org.http4s" %% "http4s-server" % Versions.http4s
2122
val jacksonDatabind = "com.fasterxml.jackson.core" % "jackson-databind" % "2.17.1"
2223
val jetbrainsAnnotations = "org.jetbrains" % "annotations" % "24.1.0"
@@ -30,6 +31,7 @@ object Dependencies {
3031
val micrometerPrometheus = "io.micrometer" % "micrometer-registry-prometheus" % Versions.micrometerPrometheus
3132
val monixCatnap = "io.monix" %% "monix-catnap" % Versions.monix
3233
val monixEval = "io.monix" %% "monix-eval" % Versions.monix
34+
val monixExecution = "io.monix" %% "monix-execution" % Versions.monix
3335
val postgresql = "org.postgresql" % "postgresql" % "42.7.3"
3436
val pureConfigCore = "com.github.pureconfig" %% "pureconfig-core" % Versions.pureConfig
3537
val pureConfigGeneric = "com.github.pureconfig" %% "pureconfig-generic" % Versions.pureConfig
@@ -51,10 +53,10 @@ object Dependencies {
5153
val doobie = "0.13.4"
5254
val grpc = "1.64.0"
5355
val http4s = "0.22.15"
54-
val micrometerCore = "1.10.13"
55-
val micrometerJmx = "1.10.13"
56-
val micrometerStatsD = "1.10.13"
57-
val micrometerPrometheus = "1.10.13"
56+
val micrometerCore = "1.12.7"
57+
val micrometerJmx = "1.12.7"
58+
val micrometerStatsD = "1.12.7"
59+
val micrometerPrometheus = "1.12.7"
5860
val monix = "3.4.1"
5961
val pureConfig = "0.17.1"
6062

0 commit comments

Comments
 (0)