GuidesPipeline API ReferenceChangelog
Guides

Data Client Base Library metrics and counters

Data Client Base Library metrics and counters

All endpoints of all APIs covered by Data Client Base Library provide a set of counters that can be used to gather some metrics.

We use metrics4-scala to collect these metrics. You can check the meaning of the different metrics types there.

Built-in metrics

NameTypeMeaning
connection-pool-total-countGaugeTotal number of connections in the pool of HTTP stack
connection-pool-idle-countGaugeNumber of idle connections in the pool of HTTP stack
requests-totalMeterNumber of total requests for that endpoint
requests-successMeterNumber of successful requests for that endpoint
requests-failureMeterNumber of failed requests for that endpoint
requests-in-flight-countCounterNumber of in-flight requests for that endpoint
requests-timeTimerDuration of the specific request

Functions to retrieve metrics

trait MetricsScala {
  def counter: Option[Counter]
  def meter: Option[Meter]
  def timer: Option[Timer]
  def gauge: Option[Gauge]
  def histogram: Option[Histogram] // note: we don't use histograms yet
}
trait MetricsJava {
  def getCounter: Optional[Counter]
  def getMeter: Optional[Meter]
  def getTimer: Optional[Timer]
  def getGauge: Optional[Gauge]
  def getHistogram: Optional[Histogram] // note: we don't use histograms yet
}

Example

BaseClientMetricsScala()
  .getMetricsFor("ConfigApi.getCatalogs")
  .flatMap(_.counter)
  .foreach(c => println(c.count))
new BaseClientMetricsJava.builder()
    .getInstance()
    .getMetricsFor("ConfigApi.getCatalogs")
    .flatMap(MetricsJava::getCounter)
    .ifPresent(c -> System.out.println(c.count()));