Skip to content

Commit

Permalink
Update docs and scalafmt
Browse files Browse the repository at this point in the history
  • Loading branch information
janstenpickle committed Aug 2, 2023
1 parent 3d3d4d7 commit dc5583c
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 8 deletions.
2 changes: 1 addition & 1 deletion core/src/main/scala/prometheus4cats/MetricFactory.scala
Original file line number Diff line number Diff line change
Expand Up @@ -753,7 +753,7 @@ object MetricFactory {
/** Build a [[MetricFactory]] from an existing [[MetricFactory]] and [[CallbackRegistry]]
*
* @param metricFactory
* [[MetricFactory]] from which to obtain a [[MetricRegistry.WithExemplars]]
* [[MetricFactory]] from which to obtain a [[MetricRegistry]]
* @param callbackRegistry
* [[CallbackRegistry]] with which to register new metrics created by the built [[MetricFactory]]
* @return
Expand Down
2 changes: 1 addition & 1 deletion docs/interface/metric-factory.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import prometheus4cats._

val metricRegistry: MetricRegistry.WithExemplers[IO] = MetricRegistry.WithExemplers.noop[IO]
val callbackRegistry: CallbackRegistry[IO] = CallbackRegistry.noop[IO]
val registry: MetricRegistry.WithExemplars[IO] with CallbackRegistry[IO] = null
val registry: MetricRegistry[IO] with CallbackRegistry[IO] = null
```

### `MetricFactory.` or `MetricFactory.WithCallbacks`
Expand Down
6 changes: 3 additions & 3 deletions docs/interface/metric-registry.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
## Metric Registry

The `MetricRegistry.WithExemplars` is an interface that may be implemented by different backends to provide concurrent
The `MetricRegistry` is an interface that may be implemented by different backends to provide concurrent
access to metrics. This is not designed for use by users of the API directly, they should use it with the
[`MetricFactory.WithExemplars`] to create metrics using the [DSL](../interface/dsl.md).
[`MetricFactory`] to create metrics using the [DSL](../interface/dsl.md).

### Development Notes

All methods on `MetricRegistry.WithExemplars` return the desired [primitive metric] contained in a Cats-Effect
All methods on `MetricRegistry` return the desired [primitive metric] contained in a Cats-Effect
`Resource`. This should be used to register and un-register the metric with the underlying concurrent data structure.
It should be possible to allow the same metric to be requested multiple times without re-registering or throwing a
runtime exception; therefore we recommend implementing some form of reference counting to track claims on each metric.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,19 @@ import cats.effect.std.{Dispatcher, Semaphore}
import cats.syntax.all._
import cats.{Applicative, ApplicativeThrow, Functor, Monad, Show}
import io.prometheus.client.Collector.MetricFamilySamples
import io.prometheus.client.{Collector, CollectorRegistry, CounterMetricFamily, GaugeMetricFamily, SimpleCollector, SummaryMetricFamily, Counter => PCounter, Gauge => PGauge, Histogram => PHistogram, Info => PInfo, Summary => PSummary}
import io.prometheus.client.{
Collector,
CollectorRegistry,
CounterMetricFamily,
GaugeMetricFamily,
SimpleCollector,
SummaryMetricFamily,
Counter => PCounter,
Gauge => PGauge,
Histogram => PHistogram,
Info => PInfo,
Summary => PSummary
}
import org.typelevel.log4cats.Logger
import prometheus4cats._
import prometheus4cats.javasimpleclient.internal.{HistogramUtils, MetricCollectionProcessor, Utils}
Expand Down Expand Up @@ -886,7 +898,7 @@ class JavaMetricRegistry[F[_]: Async: Logger: Exemplar] private (
val commonLabelValues = commonLabels.value.values.toIndexedSeq

configureBuilderOrRetrieve(
PCounter.build(),
PCounter.build().withExemplars(),
MetricType.Counter,
prefix,
name,
Expand Down Expand Up @@ -949,7 +961,7 @@ class JavaMetricRegistry[F[_]: Async: Logger: Exemplar] private (
val commonLabelValues = commonLabels.value.values.toIndexedSeq

configureBuilderOrRetrieve(
PHistogram.build().buckets(buckets.toSeq: _*),
PHistogram.build().withExemplars().buckets(buckets.toSeq: _*),
MetricType.Histogram,
prefix,
name,
Expand Down

0 comments on commit dc5583c

Please sign in to comment.