Search in sources :

Example 6 with DefaultRegistry

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());
}
Also used : Counter(com.netflix.spectator.api.Counter) DefaultRegistry(com.netflix.spectator.api.DefaultRegistry) Monitoring(com.google.api.services.monitoring.v3.Monitoring) Test(org.junit.Test)

Example 7 with DefaultRegistry

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());
}
Also used : Timer(com.netflix.spectator.api.Timer) DefaultRegistry(com.netflix.spectator.api.DefaultRegistry) Test(org.junit.Test)

Example 8 with DefaultRegistry

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();
}
Also used : Injector(com.google.inject.Injector) AdminServer(com.netflix.iep.admin.AdminServer) DefaultRegistry(com.netflix.spectator.api.DefaultRegistry) AbstractModule(com.google.inject.AbstractModule)

Aggregations

DefaultRegistry (com.netflix.spectator.api.DefaultRegistry)8 Test (org.junit.Test)6 Monitoring (com.google.api.services.monitoring.v3.Monitoring)2 AbstractModule (com.google.inject.AbstractModule)2 Measurement (com.netflix.spectator.api.Measurement)2 Meter (com.netflix.spectator.api.Meter)2 Registry (com.netflix.spectator.api.Registry)2 EventBus (com.google.common.eventbus.EventBus)1 Injector (com.google.inject.Injector)1 AdminServer (com.netflix.iep.admin.AdminServer)1 CompositeRegistry (com.netflix.spectator.api.CompositeRegistry)1 Counter (com.netflix.spectator.api.Counter)1 ManualClock (com.netflix.spectator.api.ManualClock)1 Timer (com.netflix.spectator.api.Timer)1 SpectatorMetricCollector (com.netflix.spectator.aws.SpectatorMetricCollector)1 ArrayList (java.util.ArrayList)1 Expectations (mockit.Expectations)1 MockUp (mockit.MockUp)1 InvocationFinishEvent (org.apache.servicecomb.core.event.InvocationFinishEvent)1 MetricsBootstrapConfig (org.apache.servicecomb.foundation.metrics.MetricsBootstrapConfig)1