All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.lyranthe.prometheus.client.DefaultRegistry.scala Maven / Gradle / Ivy

There is a newer version: 0.9.0-M5
Show newest version
package org.lyranthe.prometheus.client

import org.lyranthe.prometheus.client.registry._

class DefaultRegistry extends Registry {
  @volatile private[client] var collectors: Vector[MetricFamily] = Vector.empty

  override def register(c: MetricFamily): Boolean = {
    if (collectors.forall(_.name.name != c.name.name)) {
      collectors = (collectors :+ c).sortBy(_.name.name)
      true
    } else
      false
  }

  override def collect(): Iterator[RegistryMetrics] = {
    collectors.toIterator.map { c =>
      RegistryMetrics(c.name, c.help, c.escapedHelp, c.metricType, c.collect())
    }
  }
}

object DefaultRegistry {
  def apply(): DefaultRegistry = new DefaultRegistry
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy