public PrometheusQmqTimer(final Summary summary, final String[] labels) { this.summary = summary.labels(labels); }
public PrometheusQmqMeter(final Summary summary, final String[] labels) { this.summary = summary.labels(labels); }
PrometheusMetricsTracker(String poolName, CollectorRegistry collectorRegistry) { registerMetrics(collectorRegistry); this.connectionTimeoutCounterChild = CONNECTION_TIMEOUT_COUNTER.labels(poolName); this.elapsedAcquiredSummaryChild = ELAPSED_ACQUIRED_SUMMARY.labels(poolName); this.elapsedBorrowedSummaryChild = ELAPSED_BORROWED_SUMMARY.labels(poolName); this.elapsedCreationSummaryChild = ELAPSED_CREATION_SUMMARY.labels(poolName); }
@Override public void handleRequest(final HttpServerExchange exchange) throws Exception { SimpleTimer respTimer = new SimpleTimer(); exchange.addExchangeCompleteListener((exchange1, nextListener) -> { Map<String, Object> auditInfo = exchange1.getAttachment(AuditHandler.AUDIT_INFO); if(auditInfo != null) { Map<String, String> tags = new HashMap<>(); tags.put("endpoint", (String)auditInfo.get(Constants.ENDPOINT_STRING)); tags.put("clientId", auditInfo.get(Constants.CLIENT_ID_STRING) != null ? (String)auditInfo.get(Constants.CLIENT_ID_STRING) : "unknown"); List<String> labels = new ArrayList<>(tags.keySet()); List<String> labelValues = new ArrayList<>(tags.values()); summary(RERSPONSE_TIME_SECOND, labels).labels(labelValues.stream().toArray(String[]::new)).observe(respTimer.elapsedSeconds()); incCounterForStatusCode(exchange1.getStatusCode(), labels, labelValues); } nextListener.proceed(); }); Handler.next(exchange, next); }
@Benchmark @BenchmarkMode({Mode.AverageTime}) @OutputTimeUnit(TimeUnit.NANOSECONDS) public void prometheusSimpleSummaryBenchmark() { prometheusSimpleSummary.labels("test", "group").observe(1) ; }
public Summary.Child labels(String... labels) { return summary.labels(labels); }
@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"); }
@Around("processRequest()") public void timedProcessRequest(ProceedingJoinPoint joinPoint) throws Throwable { joinPoint.proceed(); Request request = (Request) joinPoint.getArgs()[0]; String type = requestTypeMap.getOrDefault(request.type, "unknown"); requests.labels(type).inc(); long latencyMs = System.currentTimeMillis() - request.createTime; String latencyLabel = isWriteRequest(request.type) ? "write" : "read"; requestsLatency.labels(latencyLabel).observe(latencyMs); }
@Around("processRequest()") public void timedProcessRequest(ProceedingJoinPoint joinPoint) throws Throwable { joinPoint.proceed(); Request request = (Request) joinPoint.getArgs()[0]; String type = requestTypeMap.getOrDefault(request.type, "unknown"); requests.labels(type).inc(); long latencyMs = Time.currentElapsedTime() - request.createTime; String latencyLabel = isWriteRequest(request.type) ? "write" : "read"; requestsLatency.labels(latencyLabel).observe(latencyMs); }
protected void doRequestDuration(RequestMetric metric) { requestDuration.labels(nullToEmpty(metric.getMethod(), Integer.toString(metric.getResponseCode()), metric.getApiId(), metric.getApiVersion(), metric.getClientId())).observe(metric.getRequestDuration()); }
protected void doRequestDuration(RequestMetric metric) { requestDuration.labels(nullToEmpty(metric.getMethod(), Integer.toString(metric.getResponseCode()), metric.getApiId(), metric.getApiVersion(), metric.getClientId())).observe(metric.getRequestDuration()); }
samplerCollector.labels(samplerLabelValues).observe(event.getResult().getTime()); samplerElaspedTimeCollector.labels(samplerLabelValues).observe(event.getResult().getTime() / 1000.0); samplerLatencyCollector.labels(samplerLabelValues).observe(event.getResult().getLatency() / 1000.0); samplerIdleTimeCollector.labels(samplerLabelValues).observe(event.getResult().getIdleTime() / 1000.0); samplerConnectTimeCollector.labels(samplerLabelValues).observe(event.getResult().getConnectTime() / 1000.0); ((Summary) assertionsCollector).labels(assertionsLabelValues).observe(event.getResult().getTime()); else if (assertionsCollector instanceof Counter) ((Counter) assertionsCollector).labels(assertionsLabelValues).inc();
PrometheusMetricsTracker(String poolName) { super(); Counter counter = Counter.build() .name("hikaricp_connection_timeout_count") .labelNames("pool") .help("Connection timeout count") .register(); this.connectionTimeoutCounter = counter.labels(poolName); Summary elapsedAcquiredSummary = Summary.build() .name("hikaricp_connection_acquired_nanos") .labelNames("pool") .help("Connection acquired time") .register(); this.elapsedAcquiredSummary = elapsedAcquiredSummary.labels(poolName); Summary elapsedBorrowedSummary = Summary.build() .name("hikaricp_connection_usage_millis") .labelNames("pool") .help("Connection usage") .register(); this.elapsedBorrowedSummary = elapsedBorrowedSummary.labels(poolName); }
.labelNames(FsImageCollector.LABEL_GROUP_NAME) .help("Per group file size and file count").create(); createGroupStats = groupName -> new GroupStats(groupName, new SummaryMetricAdapter(summary.labels(groupName))); groupFileSizeDistribution = summary; } else { .help("Per user file size and file count").create(); createUserStat = userName -> new UserStats(userName, new SummaryMetricAdapter(summary.labels(userName)), new SummaryMetricAdapter(userReplication.labels(userName))); userFileSizeDistribution = summary; } else { 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 and file count").create(); createPathStat = path -> new PathStats(path, new SummaryMetricAdapter(summary.labels(path))); pathFileSizeDistribution = summary; } else { .labelNames(FsImageCollector.LABEL_PATH_SET) .help("Path set specific file size and file count").create(); createPathSetStat = path -> new PathStats(path, new SummaryMetricAdapter(summary.labels(path))); pathSetFileSizeDistribution = summary; } else {