Skip to content

Commit

Permalink
Add docs, silent mima
Browse files Browse the repository at this point in the history
  • Loading branch information
Denys Fakhritdinov committed Jul 11, 2024
1 parent 49467c0 commit 1da4c59
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 1 deletion.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@ val records: IO[ConsumerRecords[String, String]] = consumer.use { consumer =>
## Java client metrics example

The example below demonstrates creation of `Consumer`, but same can be done for `Producer` as well.

> :warning: Creating consumer/producer will register new set of metrics in Prometheus registry
> thus metric names must not clash. For that you have to provide function of type `ClientId => String`,
> that takes client ID and returns metric prefix. The prefix expected to be unique!
```scala
import ConsumerMetricsOf.*

Expand Down
4 changes: 3 additions & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ lazy val commonSettings = Seq(
ProblemFilters.exclude[ReversedMissingMethodProblem]("com.evolutiongaming.skafka.consumer.Consumer.subscribe"),
ProblemFilters.exclude[DirectMissingMethodProblem](
"com.evolutiongaming.skafka.Converters#MapJOps.asScalaMap$extension"
)
),
ProblemFilters.exclude[DirectMissingMethodProblem]("com.evolutiongaming.skafka.consumer.ConsumerMetrics#ConsumerMetricsOps.mapK$extension"),
ProblemFilters.exclude[DirectMissingMethodProblem]("com.evolutiongaming.skafka.producer.ProducerMetrics#ProducerMetricsOps.mapK$extension"),
)
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@ import scala.concurrent.duration.FiniteDuration

object ConsumerMetricsOf {

/**
* Construct [[ConsumerMetrics]] that will expose Java Kafka client metrics.
*
* @param source original [[ConsumerMetrics]]
* @param prefix function that provides _unique_ prefix for each client
* @param prometheus instance of Prometheus registry
* @return [[ConsumerMetrics]] that exposes Java Kafka client metrics
*/
def withJavaClientMetrics[F[_]: Sync: ToTry](
source: ConsumerMetrics[F],
prefix: ClientId => String,
Expand Down Expand Up @@ -47,6 +55,13 @@ object ConsumerMetricsOf {

implicit final class Syntax[F[_]](val source: ConsumerMetrics[F]) extends AnyVal {

/**
* Construct [[ConsumerMetrics]] that will expose Java Kafka client metrics.
*
* @param prefix function that provides _unique_ prefix for each client
* @param prometheus instance of Prometheus registry
* @return [[ConsumerMetrics]] that exposes Java Kafka client metrics
*/
def exposeJavaClientMetrics(
prefix: ClientId => String,
prometheus: CollectorRegistry
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@ import scala.concurrent.duration.FiniteDuration

object ProducerMetricsOf {

/**
* Construct [[ProducerMetrics]] that will expose Java Kafka client metrics.
*
* @param source original [[ProducerMetrics]]
* @param prefix function that provides _unique_ prefix for each client
* @param prometheus instance of Prometheus registry
* @return [[ProducerMetrics]] that exposes Java Kafka client metrics
*/
def withJavaClientMetrics[F[_]: Sync: ToTry](
source: ProducerMetrics[F],
prefix: ClientId => String,
Expand Down Expand Up @@ -49,6 +57,13 @@ object ProducerMetricsOf {

implicit final class Syntax[F[_]](val source: ProducerMetrics[F]) extends AnyVal {

/**
* Construct [[ProducerMetrics]] that will expose Java Kafka client metrics.
*
* @param prefix function that provides _unique_ prefix for each client
* @param prometheus instance of Prometheus registry
* @return [[ProducerMetrics]] that exposes Java Kafka client metrics
*/
def exposeJavaClientMetrics(
prefix: ClientId => String,
prometheus: CollectorRegistry
Expand Down

0 comments on commit 1da4c59

Please sign in to comment.