use of com.netflix.spectator.api.CompositeRegistry in project incubator-servicecomb-java-chassis by apache.
the class TestPublishModelFactory method prepareRegistry.
protected Registry prepareRegistry() {
CompositeRegistry globalRegistry = SpectatorUtils.createCompositeRegistry(null);
Registry registry = new DefaultRegistry(new ManualClock());
EventBus eventBus = new EventBus();
DefaultMetricsInitializer metricsInitializer = new DefaultMetricsInitializer() {
protected Registry createRegistry(MetricsBootstrapConfig config) {
return registry;
}
};
metricsInitializer.init(globalRegistry, eventBus, new MetricsBootstrapConfig());
new MockUp<System>() {
@Mock
long nanoTime() {
return 10;
}
};
invocationType = InvocationType.CONSUMER;
new MockUp<Invocation>() {
@Mock
InvocationType getInvocationType() {
return invocationType;
}
@Mock
boolean isConsumer() {
return InvocationType.CONSUMER.equals(invocationType);
}
@Mock
String getRealTransportName() {
return Const.RESTFUL;
}
@Mock
String getMicroserviceQualifiedName() {
return "m.s.o";
}
@Mock
long getStartExecutionTime() {
return 5;
}
};
new Expectations() {
{
response.getStatusCode();
result = 200;
}
};
InvocationFinishEvent finishEvent = new InvocationFinishEvent(invocation, response);
eventBus.post(finishEvent);
invocationType = InvocationType.PRODUCER;
eventBus.post(finishEvent);
return registry;
}
use of com.netflix.spectator.api.CompositeRegistry in project zuul by Netflix.
the class SpectatorUtils method newGauge.
public static <T extends Number> T newGauge(String name, String id, T number, String... tags) {
final CompositeRegistry registry = Spectator.globalRegistry();
Id gaugeId = registry.createId(name, getTagsWithId(id, tags));
return registry.gauge(gaugeId, number);
}
Aggregations