public Histogram.Child addHistogram(String subsystem, String metric, String helpDoc, SortedMap<String, String> labels) { lock.writeLock().lock(); try { String name = name(subsystem, metric); Histogram histogram = histograms.get(name); if (histogram == null) { Histogram.Builder histogramBuilder = Histogram.build().name(name).help(helpDoc) .labelNames(labels.keySet().toArray(new String[]{})); histogramParameterizer.accept(histogramBuilder); histogram = histogramBuilder.create(); histogram.register(registry); histograms.put(name, histogram); } return histogram.labels(labels.values().toArray(new String[]{})); } finally { lock.writeLock().unlock(); } }
public HttpMetricsCollector(boolean isClient, HttpMetricsCollectorConfig config) { this.isClient = isClient; this.config = config; requests = Histogram.build() .name(String.format("http_%s_requests", isClient ? "client" : "server")) .help(String.format("Http %s requests", isClient ? "client" : "server")) .labelNames("http_method", "http_status", "http_status_group", "path") .create(); }
@Setup public void setup() { prometheusSummary = io.prometheus.client.metrics.Summary.newBuilder() .name("name") .documentation("some description..") .build(); prometheusSummaryChild = prometheusSummary.newPartial().apply(); prometheusSimpleSummary = io.prometheus.client.Summary.build() .name("name") .help("some description..") .labelNames("some", "group").create(); prometheusSimpleSummaryChild = prometheusSimpleSummary.labels("test", "group"); prometheusSimpleSummaryNoLabels = io.prometheus.client.Summary.build() .name("name") .help("some description..") .create(); prometheusSimpleHistogram = io.prometheus.client.Histogram.build() .name("name") .help("some description..") .labelNames("some", "group").create(); prometheusSimpleHistogramChild = prometheusSimpleHistogram.labels("test", "group"); prometheusSimpleHistogramNoLabels = io.prometheus.client.Histogram.build() .name("name") .help("some description..") .create(); registry = new MetricRegistry(); codahaleHistogram = registry.histogram("name"); }
.buckets(configuredBuckets) .help("Overall file size distribution") .create(); overallFleSizeDistribution = overallHistogram; overallReplication = Summary.build() .labelNames(FsImageCollector.LABEL_GROUP_NAME) .buckets(configuredBuckets) .help("Per group file size distribution.").create(); createGroupStats = groupName -> new GroupStats(groupName, new HistogramMetricAdapter(histogram.labels(groupName))); groupFileSizeDistribution = histogram; .labelNames(FsImageCollector.LABEL_USER_NAME) .buckets(configuredBuckets) .help("Per user file size distribution").create(); createUserStat = userName -> new UserStats(userName, new HistogramMetricAdapter(histogram.labels(userName)), .buckets(configuredBuckets) .labelNames(FsImageCollector.LABEL_PATH) .help("Path specific file size distribution").create(); createPathStat = path -> new PathStats(path, new HistogramMetricAdapter(histogram.labels(path))); pathFileSizeDistribution = histogram; .buckets(configuredBuckets) .labelNames(FsImageCollector.LABEL_PATH_SET) .help("Path set specific file size distribution").create(); createPathSetStat = path -> new PathStats(path, new HistogramMetricAdapter(histogram.labels(path))); pathSetFileSizeDistribution = histogram;
public PrometheusHistogram(Histogram.Builder builder, HistogramConfiguration configuration) { builder.name(configuration.getName()) .help(configuration.getDescription()) .labelNames(configuration.getLabels()); final List<Double> configurationBuckets = configuration.getBuckets(); if(configurationBuckets != null) { configureBucketsForBuilder(builder, configurationBuckets); } final ExponentialBucketConfiguration exponentialBucketConfiguration = configuration.getExponentialBuckets(); if(exponentialBucketConfiguration != null) { builder.exponentialBuckets( exponentialBucketConfiguration.getStart(), exponentialBucketConfiguration.getFactor(), exponentialBucketConfiguration.getCount() ); } final LinearBucketConfiguration linearBucketConfiguration = configuration.getLinearBuckets(); if(linearBucketConfiguration != null) { builder.linearBuckets( linearBucketConfiguration.getStart(), linearBucketConfiguration.getWidth(), linearBucketConfiguration.getCount() ); } this.histogram = builder .create(); }
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 Operation() { executions = Histogram.build() .name("operations") .help("Manual operation that we want statistics on") .labelNames("result", "type", "name") .create(); logger.debug("operations histogram registered"); }
public JvmGcMetrics() { histogram = Histogram.build().name("jvm_gc_hist").help("garbage collection metrics as a histogram") .labelNames(new String[] { KEY_NAME, KEY_CAUSE, KEY_ACTION }).create(); for (GarbageCollectorMXBean gcbean : ManagementFactory.getGarbageCollectorMXBeans()) { final NotificationEmitter emitter = (NotificationEmitter) gcbean; emitter.addNotificationListener(gcListener, null, null); } }
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); } }
@Setup(Level.Trial) public void setup() { double[] micrometerBuckets = Doubles.toArray(PercentileHistogramBuckets.buckets( DistributionStatisticConfig.builder().minimumExpectedValue(0L).maximumExpectedValue(Long.MAX_VALUE) .percentilesHistogram(true).build())); histogram = io.prometheus.client.Histogram.build("histogram", "A histogram") .buckets(micrometerBuckets).create(); }
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(); }