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)); }
@Setup public void setup() { prometheusCounter = io.prometheus.client.metrics.Counter.newBuilder() .name("name") .documentation("some description..") .build(); prometheusCounterChild = prometheusCounter.newPartial().apply(); prometheusSimpleCounter = io.prometheus.client.Counter.build() .name("name") .help("some description..") .labelNames("some", "group").create(); prometheusSimpleCounterChild = prometheusSimpleCounter.labels("test", "group"); prometheusSimpleCounterNoLabels = io.prometheus.client.Counter.build() .name("name") .help("some description..") .create(); registry = new MetricRegistry(); codahaleCounter = registry.counter("counter"); codahaleMeter = registry.meter("meter"); }
public Counter.Child addCounter(String subsystem, String metric, String helpDoc, SortedMap<String, String> labels) { lock.writeLock().lock(); try { String name = name(subsystem, metric); Counter counter = counters.get(name); if (counter == null) { counter = Counter.build().name(name(subsystem, metric)).help(helpDoc). labelNames(labels.keySet().toArray(new String[]{})).create(); counter.register(registry); counters.put(name, counter); } return counter.labels(labels.values().toArray(new String[]{})); } finally { lock.writeLock().unlock(); } }
private PrometheusClientInstanceProfiler() { this.outboundCounter = Counter.build() .labelNames(DEST_LABELS) .name(OUTBOUND_BYTES) .help("Total bytes sent to client.") .create(); this.packetsCounter = Counter.build() .labelNames(new String[]{DEST, "packetType"}) .name(PACKET_TYPE) .help("Total packets sent to client.") .create(); this.emptyBatchesCounter = Counter.build() .labelNames(DEST_LABELS) .name(EMPTY_BATCHES) .help("Total empty batches sent to client.") .create(); this.errorsCounter = Counter.build() .labelNames(new String[]{DEST, "errorCode"}) .name(ERRORS) .help("Total client request errors.") .create(); this.responseLatency = Histogram.build() .labelNames(DEST_LABELS) .name(LATENCY) .help("Client request latency.") // buckets in milliseconds .buckets(2.5, 10.0, 25.0, 100.0) .create(); }
protected void createAssertionCollector(){ if (!collectAssertions){ return; } String[] labelNames = new String[]{}; if (SampleEvent.getVarCount() > 0) { labelNames = this.combineAssertionLabelsWithSampleVars(); }else { labelNames = this.assertionConfig.getLabels(); } if(this.getSaveConfig().getAssertionClass().equals(Summary.class)) this.assertionsCollector = Summary.build().name("jmeter_assertions_total").help("Counter for assertions") .labelNames(labelNames).quantile(0.5, 0.1).quantile(0.99, 0.1) .create().register(CollectorRegistry.defaultRegistry); else if(this.getSaveConfig().getAssertionClass().equals(Counter.class)) this.assertionsCollector = Counter.build().name("jmeter_assertions_total").help("Counter for assertions") .labelNames(labelNames).create().register(CollectorRegistry.defaultRegistry); }
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"); }
public PrometheusCounter(String name, String description, String... labels) { this.counter = Counter.build() .name(name) .help(description) .labelNames(labels) .create(); }
private CallCollectors createMetrics() { final Counter totalCounter = Counter .build() .namespace(namespace) .subsystem(subsystem) .name(name + "_total") .help(help + " total") .labelNames(labelNames) .create(); final Counter errorCounter = Counter .build() .namespace(namespace) .subsystem(subsystem) .name(name + "_failures_total") .help(help + " failures total") .labelNames(labelNames) .create(); final Histogram histogram = Histogram .build() .namespace(namespace) .subsystem(subsystem) .name(name + "_latency") .help(help + " latency") .labelNames(labelNames) .create(); return new CallCollectors(histogram, totalCounter, errorCounter); } }
private PrometheusClientInstanceProfiler() { this.outboundCounter = Counter.build() .labelNames(DEST_LABELS) .name(OUTBOUND_BYTES) .help("Total bytes sent to client.") .create(); this.packetsCounter = Counter.build() .labelNames(new String[]{DEST, "packetType"}) .name(PACKET_TYPE) .help("Total packets sent to client.") .create(); this.emptyBatchesCounter = Counter.build() .labelNames(DEST_LABELS) .name(EMPTY_BATCHES) .help("Total empty batches sent to client.") .create(); this.errorsCounter = Counter.build() .labelNames(new String[]{DEST, "errorCode"}) .name(ERRORS) .help("Total client request errors.") .create(); this.responseLatency = Histogram.build() .labelNames(DEST_LABELS) .name(LATENCY) .help("Client request latency.") // buckets in milliseconds .buckets(2.5, 10.0, 25.0, 100.0) .create(); }
@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(); } }