forked from ReactiveX/RxJava
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue ReactiveX#354: Use new metrics collectors for spring-boot and s…
…pring-boot 2 (ReactiveX#382)
- Loading branch information
Showing
11 changed files
with
363 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
84 changes: 84 additions & 0 deletions
84
...ence4j-spring-boot/src/test/java/io/github/resilience4j/MetricsAutoConfigurationTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
/* | ||
* Copyright 2019 Yevhenii Voievodin | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package io.github.resilience4j; | ||
|
||
import io.github.resilience4j.prometheus.BulkheadExports; | ||
import io.github.resilience4j.prometheus.CircuitBreakerExports; | ||
import io.github.resilience4j.prometheus.RateLimiterExports; | ||
import io.github.resilience4j.prometheus.collectors.BulkheadMetricsCollector; | ||
import io.github.resilience4j.prometheus.collectors.CircuitBreakerMetricsCollector; | ||
import io.github.resilience4j.prometheus.collectors.RateLimiterMetricsCollector; | ||
import io.github.resilience4j.service.test.TestApplication; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
@RunWith(SpringJUnit4ClassRunner.class) | ||
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = TestApplication.class) | ||
public class MetricsAutoConfigurationTest { | ||
|
||
@Autowired(required = false) | ||
CircuitBreakerExports circuitBreakerExports; | ||
|
||
@Autowired(required = false) | ||
BulkheadExports bulkheadExports; | ||
|
||
@Autowired(required = false) | ||
RateLimiterExports rateLimiterExports; | ||
|
||
@Autowired(required = false) | ||
CircuitBreakerMetricsCollector circuitBreakerMetricsCollector; | ||
|
||
@Autowired(required = false) | ||
BulkheadMetricsCollector bulkheadMetricsCollector; | ||
|
||
@Autowired(required = false) | ||
RateLimiterMetricsCollector rateLimiterMetricsCollector; | ||
|
||
@Test | ||
public void legacyCircuitBreakerCollectorIsNotBound() { | ||
assertThat(circuitBreakerExports).isNull(); | ||
} | ||
|
||
@Test | ||
public void legacyBulkheadCollectorIsNotBound() { | ||
assertThat(bulkheadExports).isNull(); | ||
} | ||
|
||
@Test | ||
public void legacyRateLimiterCollectorIsNotBound() { | ||
assertThat(bulkheadExports).isNull(); | ||
} | ||
|
||
@Test | ||
public void newCircuitBreakerCollectorIsBound() { | ||
assertThat(circuitBreakerMetricsCollector).isNotNull(); | ||
} | ||
|
||
@Test | ||
public void newBulkheadCollectorIsBound() { | ||
assertThat(bulkheadMetricsCollector).isNotNull(); | ||
} | ||
|
||
@Test | ||
public void newRateLimiterCollectorIsBound() { | ||
assertThat(rateLimiterMetricsCollector).isNotNull(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
...n/java/io/github/resilience4j/retry/autoconfigure/AsyncRetryMetricsAutoConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
* Copyright 2019 Yevhenii Voievodin | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package io.github.resilience4j.retry.autoconfigure; | ||
|
||
import io.github.resilience4j.micrometer.AsyncRetryMetrics; | ||
import io.github.resilience4j.micrometer.tagged.TaggedAsyncRetryMetrics; | ||
import io.github.resilience4j.retry.AsyncRetryRegistry; | ||
import org.springframework.boot.actuate.autoconfigure.metrics.MetricsAutoConfiguration; | ||
import org.springframework.boot.autoconfigure.AutoConfigureAfter; | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
@Configuration | ||
@ConditionalOnClass(MetricsAutoConfiguration.class) | ||
@AutoConfigureAfter(value = {RetryAutoConfiguration.class, MetricsAutoConfiguration.class}) | ||
@ConditionalOnProperty(value = "resilience4j.async_retry.metrics.enabled", matchIfMissing = true) | ||
public class AsyncRetryMetricsAutoConfiguration { | ||
|
||
@Bean | ||
@ConditionalOnProperty(value = "resilience4j.async_retry.metrics.use_legacy_binder", havingValue = "true") | ||
public AsyncRetryMetrics registerLegacyAsyncRetryMetrics(AsyncRetryRegistry asyncRetryRegistry) { | ||
return AsyncRetryMetrics.ofRetryRegistry(asyncRetryRegistry); | ||
} | ||
|
||
@Bean | ||
@ConditionalOnProperty( | ||
value = "resilience4j.async_retry.metrics.use_legacy_binder", | ||
havingValue = "false", | ||
matchIfMissing = true | ||
) | ||
public TaggedAsyncRetryMetrics registerAsyncRetryMetrics(AsyncRetryRegistry asyncRetryRegistry) { | ||
return TaggedAsyncRetryMetrics.ofAsyncRetryRegistry(asyncRetryRegistry); | ||
} | ||
} |
Oops, something went wrong.