Java Code Examples for io.prometheus.client.Histogram#Builder
The following examples show how to use
io.prometheus.client.Histogram#Builder .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HystrixMetricsCollector.java From prometheus-hystrix with Apache License 2.0 | 6 votes |
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(); } }
Example 2
Source File: PrometheusHistogramMetrics.java From skywalking with Apache License 2.0 | 5 votes |
@Override protected Histogram create(String[] labelNames) { Histogram.Builder builder = Histogram.build().name(name).help(tips); if (builder != null && buckets.length > 0) { builder = builder.buckets(buckets); } return builder.labelNames(labelNames).register(); }
Example 3
Source File: HystrixMetricsCollector.java From prometheus-hystrix with Apache License 2.0 | 4 votes |
public HystrixMetricsCollector(String namespace, Consumer<Histogram.Builder> histogramParameterizer) { this.namespace = namespace; this.histogramParameterizer = histogramParameterizer; }
Example 4
Source File: MetricsFilter.java From client_java with Apache License 2.0 | 4 votes |
@Override public void init(FilterConfig filterConfig) throws ServletException { Histogram.Builder builder = Histogram.build() .labelNames("path", "method"); if (filterConfig == null && isEmpty(metricName)) { throw new ServletException("No configuration object provided, and no metricName passed via constructor"); } if (filterConfig != null) { if (isEmpty(metricName)) { metricName = filterConfig.getInitParameter(METRIC_NAME_PARAM); if (isEmpty(metricName)) { throw new ServletException("Init parameter \"" + METRIC_NAME_PARAM + "\" is required; please supply a value"); } } if (!isEmpty(filterConfig.getInitParameter(HELP_PARAM))) { help = filterConfig.getInitParameter(HELP_PARAM); } // Allow overriding of the path "depth" to track if (!isEmpty(filterConfig.getInitParameter(PATH_COMPONENT_PARAM))) { pathComponents = Integer.valueOf(filterConfig.getInitParameter(PATH_COMPONENT_PARAM)); } // Allow users to override the default bucket configuration if (!isEmpty(filterConfig.getInitParameter(BUCKET_CONFIG_PARAM))) { String[] bucketParams = filterConfig.getInitParameter(BUCKET_CONFIG_PARAM).split(","); buckets = new double[bucketParams.length]; for (int i = 0; i < bucketParams.length; i++) { buckets[i] = Double.parseDouble(bucketParams[i]); } } } if (buckets != null) { builder = builder.buckets(buckets); } histogram = builder .help(help) .name(metricName) .register(); }