-
Notifications
You must be signed in to change notification settings - Fork 534
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1675 from ClickHouse/feat_generic_metrics
Refactored metrics to make them more generic
- Loading branch information
Showing
15 changed files
with
382 additions
and
215 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
156 changes: 0 additions & 156 deletions
156
client-v2/src/main/java/com/clickhouse/client/api/OperationStatistics.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
client-v2/src/main/java/com/clickhouse/client/api/internal/ClientStatisticsHolder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package com.clickhouse.client.api.internal; | ||
|
||
import com.clickhouse.client.api.metrics.ClientMetrics; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
public class ClientStatisticsHolder { | ||
|
||
private final Map<String, StopWatch> stopWatches = new HashMap<>(); | ||
|
||
public void start(ClientMetrics metric) { | ||
start(metric.getKey()); | ||
} | ||
|
||
public void start(String spanName) { | ||
stopWatches.computeIfAbsent(spanName, k -> new StopWatch()).start(); | ||
} | ||
|
||
public StopWatch stop(ClientMetrics metric) { | ||
return stop(metric.getKey()); | ||
} | ||
|
||
public StopWatch stop(String spanName) { | ||
StopWatch timer = stopWatches.computeIfAbsent(spanName, k -> new StopWatch()); | ||
timer.stop(); | ||
return timer; | ||
} | ||
|
||
public long getElapsedTime(String spanName) { | ||
StopWatch sw = stopWatches.get(spanName); | ||
return sw == null ? -1 : sw.getElapsedTime(); | ||
} | ||
|
||
public Map<String, StopWatch> getStopWatches() { | ||
return stopWatches; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "ClientStatistics{" + | ||
"\"spans\"=" + stopWatches + | ||
'}'; | ||
} | ||
} |
Oops, something went wrong.