Java Code Examples for io.micrometer.core.instrument.simple.SimpleConfig#DEFAULT
The following examples show how to use
io.micrometer.core.instrument.simple.SimpleConfig#DEFAULT .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MicrometerCapabilityTest.java From feign with Apache License 2.0 | 5 votes |
@Test public void addMetricsCapability() { SimpleMeterRegistry registry = new SimpleMeterRegistry(SimpleConfig.DEFAULT, new MockClock()); final SimpleSource source = Feign.builder() .client(new MockClient() .ok(HttpMethod.GET, "/get", "1234567890abcde")) .addCapability(new MicrometerCapability(registry)) .target(new MockTarget<>(MicrometerCapabilityTest.SimpleSource.class)); source.get("0x3456789"); List<Meter> metrics = new ArrayList<>(); registry.forEachMeter(metrics::add); metrics.removeIf(meter -> !meter.getId().getName().startsWith("feign.")); metrics.forEach(meter -> assertThat( "Expect all metric names to include client name:" + meter.getId(), meter.getId().getTag("client"), equalTo("feign.micrometer.MicrometerCapabilityTest$SimpleSource"))); metrics.forEach(meter -> assertThat( "Expect all metric names to include method name:" + meter.getId(), meter.getId().getTag("method"), equalTo("get"))); metrics.forEach(meter -> assertThat( "Expect all metric names to include host name:" + meter.getId(), meter.getId().getTag("host"), // hostname is blank due to feign-mock shortfalls equalTo(""))); }
Example 2
Source File: MonoMetricsFuseableTest.java From reactor-core with Apache License 2.0 | 5 votes |
@Test public void queuePollSyncTracksOnComplete() { //prepare registry with mock clock MockClock clock = new MockClock(); removeRegistry(); registry = new SimpleMeterRegistry(SimpleConfig.DEFAULT, clock); Metrics.globalRegistry.add(registry); AssertSubscriber<Integer> testSubscriber = AssertSubscriber.create(); MetricsFuseableSubscriber<Integer> fuseableSubscriber = new MetricsFuseableSubscriber<>(testSubscriber, registry, clock, Tags.empty()); Fuseable.QueueSubscription<Integer> testQueue = new FluxPeekFuseableTest.AssertQueueSubscription<>(); testQueue.offer(1); fuseableSubscriber.onSubscribe(testQueue); fuseableSubscriber.requestFusion(Fuseable.SYNC); clock.add(Duration.ofMillis(200)); Integer val1 = fuseableSubscriber.poll(); clock.add(Duration.ofMillis(123)); Integer val2 = fuseableSubscriber.poll(); assertThat(val1).isEqualTo(1); assertThat(val2).isNull(); //test meters Timer terminationTimer = registry.find(METER_FLOW_DURATION) .tags(Tags.of(TAG_ON_COMPLETE)) .timer(); assertThat(terminationTimer).isNotNull(); assertThat(terminationTimer.max(TimeUnit.MILLISECONDS)).as("terminate max delay").isEqualTo(200); }
Example 3
Source File: MonoMetricsFuseableTest.java From reactor-core with Apache License 2.0 | 5 votes |
@Test public void queuePollDoesntTrackOnNext() { //prepare registry with mock clock MockClock clock = new MockClock(); removeRegistry(); registry = new SimpleMeterRegistry(SimpleConfig.DEFAULT, clock); Metrics.globalRegistry.add(registry); AssertSubscriber<Integer> testSubscriber = AssertSubscriber.create(); MetricsFuseableSubscriber<Integer> fuseableSubscriber = new MetricsFuseableSubscriber<>(testSubscriber, registry, clock, Tags.empty()); Fuseable.QueueSubscription<Integer> testQueue = new FluxPeekFuseableTest.AssertQueueSubscription<>(); testQueue.offer(1); fuseableSubscriber.onSubscribe(testQueue); clock.add(Duration.ofMillis(200)); Integer val1 = fuseableSubscriber.poll(); Integer val2 = fuseableSubscriber.poll(); assertThat(val1).isEqualTo(1); assertThat(val2).isNull(); //test meters Timer nextTimer = registry.find(METER_ON_NEXT_DELAY) .timer(); assertThat(nextTimer).as("no onNext delay meter for Mono").isNull(); }
Example 4
Source File: FluxMetricsFuseableTest.java From reactor-core with Apache License 2.0 | 5 votes |
@Test public void queuePollError() { //prepare registry with mock clock MockClock clock = new MockClock(); removeRegistry(); registry = new SimpleMeterRegistry(SimpleConfig.DEFAULT, clock); Metrics.globalRegistry.add(registry); AssertSubscriber<Integer> testSubscriber = AssertSubscriber.create(); FluxMetricsFuseable.MetricsFuseableSubscriber<Integer> fuseableSubscriber = new FluxMetricsFuseable.MetricsFuseableSubscriber<>(testSubscriber, registry, clock, "foo", Tags.empty()); FluxPeekFuseableTest.AssertQueueSubscription<Integer> testQueue = new FluxPeekFuseableTest.AssertQueueSubscription<>(); testQueue.setCompleteWithError(true); testQueue.offer(1); fuseableSubscriber.onSubscribe(testQueue); fuseableSubscriber.requestFusion(Fuseable.SYNC); clock.add(Duration.ofMillis(200)); Integer val1 = fuseableSubscriber.poll(); assertThat(val1).isEqualTo(1); clock.add(Duration.ofMillis(123)); assertThatIllegalStateException().isThrownBy(fuseableSubscriber::poll) .withMessage("AssertQueueSubscriber poll error"); //test meters Timer terminationTimer = registry.find(METER_FLOW_DURATION) .tags(Tags.of(TAG_ON_ERROR)) .timer(); assertThat(terminationTimer).isNotNull(); assertThat(terminationTimer.max(TimeUnit.MILLISECONDS)).as("terminate max delay").isEqualTo(323); }
Example 5
Source File: FluxMetricsFuseableTest.java From reactor-core with Apache License 2.0 | 5 votes |
@Test public void queuePollSyncTracksOnComplete() { //prepare registry with mock clock MockClock clock = new MockClock(); removeRegistry(); registry = new SimpleMeterRegistry(SimpleConfig.DEFAULT, clock); Metrics.globalRegistry.add(registry); AssertSubscriber<Integer> testSubscriber = AssertSubscriber.create(); FluxMetricsFuseable.MetricsFuseableSubscriber<Integer> fuseableSubscriber = new FluxMetricsFuseable.MetricsFuseableSubscriber<>(testSubscriber, registry, clock, "foo", Tags.empty()); Fuseable.QueueSubscription<Integer> testQueue = new FluxPeekFuseableTest.AssertQueueSubscription<>(); testQueue.offer(1); fuseableSubscriber.onSubscribe(testQueue); fuseableSubscriber.requestFusion(Fuseable.SYNC); clock.add(Duration.ofMillis(200)); Integer val1 = fuseableSubscriber.poll(); clock.add(Duration.ofMillis(123)); Integer val2 = fuseableSubscriber.poll(); assertThat(val1).isEqualTo(1); assertThat(val2).isNull(); //test meters Timer terminationTimer = registry.find(METER_FLOW_DURATION) .tags(Tags.of(TAG_ON_COMPLETE)) .timer(); assertThat(terminationTimer).isNotNull(); assertThat(terminationTimer.max(TimeUnit.MILLISECONDS)).as("terminate max delay").isEqualTo(323); }
Example 6
Source File: FluxMetricsFuseableTest.java From reactor-core with Apache License 2.0 | 5 votes |
@Test public void queuePollTracksOnNext() { //prepare registry with mock clock MockClock clock = new MockClock(); removeRegistry(); registry = new SimpleMeterRegistry(SimpleConfig.DEFAULT, clock); Metrics.globalRegistry.add(registry); AssertSubscriber<Integer> testSubscriber = AssertSubscriber.create(); FluxMetricsFuseable.MetricsFuseableSubscriber<Integer> fuseableSubscriber = new FluxMetricsFuseable.MetricsFuseableSubscriber<>(testSubscriber, registry, clock, "foo", Tags.empty()); Fuseable.QueueSubscription<Integer> testQueue = new FluxPeekFuseableTest.AssertQueueSubscription<>(); testQueue.offer(1); fuseableSubscriber.onSubscribe(testQueue); clock.add(Duration.ofMillis(200)); Integer val1 = fuseableSubscriber.poll(); Integer val2 = fuseableSubscriber.poll(); assertThat(val1).isEqualTo(1); assertThat(val2).isNull(); //test meters Timer nextTimer = registry.find(METER_ON_NEXT_DELAY) .timer(); assertThat(nextTimer).isNotNull(); assertThat(nextTimer.max(TimeUnit.MILLISECONDS)).as("onNext max delay").isEqualTo(200); }
Example 7
Source File: MonoMetricsFuseableTest.java From reactor-core with Apache License 2.0 | 5 votes |
@Test public void queuePollError() { //prepare registry with mock clock MockClock clock = new MockClock(); removeRegistry(); registry = new SimpleMeterRegistry(SimpleConfig.DEFAULT, clock); Metrics.globalRegistry.add(registry); AssertSubscriber<Integer> testSubscriber = AssertSubscriber.create(); MetricsFuseableSubscriber<Integer> fuseableSubscriber = new MetricsFuseableSubscriber<>(testSubscriber, registry, clock, Tags.empty()); FluxPeekFuseableTest.AssertQueueSubscription<Integer> testQueue = new FluxPeekFuseableTest.AssertQueueSubscription<>(); testQueue.setCompleteWithError(true); testQueue.offer(1); fuseableSubscriber.onSubscribe(testQueue); fuseableSubscriber.requestFusion(Fuseable.SYNC); clock.add(Duration.ofMillis(200)); Integer val1 = fuseableSubscriber.poll(); assertThat(val1).isEqualTo(1); clock.add(Duration.ofMillis(123)); assertThatIllegalStateException().isThrownBy(fuseableSubscriber::poll) .withMessage("AssertQueueSubscriber poll error"); //test meters Timer terminationTimer = registry.find(METER_FLOW_DURATION) .tags(Tags.of(TAG_ON_ERROR)) .timer(); assertThat(terminationTimer).isNotNull(); assertThat(terminationTimer.max(TimeUnit.MILLISECONDS)).as("terminate max delay").isEqualTo(323); }
Example 8
Source File: DistributionSummaryTest.java From micrometer with Apache License 2.0 | 5 votes |
@Test void histogramsInCumulativeMode() { MockClock clock = new MockClock(); MeterRegistry registry = new SimpleMeterRegistry(SimpleConfig.DEFAULT, clock); DistributionSummary summary = DistributionSummary.builder("my.summary") .serviceLevelObjectives(1.0) .register(registry); summary.record(1); // Histogram bucket counts DO roll over at the step interval, so decay. assertThat(summary.takeSnapshot().histogramCounts()).containsExactly(new CountAtBucket(1.0, 1)); clock.add(SimpleConfig.DEFAULT.step()); assertThat(summary.takeSnapshot().histogramCounts()).containsExactly(new CountAtBucket(1.0, 0)); }
Example 9
Source File: CompositeCounterTest.java From micrometer with Apache License 2.0 | 5 votes |
@Test @Issue("#119") void increment() { SimpleMeterRegistry simple = new SimpleMeterRegistry(SimpleConfig.DEFAULT, new MockClock()); CompositeMeterRegistry registry = new CompositeMeterRegistry(); registry.add(simple); registry.counter("counter").increment(2.0); assertThat(simple.get("counter").counter().count()).isEqualTo(2.0); }
Example 10
Source File: MetricsTest.java From micrometer with Apache License 2.0 | 5 votes |
@Test void metricCanBeCreatedBeforeStaticRegistryIsConfigured() { // doesn't blow up Counter counter = Metrics.counter("counter"); counter.increment(); SimpleMeterRegistry simple = new SimpleMeterRegistry(SimpleConfig.DEFAULT, new MockClock()); Metrics.addRegistry(simple); counter.increment(); assertThat(Metrics.globalRegistry.get("counter").counter().count()).isEqualTo(1.0); }
Example 11
Source File: UptimeMetricsTest.java From micrometer with Apache License 2.0 | 5 votes |
@Test void uptimeMetricsMock() { MeterRegistry registry = new SimpleMeterRegistry(SimpleConfig.DEFAULT, new MockClock()); RuntimeMXBean runtimeMXBean = mock(RuntimeMXBean.class); when(runtimeMXBean.getUptime()).thenReturn(1337L); when(runtimeMXBean.getStartTime()).thenReturn(4711L); new UptimeMetrics(runtimeMXBean, emptyList()).bindTo(registry); assertThat(registry.get("process.uptime").timeGauge().value()).isEqualTo(1.337); assertThat(registry.get("process.start.time").timeGauge().value()).isEqualTo(4.711); }
Example 12
Source File: UptimeMetricsTest.java From micrometer with Apache License 2.0 | 5 votes |
@Test void uptimeMetricsRuntime() { MeterRegistry registry = new SimpleMeterRegistry(SimpleConfig.DEFAULT, new MockClock()); new UptimeMetrics().bindTo(registry); registry.get("process.uptime").timeGauge(); registry.get("process.start.time").timeGauge(); }
Example 13
Source File: JettySslHandshakeMetricsTest.java From micrometer with Apache License 2.0 | 5 votes |
@BeforeEach void setup() { MockitoAnnotations.initMocks(this); when(engine.getSession()).thenReturn(session); registry = new SimpleMeterRegistry(SimpleConfig.DEFAULT, new MockClock()); Iterable<Tag> tags = Tags.of("id", "0"); sslHandshakeMetrics = new JettySslHandshakeMetrics(registry, tags); }
Example 14
Source File: TimedHandlerTest.java From micrometer with Apache License 2.0 | 5 votes |
@BeforeEach void setup() { this.registry = new SimpleMeterRegistry(SimpleConfig.DEFAULT, new MockClock()); this.timedHandler = new TimedHandler(registry, Tags.empty()); this.server = new Server(); this.connector = new LocalConnector(server); server.addConnector(connector); latchHandler = new LatchHandler(); server.setHandler(latchHandler); latchHandler.setHandler(timedHandler); }
Example 15
Source File: JettyServerThreadPoolMetricsTest.java From micrometer with Apache License 2.0 | 5 votes |
@BeforeEach void setup() throws Exception { registry = new SimpleMeterRegistry(SimpleConfig.DEFAULT, new MockClock()); Iterable<Tag> tags = Collections.singletonList(Tag.of("id", "0")); QueuedThreadPool threadPool = new InstrumentedQueuedThreadPool(registry, tags); threadPool.setMinThreads(32); threadPool.setMaxThreads(100); server = new Server(threadPool); ServerConnector connector = new ServerConnector(server); server.setConnectors(new Connector[] { connector }); server.start(); }
Example 16
Source File: MeteredExecutorServiceWrapperTest.java From che with Eclipse Public License 2.0 | 4 votes |
@BeforeMethod public void setup() { registry = new SimpleMeterRegistry(SimpleConfig.DEFAULT, new MockClock()); executorServiceWrapper = new MeteredExecutorServiceWrapper(registry); }
Example 17
Source File: CountedThreadFactoryTest.java From che with Eclipse Public License 2.0 | 4 votes |
@BeforeMethod public void setup() { registry = new SimpleMeterRegistry(SimpleConfig.DEFAULT, new MockClock()); }
Example 18
Source File: CountedRejectedExecutionHandlerTest.java From che with Eclipse Public License 2.0 | 4 votes |
@BeforeMethod public void setup() { registry = new SimpleMeterRegistry(SimpleConfig.DEFAULT, new MockClock()); }
Example 19
Source File: MicrometerHttpClientInterceptorTest.java From micrometer with Apache License 2.0 | 4 votes |
@BeforeEach void setup() { registry = new SimpleMeterRegistry(SimpleConfig.DEFAULT, new MockClock()); }
Example 20
Source File: MolgenisTimedAspectTest.java From molgenis with GNU Lesser General Public License v3.0 | 4 votes |
@BeforeEach void beforeMethod() { meterRegistry = new SimpleMeterRegistry(SimpleConfig.DEFAULT, clock); timedAspect = new MolgenisTimedAspect(meterRegistry); }