All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.clickhouse.client.api.metrics.OperationMetrics Maven / Gradle / Ivy

There is a newer version: 0.7.0
Show newest version
package com.clickhouse.client.api.metrics;

import com.clickhouse.client.ClickHouseResponseSummary;
import com.clickhouse.client.api.internal.ClientStatisticsHolder;
import com.clickhouse.client.api.internal.Gauge;
import com.clickhouse.client.api.internal.StopWatch;

import java.util.HashMap;
import java.util.Map;

/**
 * OperationStatistics objects hold various stats for complete operations.
 * 

* It can be used for logging or monitoring purposes. */ public class OperationMetrics { public Map metrics = new HashMap<>(); private String queryId; private final ClientStatisticsHolder clientStatistics; public OperationMetrics(ClientStatisticsHolder clientStatisticsHolder) { this.clientStatistics = clientStatisticsHolder; } public Metric getMetric(ServerMetrics metric) { return metrics.get(metric.getKey()); } public Metric getMetric(ClientMetrics metric) { return metrics.get(metric.getKey()); } public String getQueryId() { return queryId; } public void operationComplete() { for (Map.Entry sw : clientStatistics.getStopWatches().entrySet()) { sw.getValue().stop(); metrics.put(sw.getKey(), sw.getValue()); } } public void updateMetric(ServerMetrics metric, long value) { metrics.put(metric.getKey(), new Gauge(value)); } public void setQueryId(String queryId) { this.queryId = queryId; } @Override public String toString() { return "OperationStatistics{" + "\"queryId\"=\"" + queryId + "\", " + "\"metrics\"=" + metrics + '}'; } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy