mirror of
https://github.com/nosqlbench/nosqlbench.git
synced 2025-02-25 18:55:28 -06:00
base exception metrics on name only
This commit is contained in:
parent
fed7a9e173
commit
d905c35254
@ -80,10 +80,10 @@ public class NBCycleErrorHandler implements CycleErrorHandler<Throwable, ErrorSt
|
||||
case retry:
|
||||
retry = true;
|
||||
case histogram:
|
||||
exceptionHistoMetrics.update(error,cce.getDurationNanos());
|
||||
exceptionHistoMetrics.update(error.getClass().getSimpleName(),cce.getDurationNanos());
|
||||
case count:
|
||||
case counter:
|
||||
exceptionCountMetrics.count(error);
|
||||
exceptionCountMetrics.count(error.getClass().getSimpleName());
|
||||
case ignore:
|
||||
default:
|
||||
break;
|
||||
|
@ -80,10 +80,10 @@ public class NBCycleErrorHandler implements CycleErrorHandler<Throwable, ErrorSt
|
||||
case retry:
|
||||
retry = true;
|
||||
case histogram:
|
||||
exceptionHistoMetrics.update(error,cce.getDurationNanos());
|
||||
exceptionHistoMetrics.update(error.getClass().getSimpleName(),cce.getDurationNanos());
|
||||
case count:
|
||||
case counter:
|
||||
exceptionCountMetrics.count(error);
|
||||
exceptionCountMetrics.count(error.getClass().getSimpleName());
|
||||
case ignore:
|
||||
default:
|
||||
break;
|
||||
|
@ -59,7 +59,7 @@ public class GraphErrorHandler {
|
||||
case retry:
|
||||
retry = true;
|
||||
case count:
|
||||
exceptionMeterMetrics.mark(realerror);
|
||||
exceptionMeterMetrics.mark(realerror.getClass().getSimpleName());
|
||||
case ignore:
|
||||
default:
|
||||
break;
|
||||
@ -78,7 +78,7 @@ public class GraphErrorHandler {
|
||||
case retry:
|
||||
retry = true;
|
||||
case count:
|
||||
exceptionMeterMetrics.mark(retryable);
|
||||
exceptionMeterMetrics.mark(retryable.getClass().getSimpleName());
|
||||
case ignore:
|
||||
default:
|
||||
break;
|
||||
|
@ -65,7 +65,7 @@ public class JDBCAction implements SyncAction {
|
||||
} catch (Exception e) {
|
||||
LOGGER.debug("Try " + tries + ": failed to execute statement: " + sql, e);
|
||||
|
||||
activity.getExceptionCount().count(e);
|
||||
activity.getExceptionCount().count(e.getClass().getSimpleName());
|
||||
|
||||
if (e instanceof SQLException) {
|
||||
SQLException sqle = (SQLException) e;
|
||||
|
@ -28,20 +28,20 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
* Use this to provide exception metering in a uniform way.
|
||||
*/
|
||||
public class ExceptionCountMetrics {
|
||||
private final ConcurrentHashMap<Class<? extends Throwable>, Counter> counters = new ConcurrentHashMap<>();
|
||||
private final ConcurrentHashMap<String, Counter> counters = new ConcurrentHashMap<>();
|
||||
private final ActivityDef activityDef;
|
||||
|
||||
public ExceptionCountMetrics(ActivityDef activityDef) {
|
||||
this.activityDef = activityDef;
|
||||
}
|
||||
|
||||
public void count(Throwable e) {
|
||||
Counter c = counters.get(e.getClass());
|
||||
public void count(String name) {
|
||||
Counter c = counters.get(name);
|
||||
if (c == null) {
|
||||
synchronized (counters) {
|
||||
c = counters.computeIfAbsent(
|
||||
e.getClass(),
|
||||
k -> ActivityMetrics.counter(activityDef, "errorcounts." + e.getClass().getSimpleName())
|
||||
name,
|
||||
k -> ActivityMetrics.counter(activityDef, "errorcounts." + name)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -30,20 +30,20 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
* from each type of error you want to track.
|
||||
*/
|
||||
public class ExceptionHistoMetrics {
|
||||
private final ConcurrentHashMap<Class<? extends Throwable>, Histogram> histos = new ConcurrentHashMap<>();
|
||||
private final ConcurrentHashMap<String, Histogram> histos = new ConcurrentHashMap<>();
|
||||
private final ActivityDef activityDef;
|
||||
|
||||
public ExceptionHistoMetrics(ActivityDef activityDef) {
|
||||
this.activityDef = activityDef;
|
||||
}
|
||||
|
||||
public void update(Throwable e, long magnitude) {
|
||||
Histogram h = histos.get(e.getClass());
|
||||
public void update(String name, long magnitude) {
|
||||
Histogram h = histos.get(name);
|
||||
if (h == null) {
|
||||
synchronized (histos) {
|
||||
h = histos.computeIfAbsent(
|
||||
e.getClass(),
|
||||
k -> ActivityMetrics.histogram(activityDef, "errorhistos." + e.getClass().getSimpleName())
|
||||
name,
|
||||
k -> ActivityMetrics.histogram(activityDef, "errorhistos." + name)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -28,20 +28,20 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
* Use this to provide exception metering in a uniform way.
|
||||
*/
|
||||
public class ExceptionMeterMetrics {
|
||||
private final ConcurrentHashMap<Class<? extends Throwable>, Meter> meters = new ConcurrentHashMap<>();
|
||||
private final ConcurrentHashMap<String, Meter> meters = new ConcurrentHashMap<>();
|
||||
private final ActivityDef activityDef;
|
||||
|
||||
public ExceptionMeterMetrics(ActivityDef activityDef) {
|
||||
this.activityDef = activityDef;
|
||||
}
|
||||
|
||||
public void mark(Throwable t) {
|
||||
Meter c = meters.get(t.getClass());
|
||||
public void mark(String name) {
|
||||
Meter c = meters.get(name);
|
||||
if (c == null) {
|
||||
synchronized (meters) {
|
||||
c = meters.computeIfAbsent(
|
||||
t.getClass(),
|
||||
k -> ActivityMetrics.meter(activityDef, "exceptions." + t.getClass().getSimpleName())
|
||||
name,
|
||||
k -> ActivityMetrics.meter(activityDef, "exceptions." + name)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -29,20 +29,20 @@ import java.util.concurrent.TimeUnit;
|
||||
* Use this to provide exception metering in a uniform way.
|
||||
*/
|
||||
public class ExceptionTimerMetrics {
|
||||
private final ConcurrentHashMap<Class<? extends Throwable>, Timer> timers = new ConcurrentHashMap<>();
|
||||
private final ConcurrentHashMap<String, Timer> timers = new ConcurrentHashMap<>();
|
||||
private final ActivityDef activityDef;
|
||||
|
||||
public ExceptionTimerMetrics(ActivityDef activityDef) {
|
||||
this.activityDef = activityDef;
|
||||
}
|
||||
|
||||
public void update(Throwable throwable, long nanosDuration) {
|
||||
Timer timer = timers.get(throwable.getClass());
|
||||
public void update(String name, long nanosDuration) {
|
||||
Timer timer = timers.get(name);
|
||||
if (timer == null) {
|
||||
synchronized (timers) {
|
||||
timer = timers.computeIfAbsent(
|
||||
throwable.getClass(),
|
||||
k -> ActivityMetrics.timer(activityDef, "exceptions." + throwable.getClass().getSimpleName())
|
||||
name,
|
||||
k -> ActivityMetrics.timer(activityDef, "exceptions." + name)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user