本文整理了Java中io.prometheus.client.Histogram.labels()
方法的一些代码示例,展示了Histogram.labels()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Histogram.labels()
方法的具体详情如下:
包路径:io.prometheus.client.Histogram
类名称:Histogram
方法名:labels
暂无
代码示例来源:origin: resilience4j/resilience4j
@Override
public Child labels(String... labels) {
return new CallMeterChildImpl(
collectors.histogram.labels(labels),
collectors.totalCounter.labels(labels),
collectors.errorCounter.labels(labels));
}
代码示例来源:origin: alibaba/canal
@Override
public void profiling(ClientRequestResult result) {
String destination = result.getDestination();
PacketType type = result.getType();
outboundCounter.labels(destination).inc(result.getAmount());
short errorCode = result.getErrorCode();
if (errorCode > 0) {
errorsCounter.labels(destination, Short.toString(errorCode)).inc();
}
long latency = result.getLatency();
responseLatency.labels(destination).observe(((double) latency) / NANO_PER_MILLI);
switch (type) {
case GET:
boolean empty = result.getEmpty();
// 区分一下空包
if (empty) {
emptyBatchesCounter.labels(destination).inc();
} else {
packetsCounter.labels(destination, type.name()).inc();
}
break;
// reserve for others
default:
packetsCounter.labels(destination, type.name()).inc();
break;
}
}
代码示例来源:origin: prometheus/client_java
@Override
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
if (!(servletRequest instanceof HttpServletRequest)) {
filterChain.doFilter(servletRequest, servletResponse);
return;
}
HttpServletRequest request = (HttpServletRequest) servletRequest;
String path = request.getRequestURI();
Histogram.Timer timer = histogram
.labels(getComponents(path), request.getMethod())
.startTimer();
try {
filterChain.doFilter(servletRequest, servletResponse);
} finally {
timer.observeDuration();
}
}
代码示例来源:origin: prometheus/client_java
@Benchmark
@BenchmarkMode({Mode.AverageTime})
@OutputTimeUnit(TimeUnit.NANOSECONDS)
public void prometheusSimpleHistogramBenchmark() {
prometheusSimpleHistogram.labels("test", "group").observe(1) ;
}
代码示例来源:origin: com.jonnymatts.prometheus/metrics-core
public Histogram.Child labels(String... labels) {
return histogram.labels(labels);
}
代码示例来源:origin: TGAC/miso-lims
public AutoCloseable start(final String... labels) {
long startTime = System.nanoTime();
return () -> histogram.labels(labels).observe((System.nanoTime() - startTime) / 1e9);
}
代码示例来源:origin: nlighten/tomcat_exporter
@Override
protected String reportQuery(String query, Object[] args, final String name, long start, long delta) {
String sql = super.reportQuery(query, args, name, start, delta);
globalQueryStats.labels(SUCCESS_QUERY_STATUS).observe((double) delta/1000);
if (slowQueryStatsEnabled && delta >= slowQueryThreshold) {
slowQueryStats.labels(sql).observe((double) delta/1000);
}
return sql;
}
代码示例来源:origin: nlighten/tomcat_exporter
@Override
protected String reportSlowQuery(String query, Object[] args, String name, long start, long delta) {
String sql = super.reportSlowQuery(query, args, name, start, delta);
globalQueryStats.labels(SUCCESS_QUERY_STATUS).observe((double) delta/1000);
if (slowQueryStatsEnabled && delta >= slowQueryThreshold) {
slowQueryStats.labels(sql).observe((double) delta/1000);
}
return sql;
}
代码示例来源: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 static <T> T withMetrics(String name, String type, Supplier<T> s) {
SimpleTimer requestTimer = new SimpleTimer();
String result = "success";
try {
return s.get();
} catch (Exception e) {
result = e.getClass().getSimpleName();
throw e;
} finally {
instance.executions.labels(result, type, name)
.observe(requestTimer.elapsedSeconds());
}
}
代码示例来源:origin: avaire/avaire
private void invokeIntent(Message message, DatabaseEventHolder databaseEventHolder, AIResponse response, Intent intent) {
Metrics.aiRequestsExecuted.labels(intent.getClass().getSimpleName()).inc();
Histogram.Timer timer = Metrics.aiExecutionTime.labels(intent.getClass().getSimpleName()).startTimer();
intent.onIntent(new CommandMessage(
null, databaseEventHolder, message
), response);
timer.observeDuration();
}
代码示例来源: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: nlighten/tomcat_exporter
@Override
protected String reportFailedQuery(String query, Object[] args, String name, long start, Throwable t) {
String sql = super.reportFailedQuery(query, args, name, start, t);
long now = System.currentTimeMillis();
long delta = now - start;
globalQueryStats.labels(FAILED_QUERY_STATUS).observe((double) delta/1000);
if (failedQueryStatsEnabled) {
failedQueryStats.labels(sql).inc();
}
return sql;
}
代码示例来源:origin: no.skatteetaten.aurora/aurora-prometheus
public void record(String method, String requestUri, int statusCode, long start) {
long duration = System.nanoTime() - start;
if (!config.shouldRecord(requestUri)) {
return;
}
String path = config.groupUrl(requestUri).orElse(normalize(requestUri, isClient));
requests.labels(
method,
String.valueOf(statusCode),
HttpStatusSeries.valueOf(statusCode).name(),
path
).observe(duration / Collector.NANOSECONDS_PER_SECOND);
}
代码示例来源:origin: nlighten/tomcat_exporter
@Override
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
if (!(servletRequest instanceof HttpServletRequest)) {
filterChain.doFilter(servletRequest, servletResponse);
return;
}
HttpServletRequest request = (HttpServletRequest) servletRequest;
if (!request.isAsyncStarted()) {
String context = getContext(request);
servletConcurrentRequest.labels(context).inc();
Histogram.Timer timer = servletLatency
.labels(context, request.getMethod())
.startTimer();
try {
filterChain.doFilter(servletRequest, servletResponse);
} finally {
timer.observeDuration();
servletConcurrentRequest.labels(context).dec();
servletStatusCodes.labels(context, Integer.toString(getStatus((HttpServletResponse) servletResponse))).inc();
}
} else {
filterChain.doFilter(servletRequest, servletResponse);
}
}
代码示例来源:origin: dabbotorg/java-music-bot
Histogram.Timer requestTimer = commandLatency.labels(shard, command.getNames()[0]).startTimer();
try {
command.on(context);
代码示例来源:origin: FlareBot/FlareBot
Histogram.Timer executionTimer = Metrics.commandExecutionTime.labels(cmd.getClass().getSimpleName()).startTimer();
cmd.onCommand(event.getAuthor(), guild, event.getChannel(), event.getMessage(), args, event
.getMember());
代码示例来源:origin: avaire/avaire
timer = Metrics.executionTime.labels(stack.getCommand().getClass().getSimpleName()).startTimer();
代码示例来源:origin: com.alibaba.otter/canal.prometheus
@Override
public void profiling(ClientRequestResult result) {
String destination = result.getDestination();
PacketType type = result.getType();
outboundCounter.labels(destination).inc(result.getAmount());
short errorCode = result.getErrorCode();
if (errorCode > 0) {
errorsCounter.labels(destination, Short.toString(errorCode)).inc();
}
long latency = result.getLatency();
responseLatency.labels(destination).observe(((double) latency) / NANO_PER_MILLI);
switch (type) {
case GET:
boolean empty = result.getEmpty();
// 区分一下空包
if (empty) {
emptyBatchesCounter.labels(destination).inc();
} else {
packetsCounter.labels(destination, type.name()).inc();
}
break;
// reserve for others
default:
packetsCounter.labels(destination, type.name()).inc();
break;
}
}
代码示例来源:origin: marcelmay/hadoop-hdfs-fsimage-exporter
.name(FsImageCollector.METRIC_PREFIX + REPLICATION)
.help("Overall file replication").create();
overallStats = new OverallStats(new HistogramMetricAdapter(overallHistogram.labels()), overallReplication);
.buckets(configuredBuckets)
.help("Per group file size distribution.").create();
createGroupStats = groupName -> new GroupStats(groupName, new HistogramMetricAdapter(histogram.labels(groupName)));
groupFileSizeDistribution = histogram;
.help("Per user file size distribution").create();
createUserStat = userName -> new UserStats(userName,
new HistogramMetricAdapter(histogram.labels(userName)),
new SummaryMetricAdapter(userReplication.labels(userName)));
userFileSizeDistribution = histogram;
.labelNames(FsImageCollector.LABEL_PATH)
.help("Path specific file size distribution").create();
createPathStat = path -> new PathStats(path, new HistogramMetricAdapter(histogram.labels(path)));
pathFileSizeDistribution = histogram;
.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;
内容来源于网络,如有侵权,请联系作者删除!