use of com.netflix.spectator.api.DefaultRegistry in project kork by spinnaker.
the class StackdriverWriterTest method writeRegistryWithSmallRegistry.
@Test
public void writeRegistryWithSmallRegistry() throws IOException {
TestableStackdriverWriter spy = spy(new TestableStackdriverWriter(writerConfig.build()));
Monitoring.Projects.TimeSeries.Create mockCreateMethod = Mockito.mock(Monitoring.Projects.TimeSeries.Create.class);
DefaultRegistry registry = new DefaultRegistry(clock);
Counter counterA = registry.counter(idAXY);
Counter counterB = registry.counter(idBXY);
counterA.increment(4);
counterB.increment(10);
when(timeseriesApi.create(eq("projects/test-project"), any(CreateTimeSeriesRequest.class))).thenReturn(mockCreateMethod);
when(mockCreateMethod.execute()).thenReturn(null);
spy.writeRegistry(registry);
verify(mockCreateMethod, times(1)).execute();
ArgumentCaptor<CreateTimeSeriesRequest> captor = ArgumentCaptor.forClass(CreateTimeSeriesRequest.class);
verify(timeseriesApi, times(1)).create(eq("projects/test-project"), captor.capture());
// A, B, timer count and totalTime.
Assert.assertEquals(4, captor.getValue().getTimeSeries().size());
}
use of com.netflix.spectator.api.DefaultRegistry 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.DefaultRegistry in project iep by Netflix.
the class AdminModule method main.
/**
* Sample main that runs the admin with a default set of endpoints. Mostly used for
* quick local testing of the module and common endpoints.
*/
public static void main(String[] args) {
Injector injector = Guice.createInjector(new AdminModule(), new AbstractModule() {
@Override
protected void configure() {
bind(Registry.class).toInstance(new DefaultRegistry());
}
});
AdminServer server = injector.getInstance(AdminServer.class);
server.start();
}
Aggregations