Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/permutive-engineering/prometheus4cats
Functional Prometheus Metrics API for Scala
https://github.com/permutive-engineering/prometheus4cats
dsl metrics prometheus prometheus-metrics scala
Last synced: 28 days ago
JSON representation
Functional Prometheus Metrics API for Scala
- Host: GitHub
- URL: https://github.com/permutive-engineering/prometheus4cats
- Owner: permutive-engineering
- License: apache-2.0
- Created: 2022-09-23T10:55:18.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-12-01T05:02:49.000Z (about 1 month ago)
- Last Synced: 2024-12-01T06:21:53.386Z (about 1 month ago)
- Topics: dsl, metrics, prometheus, prometheus-metrics, scala
- Language: Scala
- Homepage: https://permutive-engineering.github.io/prometheus4cats/
- Size: 1.79 MB
- Stars: 20
- Watchers: 7
- Forks: 2
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
# Functional Prometheus Metrics API for Scala
This library is designed to provide a tasteful Scala API for exposing [Prometheus] metrics using [Cats-Effect]. It is a
mix between Permutive's internal library and [Epimetheus]. See the [design page](https://permutive-engineering.github.io/prometheus4cats/docs/design) for more information.## Features
- [A fluent metric builder DSL](https://permutive-engineering.github.io/prometheus4cats/docs/interface/dsl)
- [Metric name prefix and common labels](https://permutive-engineering.github.io/prometheus4cats/docs/interface/metric-factory)
- [Decoupled backend for registering metrics](https://permutive-engineering.github.io/prometheus4cats/docs/interface/metric-registry)## Quickstart Usage
This library is currently available for Scala binary versions 2.12 and 2.13 and 3.2.
**For detailed code examples see the [metrics DSL](https://permutive-engineering.github.io/prometheus4cats/docs/interface/dsl) documentation.**
To use the latest version, include the following in your `build.sbt`:
```scala
libraryDependencies ++= Seq(
"com.permutive" %% "prometheus4cats" % "3.0.0",
"com.permutive" %% "prometheus4cats-java" % "3.0.0"
)
``````scala
import cats.effect.IOimport org.typelevel.log4cats.Logger
import org.typelevel.log4cats.noop.NoOpLoggerimport prometheus4cats.MetricFactory
import prometheus4cats.javasimpleclient.JavaMetricRegistry// Java client requires a logger
implicit val logger: Logger[IO] = NoOpLogger.implval counterResource =
for {
registry <- JavaMetricRegistry.Builder().build[IO]
factory = MetricFactory.builder.build(registry)
counter <- factory.counter("my_counter_total")
.ofLong
.help("My Counter")
.label[String]("some_label")
.build
} yield countercounterResource.use { counter => counter.inc("Some label value") }
```If you want to know more about all the library's features, please head on to [its website](https://permutive-engineering.github.io/prometheus4cats/) where you will find much more information.
## Contributors for this project
| | | | | |
| :--: | :--: | :--: | :--: | :--: |
| janstenpickle | TimWSpence | alejandrohdezma | bastewart | desbo |[Prometheus]: https://prometheus.io
[Epimetheus]: https://github.com/davenverse/epimetheus
[Cats-Effect]: https://typelevel.org/cats-effect