private Counter counter(String name, List<String> labels) { String key = sanitizeName(name); return counters.computeIfAbsent(key, k-> Counter.build().name(k).help(k).labelNames(labels.stream().toArray(String[]::new)).register(registry)); }
PrometheusMetricsTracker(String poolName) { super(); Counter counter = Counter.build() .name("hikaricp_connection_timeout_count") .labelNames("pool") .help("Connection timeout count") .register(); this.connectionTimeoutCounter = counter.labels(poolName); Summary elapsedAcquiredSummary = Summary.build() .name("hikaricp_connection_acquired_nanos") .labelNames("pool") .help("Connection acquired time") .register(); this.elapsedAcquiredSummary = elapsedAcquiredSummary.labels(poolName); Summary elapsedBorrowedSummary = Summary.build() .name("hikaricp_connection_usage_millis") .labelNames("pool") .help("Connection usage") .register(); this.elapsedBorrowedSummary = elapsedBorrowedSummary.labels(poolName); }
/** * Create a new instrumented appender using the default registry. */ public LogbackMetricsAppender(CollectorRegistry registry) { Counter counter = Counter.build().name("logback_appender_total") .help("Logback log statements at various log levels") .labelNames("level") .register(registry); traceLabel = counter.labels("trace"); debugLabel = counter.labels("debug"); infoLabel = counter.labels("info"); warnLabel = counter.labels("warn"); errorLabel = counter.labels("error"); }
@Setup(Level.Trial) public void setup() { counter = io.prometheus.client.Counter.build().name("counter").help("A counter").create(); counterWithTags = io.prometheus.client.Counter.build().name("counter").help("Counter with two tags declared").labelNames("key1", "key2").register(); } }