本文整理了Java中io.micrometer.core.instrument.Counter.count()
方法的一些代码示例,展示了Counter.count()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Counter.count()
方法的具体详情如下:
包路径:io.micrometer.core.instrument.Counter
类名称:Counter
方法名:count
暂无
代码示例来源:origin: micrometer-metrics/micrometer
@TearDown(Level.Trial)
public void tearDown(Blackhole hole) {
for (io.micrometer.core.instrument.Meter m : registry.getMeters()) {
if (m instanceof io.micrometer.core.instrument.Counter) {
hole.consume(((io.micrometer.core.instrument.Counter) m).count());
}
}
}
}
代码示例来源:origin: reactor/reactor-core
@Test
public void countsSubscriptionsFuseable() {
Mono<Integer> source = Mono.just(10);
Mono<Integer> test = new MonoMetricsFuseable<>(source, registry);
test.subscribe();
Counter meter = registry.find(METER_SUBSCRIBED)
.counter();
assertThat(meter).isNotNull();
assertThat(meter.count()).as("after 1s subscribe").isEqualTo(1);
test.subscribe();
test.subscribe();
assertThat(meter.count()).as("after more subscribe").isEqualTo(3);
}
代码示例来源:origin: reactor/reactor-core
@Test
public void malformedOnComplete() {
TestPublisher<Integer> testPublisher = TestPublisher.createNoncompliant(CLEANUP_ON_TERMINATE);
Mono<Integer> source = testPublisher.mono().hide();
new MonoMetrics<>(source, registry)
.subscribe(v -> assertThat(v).isEqualTo(1),
e -> assertThat(e).hasMessage("malformedOnComplete"));
testPublisher.error(new IllegalStateException("malformedOnComplete"))
.complete();
Counter malformedMeter = registry
.find(METER_MALFORMED)
.counter();
assertThat(malformedMeter).isNotNull();
assertThat(malformedMeter.count()).isEqualTo(1);
}
代码示例来源:origin: reactor/reactor-core
@Test
public void countsSubscriptions() {
Mono<Integer> source = Mono.just(1)
.hide();
Mono<Integer> test = new MonoMetrics<>(source, registry);
test.subscribe();
Counter meter = registry.find(METER_SUBSCRIBED)
.counter();
assertThat(meter).isNotNull();
assertThat(meter.count()).as("after 1s subscribe").isEqualTo(1);
test.subscribe();
test.subscribe();
assertThat(meter.count()).as("after more subscribe").isEqualTo(3);
}
代码示例来源:origin: reactor/reactor-core
@Test
public void countsSubscriptionsFuseable() {
Flux<Integer> source = Flux.range(1, 10);
Flux<Integer> test = new FluxMetricsFuseable<>(source, registry);
test.subscribe();
Counter meter = registry.find(METER_SUBSCRIBED)
.counter();
assertThat(meter).isNotNull();
assertThat(meter.count()).as("after 1s subscribe").isEqualTo(1);
test.subscribe();
test.subscribe();
assertThat(meter.count()).as("after more subscribe").isEqualTo(3);
}
代码示例来源:origin: reactor/reactor-core
@Test
public void malformedOnComplete() {
TestPublisher<Integer> testPublisher = TestPublisher.createNoncompliant(CLEANUP_ON_TERMINATE);
Flux<Integer> source = testPublisher.flux().hide();
new FluxMetrics<>(source, registry)
.subscribe(v -> assertThat(v).isEqualTo(1),
e -> assertThat(e).hasMessage("malformedOnComplete"));
testPublisher.next(1)
.error(new IllegalStateException("malformedOnComplete"))
.complete();
Counter malformedMeter = registry
.find(METER_MALFORMED)
.counter();
assertThat(malformedMeter).isNotNull();
assertThat(malformedMeter.count()).isEqualTo(1);
}
代码示例来源:origin: reactor/reactor-core
@Test
public void countsSubscriptions() {
Flux<Integer> source = Flux.range(1, 10)
.hide();
Flux<Integer> test = new FluxMetrics<>(source, registry);
test.subscribe();
Counter meter = registry.find(METER_SUBSCRIBED)
.counter();
assertThat(meter).isNotNull();
assertThat(meter.count()).as("after 1s subscribe").isEqualTo(1);
test.subscribe();
test.subscribe();
assertThat(meter.count()).as("after more subscribe").isEqualTo(3);
}
代码示例来源:origin: reactor/reactor-core
@Test
public void malformedOnNext() {
TestPublisher<Integer> testPublisher = TestPublisher.createNoncompliant(CLEANUP_ON_TERMINATE);
Mono<Integer> source = testPublisher.mono().hide();
new MonoMetrics<>(source, registry)
.subscribe();
testPublisher.complete()
.next(2);
Counter malformedMeter = registry
.find(METER_MALFORMED)
.counter();
assertThat(malformedMeter).isNotNull();
assertThat(malformedMeter.count()).isEqualTo(1);
}
代码示例来源:origin: reactor/reactor-core
@Test
public void malformedOnError() {
AtomicReference<Throwable> errorDropped = new AtomicReference<>();
Hooks.onErrorDropped(errorDropped::set);
Exception dropError = new IllegalStateException("malformedOnError");
try {
TestPublisher<Integer> testPublisher = TestPublisher.createNoncompliant(CLEANUP_ON_TERMINATE);
Mono<Integer> source = testPublisher.mono().hide();
new MonoMetrics<>(source, registry)
.subscribe();
testPublisher.complete()
.error(dropError);
Counter malformedMeter = registry
.find(METER_MALFORMED)
.counter();
assertThat(malformedMeter).isNotNull();
assertThat(malformedMeter.count()).isEqualTo(1);
assertThat(errorDropped).hasValue(dropError);
}
finally{
Hooks.resetOnErrorDropped();
}
}
代码示例来源:origin: reactor/reactor-core
@Test
public void malformedOnNext() {
TestPublisher<Integer> testPublisher = TestPublisher.createNoncompliant(CLEANUP_ON_TERMINATE);
Flux<Integer> source = testPublisher.flux().hide();
new FluxMetrics<>(source, registry)
.subscribe();
testPublisher.next(1)
.complete()
.next(2);
Counter malformedMeter = registry
.find(METER_MALFORMED)
.counter();
assertThat(malformedMeter).isNotNull();
assertThat(malformedMeter.count()).isEqualTo(1);
}
代码示例来源:origin: reactor/reactor-core
@Test
public void malformedOnError() {
AtomicReference<Throwable> errorDropped = new AtomicReference<>();
Hooks.onErrorDropped(errorDropped::set);
Exception dropError = new IllegalStateException("malformedOnError");
try {
TestPublisher<Integer> testPublisher = TestPublisher.createNoncompliant(CLEANUP_ON_TERMINATE);
Flux<Integer> source = testPublisher.flux().hide();
new FluxMetrics<>(source, registry)
.subscribe();
testPublisher.next(1)
.complete()
.error(dropError);
Counter malformedMeter = registry
.find(METER_MALFORMED)
.counter();
assertThat(malformedMeter).isNotNull();
assertThat(malformedMeter.count()).isEqualTo(1);
assertThat(errorDropped).hasValue(dropError);
}
finally{
Hooks.resetOnErrorDropped();
}
}
代码示例来源:origin: rsocket/rsocket-java
@DisplayName("metadataPush gathers metrics")
@Test
void metadataPush() {
Payload payload = DefaultPayload.create("test-metadata", "test-data");
when(delegate.metadataPush(payload)).thenReturn(Mono.empty());
new MicrometerRSocket(delegate, meterRegistry, Tag.of("test-key", "test-value"))
.metadataPush(payload)
.as(StepVerifier::create)
.verifyComplete();
assertThat(findCounter("metadata.push", SignalType.ON_COMPLETE).count()).isEqualTo(1);
}
代码示例来源:origin: rsocket/rsocket-java
@DisplayName("fireAndForget gathers metrics")
@Test
void fireAndForget() {
Payload payload = DefaultPayload.create("test-metadata", "test-data");
when(delegate.fireAndForget(payload)).thenReturn(Mono.empty());
new MicrometerRSocket(delegate, meterRegistry, Tag.of("test-key", "test-value"))
.fireAndForget(payload)
.as(StepVerifier::create)
.verifyComplete();
assertThat(findCounter("request.fnf", SignalType.ON_COMPLETE).count()).isEqualTo(1);
}
代码示例来源:origin: rsocket/rsocket-java
@DisplayName("requestChannel gathers metrics")
@Test
void requestChannel() {
Mono<Payload> payload = Mono.just(DefaultPayload.create("test-metadata", "test-data"));
when(delegate.requestChannel(payload)).thenReturn(Flux.empty());
new MicrometerRSocket(delegate, meterRegistry, Tag.of("test-key", "test-value"))
.requestChannel(payload)
.as(StepVerifier::create)
.verifyComplete();
assertThat(findCounter("request.channel", SignalType.ON_COMPLETE).count()).isEqualTo(1);
}
代码示例来源:origin: rsocket/rsocket-java
@DisplayName("requestStream gathers metrics")
@Test
void requestStream() {
Payload payload = DefaultPayload.create("test-metadata", "test-data");
when(delegate.requestStream(payload)).thenReturn(Flux.empty());
new MicrometerRSocket(delegate, meterRegistry, Tag.of("test-key", "test-value"))
.requestStream(payload)
.as(StepVerifier::create)
.verifyComplete();
assertThat(findCounter("request.stream", SignalType.ON_COMPLETE).count()).isEqualTo(1);
}
代码示例来源:origin: rsocket/rsocket-java
assertThat(findCounter(SERVER, CANCEL).count()).isEqualTo(1);
assertThat(findCounter(SERVER, COMPLETE).count()).isEqualTo(1);
assertThat(findCounter(SERVER, ERROR).count()).isEqualTo(1);
assertThat(findCounter(SERVER, KEEPALIVE).count()).isEqualTo(1);
assertThat(findCounter(SERVER, LEASE).count()).isEqualTo(1);
assertThat(findCounter(SERVER, METADATA_PUSH).count()).isEqualTo(1);
assertThat(findCounter(SERVER, REQUEST_CHANNEL).count()).isEqualTo(1);
assertThat(findCounter(SERVER, REQUEST_FNF).count()).isEqualTo(1);
assertThat(findCounter(SERVER, REQUEST_N).count()).isEqualTo(1);
assertThat(findCounter(SERVER, REQUEST_RESPONSE).count()).isEqualTo(1);
assertThat(findCounter(SERVER, REQUEST_STREAM).count()).isEqualTo(1);
assertThat(findCounter(SERVER, RESUME).count()).isEqualTo(1);
assertThat(findCounter(SERVER, RESUME_OK).count()).isEqualTo(1);
assertThat(findCounter(SERVER, SETUP).count()).isEqualTo(1);
代码示例来源:origin: rsocket/rsocket-java
.verifyComplete();
assertThat(findCounter(CLIENT, CANCEL).count()).isEqualTo(1);
assertThat(findCounter(CLIENT, COMPLETE).count()).isEqualTo(1);
assertThat(findCounter(CLIENT, ERROR).count()).isEqualTo(1);
assertThat(findCounter(CLIENT, KEEPALIVE).count()).isEqualTo(1);
assertThat(findCounter(CLIENT, LEASE).count()).isEqualTo(1);
assertThat(findCounter(CLIENT, METADATA_PUSH).count()).isEqualTo(1);
assertThat(findCounter(CLIENT, REQUEST_CHANNEL).count()).isEqualTo(1);
assertThat(findCounter(CLIENT, REQUEST_FNF).count()).isEqualTo(1);
assertThat(findCounter(CLIENT, REQUEST_N).count()).isEqualTo(1);
assertThat(findCounter(CLIENT, REQUEST_RESPONSE).count()).isEqualTo(1);
assertThat(findCounter(CLIENT, REQUEST_STREAM).count()).isEqualTo(1);
assertThat(findCounter(CLIENT, RESUME).count()).isEqualTo(1);
assertThat(findCounter(CLIENT, RESUME_OK).count()).isEqualTo(1);
assertThat(findCounter(CLIENT, SETUP).count()).isEqualTo(1);
代码示例来源:origin: rsocket/rsocket-java
@DisplayName("onClose gathers metrics")
@Test
void onClose() {
when(delegate.onClose()).thenReturn(Mono.empty());
new MicrometerDuplexConnection(
CLIENT, delegate, meterRegistry, Tag.of("test-key", "test-value"))
.onClose()
.subscribe(Operators.drainSubscriber());
assertThat(
meterRegistry
.get("rsocket.duplex.connection.close")
.tag("connection.type", CLIENT.name())
.tag("test-key", "test-value")
.counter()
.count())
.isEqualTo(1);
}
代码示例来源:origin: rsocket/rsocket-java
@DisplayName("dispose gathers metrics")
@Test
void dispose() {
new MicrometerDuplexConnection(
CLIENT, delegate, meterRegistry, Tag.of("test-key", "test-value"))
.dispose();
assertThat(
meterRegistry
.get("rsocket.duplex.connection.dispose")
.tag("connection.type", CLIENT.name())
.tag("test-key", "test-value")
.counter()
.count())
.isEqualTo(1);
}
代码示例来源:origin: spring-projects/spring-integration
.tag("name", "queue")
.tag("result", "success")
.counter().count()).isEqualTo(1);
内容来源于网络,如有侵权,请联系作者删除!