ENH: Add ProfileLocation - Part 2 - performance metrics for transactions with label and profileLocation

This commit is contained in:
Rob Bygrave committed 2018-01-22 14:54:27 +13:00
1 parent 4e33027fdf
commit 51d2e4c600
37 files changed
+779 -33

No files matched your search

@@ -0,0 +1,25 @@
package io.ebeaninternal.metric;
/**
* Factory to create timed metric counters.
*/
public interface MetricFactory {
/**
* Return the factory instance.
*/
static MetricFactory get() {
return MetricServiceProvider.get();
}
/**
* Create a timed metric group.
*/
TimedMetricMap createTimedMetricMap(String name);
/**
* Create a Timed metric.
*/
TimedMetric createTimedMetric(String name);
}
@@ -0,0 +1,31 @@
package io.ebeaninternal.metric;
import io.ebeaninternal.server.profile.DMetricFactory;
import java.util.Iterator;
import java.util.ServiceLoader;
/**
* Lookup MetricFactory service.
*/
class MetricServiceProvider {
private static MetricFactory metricFactory = init();
private static MetricFactory init() {
Iterator<MetricFactory> loader = ServiceLoader.load(MetricFactory.class).iterator();
if (loader.hasNext()) {
return loader.next();
}
return new DMetricFactory();
}
/**
* Return the MetricFactory implementation.
*/
static MetricFactory get() {
return metricFactory;
}
}
@@ -0,0 +1,31 @@
package io.ebeaninternal.metric;
import io.ebean.meta.MetaTimedMetric;
import java.util.List;
/**
* Metric for timed events like transaction execution times.
*/
public interface TimedMetric {
/**
* Add a time event (usually in microseconds).
*/
void add(long value);
/**
* Return true if there are no metrics collected since the last collection.
*/
boolean isEmpty();
/**
* Collect the timed metric statistics.
*/
TimedMetricStats collect(boolean reset);
/**
* Add non empty metrics to the result.
*/
void collect(boolean reset, List<MetaTimedMetric> result);
}
@@ -0,0 +1,21 @@
package io.ebeaninternal.metric;
import io.ebean.meta.MetaTimedMetric;
import java.util.List;
/**
* A map of timed metrics keyed by a string.
*/
public interface TimedMetricMap {
/**
* Add an execution for the given key.
*/
void add(String key, long exeMicros);
/**
* Add non empty metrics to the given result.
*/
void collect(boolean reset, List<MetaTimedMetric> result);
}
@@ -0,0 +1,14 @@
package io.ebeaninternal.metric;
import io.ebean.meta.MetaTimedMetric;
/**
* Extend public MetaTimedMetric with ability to set details from profile location.
*/
public interface TimedMetricStats extends MetaTimedMetric {
/**
* Additionally set the location.
*/
void setLocation(String location);
}