@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(); } }
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); }
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(); }
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(); } }