-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1160 from avast/http4s-prometheus-conflict
Http4s prometheus conflict
- Loading branch information
Showing
5 changed files
with
56 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
...theus/src/main/scala/com/avast/sst/micrometer/prometheus/MicrometerPrometheusConfig.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,14 @@ | ||
package com.avast.sst.micrometer.prometheus | ||
|
||
import io.micrometer.prometheus.HistogramFlavor | ||
|
||
import java.util.concurrent.TimeUnit | ||
import scala.concurrent.duration.Duration | ||
|
||
final case class MicrometerPrometheusConfig( | ||
step: Duration = Duration(1, TimeUnit.MINUTES), | ||
prefix: String = "", | ||
descriptions: Boolean = true, | ||
histogramFlavor: HistogramFlavor = HistogramFlavor.Prometheus, | ||
commonTags: Map[String, String] = Map.empty | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
...rc/test/scala/com/avast/sst/micrometer/prometheus/Http4sPrometheusCompatibilityTest.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package com.avast.sst.micrometer.prometheus | ||
|
||
import cats.effect.* | ||
import monix.eval.Task | ||
import monix.eval.instances.CatsConcurrentEffectForTask | ||
import monix.execution.Scheduler | ||
import org.http4s.metrics.prometheus.PrometheusExportService | ||
import org.scalatest.funsuite.AnyFunSuite | ||
|
||
import java.util.concurrent.{SynchronousQueue, ThreadPoolExecutor, TimeUnit} | ||
import scala.concurrent.ExecutionContext | ||
|
||
class Http4sPrometheusCompatibilityTest extends AnyFunSuite { | ||
|
||
implicit def scheduler: Scheduler = Scheduler.global | ||
|
||
protected def options: Task.Options = Task.defaultOptions.withSchedulerFeatures(scheduler) | ||
|
||
protected implicit lazy val catsEffect: ConcurrentEffect[Task] = | ||
new CatsConcurrentEffectForTask()(scheduler, options) | ||
|
||
test("Http4s Prometheus compatibility test") { | ||
|
||
val config = MicrometerPrometheusConfig() | ||
|
||
val blockingExecutor = new ThreadPoolExecutor(1, 1, 10, TimeUnit.SECONDS, new SynchronousQueue()) | ||
val blocker = Blocker.liftExecutionContext(ExecutionContext.fromExecutor(blockingExecutor)) | ||
|
||
val test = for { | ||
|
||
prometheusMeterRegistry <- MicrometerPrometheusModule.make(config, blocker) | ||
_ = PrometheusExportService(prometheusMeterRegistry.getPrometheusRegistry) | ||
_ <- PrometheusExportService.addDefaults(prometheusMeterRegistry.getPrometheusRegistry) | ||
} yield () | ||
|
||
test.use(_ => Task.unit).runSyncUnsafe() | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters