mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
#1345 - Refactor io.ebean.meta.MetaInfoManager API (query execution metrics). Breaking change for people collecting query execution metrics.
This commit is contained in:
@@ -1,30 +1,38 @@
|
||||
package io.ebeaninternal.server.profile;
|
||||
|
||||
import io.ebean.meta.MetaTimedMetric;
|
||||
import io.ebean.meta.MetricType;
|
||||
import io.ebean.meta.MetricVisitor;
|
||||
import io.ebeaninternal.metric.TimedMetricMap;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
class DTimedMetricMap implements TimedMetricMap {
|
||||
|
||||
private final MetricType metricType;
|
||||
|
||||
private final String name;
|
||||
|
||||
private final ConcurrentHashMap<String, DTimedMetric> map = new ConcurrentHashMap<>();
|
||||
|
||||
DTimedMetricMap(String name) {
|
||||
DTimedMetricMap(MetricType metricType, String name) {
|
||||
this.metricType = metricType;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void add(String key, long exeMicros) {
|
||||
map.computeIfAbsent(key, (k)-> new DTimedMetric(name + key)).add(exeMicros);
|
||||
map.computeIfAbsent(key, (k) -> new DTimedMetric(metricType, name + key)).add(exeMicros);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void collect(boolean reset, List<MetaTimedMetric> list) {
|
||||
public void add(String key, long exeMicros, int rows) {
|
||||
map.computeIfAbsent(key, (k) -> new DTimedMetric(metricType, name + key)).add(exeMicros, rows);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(MetricVisitor visitor) {
|
||||
for (DTimedMetric value : map.values()) {
|
||||
value.collect(reset, list);
|
||||
value.visit(visitor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user