Skip to content

Commit 4966435

Browse files
committed
Merge pull request #111 from brharrington/servo-guage-gaps
fix sporadic gaps on gauges reported to servo
2 parents dbdaf91 + 7ef8f96 commit 4966435

File tree

2 files changed

+41
-1
lines changed

2 files changed

+41
-1
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/**
2+
* Copyright 2015 Netflix, Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package com.netflix.spectator.servo;
17+
18+
import com.netflix.servo.monitor.AbstractMonitor;
19+
import com.netflix.servo.monitor.MonitorConfig;
20+
import com.netflix.servo.monitor.NumericMonitor;
21+
22+
/**
23+
* Reports a constant value passed into the constructor.
24+
*/
25+
final class ServoGauge<T extends Number> extends AbstractMonitor<Double>
26+
implements NumericMonitor<Double> {
27+
private final double value;
28+
29+
/**
30+
* Create a new monitor that returns {@code value}.
31+
*/
32+
ServoGauge(MonitorConfig config, double value) {
33+
super(config);
34+
this.value = value;
35+
}
36+
37+
@Override public Double getValue(int pollerIndex) {
38+
return value;
39+
}
40+
}

spectator-reg-servo/src/main/java/com/netflix/spectator/servo/ServoRegistry.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ MonitorConfig toMonitorConfig(Id id) {
121121
}
122122
} else {
123123
for (Measurement m : meter.measure()) {
124-
monitors.add(new NumberGauge(toMonitorConfig(m.id()), m.value()));
124+
monitors.add(new ServoGauge(toMonitorConfig(m.id()), m.value()));
125125
}
126126
}
127127
}

0 commit comments

Comments
 (0)