use of com.netflix.spectator.api.Timer in project kork by spinnaker.
the class StackdriverWriterTest method writeRegistryWithTimer.
@Test
public void writeRegistryWithTimer() throws IOException {
DefaultRegistry testRegistry = new DefaultRegistry(clock);
Timer timer = testRegistry.timer(idAXY);
timer.record(123, TimeUnit.MILLISECONDS);
// If we get the expected result then we matched the expected descriptors,
// which means the transforms occurred as expected.
List<TimeSeries> tsList = writer.registryToTimeSeries(testRegistry);
Assert.assertEquals(2, tsList.size());
}
use of com.netflix.spectator.api.Timer in project metacat by Netflix.
the class SNSNotificationMetric method recordTime.
void recordTime(final SNSMessage<?> message, final String timeName) {
final Timer timer = this.registry.timer(timeName, Metrics.TagEventsType.getMetricName(), message.getClass().getName());
timer.record(this.registry.clock().wallTime() - message.getTimestamp(), TimeUnit.MILLISECONDS);
}
use of com.netflix.spectator.api.Timer in project iep by Netflix.
the class SpectatorEndpoint method get.
@Override
public Object get(String path) {
Query q = Query.parse(path);
return registry.stream().filter(m -> !m.hasExpired()).flatMap(m -> {
List<Object> ms = new ArrayList<>();
Map<String, String> tags = toMap(m.id());
if (m instanceof Counter) {
add(q, tags, ms, new CounterInfo(tags, ((Counter) m).count()));
} else if (m instanceof Timer) {
Timer t = (Timer) m;
add(q, tags, ms, new TimerInfo(tags, t.totalTime(), t.count()));
} else if (m instanceof DistributionSummary) {
DistributionSummary t = (DistributionSummary) m;
add(q, tags, ms, new DistInfo(tags, t.totalAmount(), t.count()));
} else if (m instanceof Gauge) {
Gauge g = (Gauge) m;
add(q, tags, ms, new GaugeInfo(tags, g.value()));
}
return ms.stream();
}).collect(Collectors.toList());
}
Aggregations