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

Name Type Meaning
connection-pool-total-count Gauge Total number of connections in the pool of HTTP stack
connection-pool-idle-count Gauge Number of idle connections in the pool of HTTP stack
requests-total Meter Number of total requests for that endpoint
requests-success Meter Number of successful requests for that endpoint
requests-failure Meter Number of failed requests for that endpoint
requests-in-flight-count Counter Number of in-flight requests for that endpoint
requests-time Timer Duration of the specific request

Functions to Retrieve Metrics

Scala
Java
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

Scala
Java
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()));

results matching ""

    No results matching ""