Pass field definitions into metric timers

This makes the names of the fields available to the Timer so that the
fields names can be included into debug logs and performance logs.

Change-Id: I987f40da0165ac948f2747b33cb8154f3bdab4da
Signed-off-by: Edwin Kempin <ekempin@google.com>
This commit is contained in:
Edwin Kempin
2019-06-24 14:09:38 +02:00
parent 3fec839b37
commit aadd006c8c
7 changed files with 110 additions and 83 deletions

View File

@@ -26,8 +26,9 @@ class TimerImpl1<F1> extends BucketedTimer implements BucketedMetric {
super(metrics, name, desc, field1);
}
@SuppressWarnings("unchecked")
Timer1<F1> timer() {
return new Timer1<F1>(name) {
return new Timer1<F1>(name, (Field<F1>) fields[0]) {
@Override
protected void doRecord(F1 field1, long value, TimeUnit unit) {
total.record(value, unit);

View File

@@ -29,8 +29,9 @@ class TimerImplN extends BucketedTimer implements BucketedMetric {
super(metrics, name, desc, fields);
}
@SuppressWarnings("unchecked")
<F1, F2> Timer2<F1, F2> timer2() {
return new Timer2<F1, F2>(name) {
return new Timer2<F1, F2>(name, (Field<F1>) fields[0], (Field<F2>) fields[1]) {
@Override
protected void doRecord(F1 field1, F2 field2, long value, TimeUnit unit) {
total.record(value, unit);
@@ -44,8 +45,10 @@ class TimerImplN extends BucketedTimer implements BucketedMetric {
};
}
@SuppressWarnings("unchecked")
<F1, F2, F3> Timer3<F1, F2, F3> timer3() {
return new Timer3<F1, F2, F3>(name) {
return new Timer3<F1, F2, F3>(
name, (Field<F1>) fields[0], (Field<F2>) fields[1], (Field<F3>) fields[2]) {
@Override
protected void doRecord(F1 field1, F2 field2, F3 field3, long value, TimeUnit unit) {
total.record(value, unit);