@Override public void init(FilterConfig filterConfig) throws ServletException { Histogram.Builder builder = Histogram.build() .labelNames("path", "method");
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(); }
Histogram histogram = Histogram.build() .name(FsImageCollector.METRIC_PREFIX_GROUP + FSIZE) .labelNames(FsImageCollector.LABEL_GROUP_NAME) .buckets(configuredBuckets) .help("Per group file size distribution.").create(); Histogram histogram = Histogram.build() .name(FsImageCollector.METRIC_PREFIX_USER + FSIZE) .labelNames(FsImageCollector.LABEL_USER_NAME) .buckets(configuredBuckets) .help("Per user file size distribution").create(); .name(FsImageCollector.METRIC_PREFIX_PATH + FSIZE) .buckets(configuredBuckets) .labelNames(FsImageCollector.LABEL_PATH) .help("Path specific file size distribution").create(); createPathStat = path -> new PathStats(path, new HistogramMetricAdapter(histogram.labels(path))); .name(FsImageCollector.METRIC_PREFIX_PATH_SET + FSIZE) .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)));
.name("tomcat_jdbc_query_seconds") .buckets(buckets) .labelNames("status"); globalQueryStats = builder.register(); .name("tomcat_jdbc_slowquery_seconds") .buckets(slowQueryBuckets) .labelNames("query"); slowQueryStats = builder.register();
@Override public void init(FilterConfig filterConfig) throws ServletException { if (servletLatency == null) { Histogram.Builder servletLatencyBuilder = Histogram.build() .name("servlet_request_seconds") .help("The time taken fulfilling servlet requests") .labelNames("context", "method"); if ((filterConfig.getInitParameter(BUCKET_CONFIG_PARAM) != null) && (!filterConfig.getInitParameter(BUCKET_CONFIG_PARAM).isEmpty())) { String[] bucketParams = filterConfig.getInitParameter(BUCKET_CONFIG_PARAM).split(","); double[] buckets = new double[bucketParams.length]; for (int i = 0; i < bucketParams.length; i++) { buckets[i] = Double.parseDouble(bucketParams[i].trim()); } servletLatencyBuilder.buckets(buckets); } else { servletLatencyBuilder.buckets(.01, .05, .1, .25, .5, 1, 2.5, 5, 10, 30); } servletLatency = servletLatencyBuilder.register(); Gauge.Builder servletConcurrentRequestBuilder = Gauge.build() .name("servlet_request_concurrent_total") .help("Number of concurrent requests for given context.") .labelNames("context"); servletConcurrentRequest = servletConcurrentRequestBuilder.register(); Gauge.Builder servletStatusCodesBuilder = Gauge.build() .name("servlet_response_status_total") .help("Number of requests for given context and status code.") .labelNames("context", "status"); servletStatusCodes = servletStatusCodesBuilder.register(); } }
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 LatencyHistogram(String name, String help, String... labels) { histogram = Histogram.build().buckets(1, 5, 10, 30, 60, 300, 600, 3600) .name(name).help(help).labelNames(labels).register(); }
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); } }
@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"); }
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(); }