io.prometheus.client.Histogram.build()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(9.4k)|赞(0)|评价(0)|浏览(169)

本文整理了Java中io.prometheus.client.Histogram.build()方法的一些代码示例,展示了Histogram.build()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Histogram.build()方法的具体详情如下:
包路径:io.prometheus.client.Histogram
类名称:Histogram
方法名:build

Histogram.build介绍

[英]Return a Builder to allow configuration of a new Histogram.
[中]返回生成器以允许配置新直方图。

代码示例

代码示例来源:origin: micrometer-metrics/micrometer

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

代码示例来源:origin: alibaba/canal

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

代码示例来源:origin: resilience4j/resilience4j

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

代码示例来源:origin: prometheus/client_java

@Override
public void init(FilterConfig filterConfig) throws ServletException {
  Histogram.Builder builder = Histogram.build()
      .labelNames("path", "method");

代码示例来源:origin: com.jonnymatts.prometheus/metrics-core

public PrometheusHistogram(HistogramConfiguration configuration) {
  this(Histogram.build(), configuration);
}

代码示例来源:origin: prometheus/client_java

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

代码示例来源:origin: no.skatteetaten.aurora/aurora-prometheus

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

代码示例来源:origin: ahus1/prometheus-hystrix

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

代码示例来源:origin: no.skatteetaten.aurora/aurora-prometheus

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");
}

代码示例来源:origin: no.skatteetaten.aurora/aurora-prometheus

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

代码示例来源:origin: TGAC/miso-lims

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

代码示例来源:origin: nlighten/tomcat_exporter

Histogram.Builder builder = Histogram.build()
    .help("JDBC query duration")
    .name("tomcat_jdbc_query_seconds")
slowQueryStatsEnabled = true;
if (slowQueryStats == null) {
  Histogram.Builder builder = Histogram.build()
      .help("JDBC slow query duration in seconds")
      .name("tomcat_jdbc_slowquery_seconds")

代码示例来源:origin: nlighten/tomcat_exporter

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

代码示例来源:origin: marcelmay/hadoop-hdfs-fsimage-exporter

Histogram overallHistogram = Histogram.build()
    .name(METRIC_PREFIX + FSIZE)
    .buckets(configuredBuckets)
  groupFileSizeDistribution = summary;
} else {
  Histogram histogram = Histogram.build()
      .name(FsImageCollector.METRIC_PREFIX_GROUP + FSIZE)
      .labelNames(FsImageCollector.LABEL_GROUP_NAME)
  userFileSizeDistribution = summary;
} else {
  Histogram histogram = Histogram.build()
      .name(FsImageCollector.METRIC_PREFIX_USER + FSIZE)
      .labelNames(FsImageCollector.LABEL_USER_NAME)
  pathFileSizeDistribution = summary;
} else {
  Histogram histogram = Histogram.build()
      .name(FsImageCollector.METRIC_PREFIX_PATH + FSIZE)
      .buckets(configuredBuckets)
  pathSetFileSizeDistribution = summary;
} else {
  Histogram histogram = Histogram.build()
      .name(FsImageCollector.METRIC_PREFIX_PATH_SET + FSIZE)
      .buckets(configuredBuckets)

代码示例来源:origin: com.alibaba.otter/canal.prometheus

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

相关文章