use of io.micrometer.core.instrument.simple.SimpleMeterRegistry in project tutorials by eugenp.
the class MicrometerAtlasTest method givenTimer_whenEnrichWithTimescaleHistogram_thenTimeScaleDataCollected.
@Test
public void givenTimer_whenEnrichWithTimescaleHistogram_thenTimeScaleDataCollected() {
SimpleMeterRegistry registry = new SimpleMeterRegistry();
Timer timer = Timer.builder("timer").histogram(Histogram.linearTime(TimeUnit.MILLISECONDS, 0, 200, 3)).register(registry);
timer.record(1000, TimeUnit.MILLISECONDS);
timer.record(23, TimeUnit.MILLISECONDS);
timer.record(450, TimeUnit.MILLISECONDS);
timer.record(341, TimeUnit.MILLISECONDS);
timer.record(500, TimeUnit.MILLISECONDS);
Map<String, Integer> histograms = extractTagValueMap(registry, Type.Counter, 1.0);
assertThat(histograms, allOf(hasEntry("bucket=0.0", 0), hasEntry("bucket=2.0E8", 1), hasEntry("bucket=4.0E8", 1), hasEntry("bucket=Infinity", 3)));
}
use of io.micrometer.core.instrument.simple.SimpleMeterRegistry in project micrometer by micrometer-metrics.
the class TimedAspectTest method timeMethod.
@Test
void timeMethod() {
MeterRegistry registry = new SimpleMeterRegistry();
AspectJProxyFactory pf = new AspectJProxyFactory(new TimedService());
pf.addAspect(new TimedAspect(registry));
TimedService service = pf.getProxy();
service.call();
assertThat(registry.get("call").tag("class", "io.micrometer.core.aop.TimedAspectTest$TimedService").tag("method", "call").tag("extra", "tag").timer().count()).isEqualTo(1);
}
use of io.micrometer.core.instrument.simple.SimpleMeterRegistry in project micrometer by micrometer-metrics.
the class MicrometerMetricsPublisherCommandTest method testOpenCircuit.
@Disabled
@Test
void testOpenCircuit() {
HystrixCommandKey key = HystrixCommandKey.Factory.asKey("MicrometerCOMMAND-B");
HystrixCommandProperties properties = new HystrixPropertiesCommandDefault(key, propertiesSetter.withCircuitBreakerForceOpen(true));
HystrixCommandMetrics metrics = HystrixCommandMetrics.getInstance(key, groupKey, properties);
HystrixCircuitBreaker circuitBreaker = HystrixCircuitBreaker.Factory.getInstance(key, groupKey, properties, metrics);
SimpleMeterRegistry registry = new SimpleMeterRegistry();
MicrometerMetricsPublisherCommand metricsPublisherCommand = new MicrometerMetricsPublisherCommand(registry, key, groupKey, metrics, circuitBreaker, properties);
metricsPublisherCommand.initialize();
new SuccessCommand(key).execute();
new SuccessCommand(key).execute();
new TimeoutCommand(key).execute();
new FailureCommand(key).execute();
new FailureCommand(key).execute();
new SuccessCommand(key).execute();
Iterable<Tag> tags = Tags.of("group", groupKey.name(), "key", key.name());
assertExecutionMetric(registry, "short_circuited", 6.0);
assertThat(registry.get("hystrix.execution").tags(tags).tags("event", "success").functionCounter().count()).isEqualTo(0.0);
assertThat(registry.get("hystrix.execution").tags(tags).tags("event", "timeout").functionCounter().count()).isEqualTo(0.0);
assertThat(registry.get("hystrix.execution").tags(tags).tags("event", "failure").functionCounter().count()).isEqualTo(0.0);
assertThat(registry.get("hystrix.fallback").tags(tags).tags("event", "fallback_success").functionCounter().count()).isEqualTo(6.0);
assertThat(registry.get("hystrix.circuit.breaker.open").tags(tags).gauge().value()).isEqualTo(1.0);
}
use of io.micrometer.core.instrument.simple.SimpleMeterRegistry in project micrometer by micrometer-metrics.
the class CompositeMeterRegistryTest method castingFunctionCounter.
@Issue("#255")
@Test
void castingFunctionCounter() {
SimpleMeterRegistry registry = new SimpleMeterRegistry();
CompositeMeterRegistry compositeMeterRegistry = new CompositeMeterRegistry();
FunctionCounter.builder("foo", 1L, x -> x).register(compositeMeterRegistry);
compositeMeterRegistry.add(registry);
}
use of io.micrometer.core.instrument.simple.SimpleMeterRegistry in project micrometer by micrometer-metrics.
the class HistogramGaugesTest method snapshotRollsOverAfterEveryPublish.
@Test
void snapshotRollsOverAfterEveryPublish() {
MeterRegistry registry = new SimpleMeterRegistry();
Timer timer = Timer.builder("my.timer").sla(Duration.ofMillis(1)).register(registry);
HistogramGauges gauges = HistogramGauges.registerWithCommonFormat(timer, registry);
timer.record(1, TimeUnit.MILLISECONDS);
assertThat(registry.get("my.timer.histogram").gauge().value()).isEqualTo(1);
assertThat(gauges.polledGaugesLatch.getCount()).isEqualTo(0);
}
Aggregations