Search in sources :

Example 1 with Clock

use of com.netflix.spectator.api.Clock in project java-chassis by ServiceComb.

the class TestMetricsRestPublisher method measure_normal.

@Test
public void measure_normal() {
    Clock clock = new ManualClock();
    GlobalRegistry globalRegistry = new GlobalRegistry();
    Registry registry = new DefaultRegistry(clock);
    registry.timer(registry.createId("name", "t1", "v1", "t2", "v2"));
    globalRegistry.add(registry);
    EventBus eventBus = new EventBus();
    publisher.init(globalRegistry, eventBus, new MetricsBootstrapConfig());
    Map<String, Double> result = publisher.measure();
    Assert.assertEquals(2, result.size());
    Assert.assertEquals(0, result.get("name(statistic=count,t1=v1,t2=v2)"), 0);
    Assert.assertEquals(0, result.get("name(statistic=totalTime,t1=v1,t2=v2)"), 0);
}
Also used : ManualClock(com.netflix.spectator.api.ManualClock) GlobalRegistry(org.apache.servicecomb.foundation.metrics.registry.GlobalRegistry) MetricsBootstrapConfig(org.apache.servicecomb.foundation.metrics.MetricsBootstrapConfig) DefaultRegistry(com.netflix.spectator.api.DefaultRegistry) DefaultRegistry(com.netflix.spectator.api.DefaultRegistry) GlobalRegistry(org.apache.servicecomb.foundation.metrics.registry.GlobalRegistry) Registry(com.netflix.spectator.api.Registry) EventBus(com.google.common.eventbus.EventBus) ManualClock(com.netflix.spectator.api.ManualClock) Clock(com.netflix.spectator.api.Clock) Test(org.junit.Test)

Aggregations

EventBus (com.google.common.eventbus.EventBus)1 Clock (com.netflix.spectator.api.Clock)1 DefaultRegistry (com.netflix.spectator.api.DefaultRegistry)1 ManualClock (com.netflix.spectator.api.ManualClock)1 Registry (com.netflix.spectator.api.Registry)1 MetricsBootstrapConfig (org.apache.servicecomb.foundation.metrics.MetricsBootstrapConfig)1 GlobalRegistry (org.apache.servicecomb.foundation.metrics.registry.GlobalRegistry)1 Test (org.junit.Test)1