use of com.netflix.spectator.api.Measurement in project kork by spinnaker.
the class StackdriverWriterTest method testMeasurementsToTimeSeries.
@Test
public void testMeasurementsToTimeSeries() throws IOException {
Measurement measureAXY = new Measurement(idAXY, clock.monotonicTime(), 1);
Measurement measureBXY = new Measurement(idBXY, clock.monotonicTime(), 2);
DefaultRegistry testRegistry = new DefaultRegistry(clock);
testRegistry.counter(idAXY).increment();
testRegistry.counter(idBXY).increment(2);
// Note this writer is still using the mock Monitoring client stub.
TestableStackdriverWriter spy = spy(new TestableStackdriverWriter(writerConfig.build()));
Meter counterA = testRegistry.counter(idAXY);
Meter counterB = testRegistry.counter(idBXY);
doReturn(new TimeSeries()).when(spy).measurementToTimeSeries(eq(descriptorA.getType()), eq(testRegistry), eq(counterA), eq(measureAXY));
doReturn(new TimeSeries()).when(spy).measurementToTimeSeries(eq(descriptorB.getType()), eq(testRegistry), eq(counterB), eq(measureBXY));
// Just testing the call flow produces descriptors since
// we return empty TimeSeries values.
spy.registryToTimeSeries(testRegistry);
}
use of com.netflix.spectator.api.Measurement in project kork by spinnaker.
the class StackdriverWriterTest method testAddMeasurementsToTimeSeries.
@Test
public void testAddMeasurementsToTimeSeries() {
DefaultRegistry testRegistry = new DefaultRegistry(clock);
long millisA = TimeUnit.MILLISECONDS.convert(1472394975L, TimeUnit.SECONDS);
long millisB = millisA + 987;
String timeA = "2016-08-28T14:36:15.000000000Z";
String timeB = "2016-08-28T14:36:15.987000000Z";
Meter timerA = testRegistry.timer(idAXY);
Meter timerB = testRegistry.timer(idBXY);
Measurement measureAXY = new Measurement(idAXY, millisA, 1);
Measurement measureBXY = new Measurement(idBXY, millisB, 20.1);
descriptorRegistrySpy.addExtraTimeSeriesLabel(MetricDescriptorCache.INSTANCE_LABEL, INSTANCE_ID);
Assert.assertEquals(makeTimeSeries(descriptorA, idAXY, 1, timeA), writer.measurementToTimeSeries(descriptorA.getType(), testRegistry, timerA, measureAXY));
Assert.assertEquals(makeTimeSeries(descriptorB, idBXY, 20.1, timeB), writer.measurementToTimeSeries(descriptorB.getType(), testRegistry, timerB, measureBXY));
}
use of com.netflix.spectator.api.Measurement in project iep by Netflix.
the class BaseServerEndpoint method getMetrics.
private Object getMetrics() {
List<Object> metrics = new ArrayList<>();
for (Meter meter : registry) {
for (Measurement m : meter.measure()) {
if (Double.isFinite(m.value())) {
Map<String, Object> datapoint = new LinkedHashMap<>();
datapoint.put("name", m.id().name());
datapoint.put("tags", encodeTags(m.id()));
datapoint.put("timestamp", m.timestamp());
datapoint.put("value", m.value());
metrics.add(datapoint);
}
}
}
return metrics;
}
Aggregations