Skip to content

Commit 16ba681

Browse files
committed
Updated documentation.
1 parent b8e4076 commit 16ba681

File tree

4 files changed

+220
-220
lines changed

4 files changed

+220
-220
lines changed

resilience4j-documentation/src/docs/asciidoc/addon_guides/micrometer.adoc

Lines changed: 4 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,11 @@ final Bulkhead foo = bulkheadRegistry.bulkhead("foo");
1616
final Bulkhead boo = bulkheadRegistry.bulkhead("boo");
1717

1818
// Register all bulkheads at once
19-
BulkheadMetrics bulkheadMetrics = BulkheadMetrics.ofBulkheadRegistry(bulkheadRegistry);
20-
bulkheadMetrics.bindTo(meterRegistry);
21-
22-
// Or for tag based metrics
2319
TaggedBulkheadMetrics.ofBulkheadRegistry(bulkheadRegistry).bindTo(meterRegistry);
2420
--
2521

2622
For each bulkhead this registry will export:
2723

28-
* `available_concurrent_calls` - instantaneous read of the number of currently available concurrent calls `[int]`
29-
* `max_allowed_concurrent_calls` - maximum number of allowed concurrent calls `[int]`
30-
31-
Tag based metrics:
32-
3324
* `resilience4j_bulkhead_available_concurrent_calls{name="name of bulkhead"}` - number of available concurrent calls
3425
* `resilience4j_bulkhead_max_allowed_concurrent_calls{name="name of bulkhead"}` - maximum number of allowed concurrent calls
3526

@@ -42,24 +33,11 @@ final CircuitBreaker foo = circuitBreakerRegistry.circuitBreaker("foo");
4233
final CircuitBreaker boo = circuitBreakerRegistry.circuitBreaker("boo");
4334

4435
// Register all circuit breakers at once
45-
CircuitBreakerMetrics circuitBreakerMetrics = CircuitBreakerMetrics.ofCircuitBreakerRegistry(circuitBreakerRegistry);
46-
circuitBreakerMetrics.bindTo(meterRegistry);
47-
48-
// Or for tag based metrics
4936
TaggedCircuitBreakerMetrics.ofCircuitBreakerRegistry(circuitBreakerRegistry).bindTo(meterRegistry);
5037
--
5138

5239
For each circuit breaker this registry will export:
5340

54-
* `state` - instantaneous read of the current state where 0-CLOSED, 1-OPEN, 2-HALF-OPEN `[int]`
55-
* `successful` - current number of successful calls `[int]`
56-
* `failed` - current number of failed calls `[int]`
57-
* `buffered` - current number of buffered calls `[int]`
58-
* `buffered_max` - maximum number of buffered calls `[int]`
59-
* `not_permitted` - current number of not permitted calls `[int]`
60-
61-
Tag based metrics:
62-
6341
* `resilience4j_circuitbreaker_state{name="name of circuitbreaker"}` - the state of the circuit breaker where 0-CLOSED, 1-OPEN, 2-HALF-OPEN
6442
* `resilience4j_circuitbreaker_calls{name="name of circuitbreaker", kind="one of the values below"}` - the number of calls of a certain kind
6543
- `successful` - indicates successful calls
@@ -76,20 +54,11 @@ final RateLimiterRegistry rateLimiterRegistry = RateLimiterRegistry.ofDefaults()
7654
final RateLimiter rateLimiter = rateLimiterRegistry.rateLimiter("testLimit");
7755

7856
// Register rate limiters at once
79-
RateLimiterMetrics rateLimiterMetrics = RateLimiterMetrics.ofRateLimiterRegistry(rateLimiterRegistry);
80-
rateLimiterMetrics.bindTo(meterRegistry);
81-
82-
// Or for tag based metrics
8357
TaggedRateLimiterMetrics.ofRateLimiterRegistry(rateLimiterRegistry).bindTo(meterRegistry);
8458
--
8559

8660
For each rate limiter this registry will export:
8761

88-
* `available_permissions` - current number of available permissions `[int]`
89-
* `number_of_waiting_threads` - current number of threads waiting for permission `[int]`
90-
91-
Tag based metrics:
92-
9362
* `resilience4j_ratelimiter_available_permissions{name="name of ratelimiter"}` - the number of available permissions
9463
* `resilience4j_ratelimiter_waiting_threads{name="name of ratelimiter"}` - the number of threads waiting for permission
9564

@@ -102,26 +71,15 @@ final RetryRegistry retryRegistry = RetryRegistry.ofDefaults();
10271
final Retry retry = retryRegistry.retry("testLimit");
10372

10473
// Register all retries at once
105-
RetryMetrics retryMetrics = RetryMetrics.ofRetryRegistry(retryRegistry);
106-
retryMetrics.bindTo(meterRegistry);
107-
108-
// Or for tag baed metrics
10974
TaggedRetryMetrics.ofRetryRegistry(retryRegistry).bindTo(meterRegistry);
11075
--
11176

11277
For each retry this registry will export:
11378

114-
* `successful_calls_without_retry` - the number of successful calls without a retry attempt `[long]`
115-
* `successful_calls_with_retry` - the number of successful calls after a retry attempt `[long]`
116-
* `failed_calls_without_retry` - the number of failed calls without a retry attempt `[long]`
117-
* `failed_calls_with_retry` - the number of failed calls after all retry attempts `[long]`
118-
119-
Tag based metrics:
120-
12179
* `resilience4j_retry_calls{name="retry name", kind="one of the values below"}` - the number of calls of a certain kind
122-
- `successful_without_retry` - indicates successful calls without retry
123-
- `successful_with_retry` - indicates successful calls with retry
124-
- `failed_without_retry` - indicates failed calls without retry
125-
- `failed_with_retry` - indicates failed calls with retry
80+
- `successful_without_retry` - indicates successful calls without retry
81+
- `successful_with_retry` - indicates successful calls with retry
82+
- `failed_without_retry` - indicates failed calls without retry
83+
- `failed_with_retry` - indicates failed calls with retry
12684

12785
Note the same set of metrics is exposed for async retry, metric name is `resilience4j_async_retry_calls`.

resilience4j-documentation/src/docs/asciidoc/addon_guides/prometheus.adoc

Lines changed: 2 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -4,56 +4,7 @@
44

55
Integration with https://github.com/prometheus/client_java[Prometheus simple client]
66

7-
Module provides exporters for `CircuitBreaker`, `RateLimiter` and `Bulkhead` metrics.
8-
Every metric has `name` label indicating the relation to certain object, object category
9-
such as `bulkhead` is inlined to the metric name, so that the combination of metric name + `name` label
10-
uniquely identifies metric per backend. For example:
11-
12-
```
13-
resilience4j_bulkhead_available_concurrent_calls{name="Backend1"}
14-
resilience4j_circuitbreaker_buffered_calls{name="Backend1"}
15-
resilience4j_ratelimiter_waiting_threads{name=Backend1"}
16-
```
17-
18-
For every `CircuitBreaker` the library exports the following metrics:
19-
20-
1. `resilience4j_circuitbreaker_state` - the state of the circuit breaker, possible values:
21-
22-
- 0 - CLOSED
23-
- 1 - OPEN
24-
- 2 - HALF_OPEN
25-
26-
2. `resilience4j_circuitbreaker_calls` - the number of recorded calls,
27-
the additional `kind` label indicates type of calls being recorded, the possible
28-
`kind` values are `successful`, `failed` or `not_permitted`.
29-
30-
3. `resilience4j_circuitbreaker_buffered_calls` - the number of buffered calls
31-
32-
4. `resilience4j_circuitbreaker_max_buffered_calls` - the maximum number of buffered calls
33-
34-
For every `RateLimiter` the library exports the following metrics:
35-
36-
1. `resilience4j_ratelimiter_available_permissions` - the number of available permissions
37-
2. `resilience4j_ratelimiter_waiting_threads` - the number of waiting threads
38-
39-
For every `Bulkhead` the library exports the following metrics:
40-
41-
1. `resilience4j_bulkhead_available_concurrent_calls` - the number of available concurrent calls
42-
2. `resilience4j_bulkhead_max_allowed_concurrent_calls` - the maximum number of allowed concurrent calls
43-
44-
45-
This module also provides `CallMeter` -- a composite metric to measure single call/request metrics such as:
46-
- execution time distribution,
47-
- number of attempts and
48-
- number of failures.
49-
50-
It is implemented in Prometheus simple client's style, supports labels and produces histogram and counter metrics.
51-
52-
Usage examples provided bellow in this section.
53-
54-
==== Dashboard Example
55-
56-
image::images/prometheus-dashboard.png[Circuit Breaker Dashboard Example]
7+
This add-on provides Prometheus collectors for `CircuitBreaker`, `RateLimiter` and `Bulkhead` metrics.
578

589
==== Usage
5910

@@ -100,44 +51,4 @@ final Bulkhead boo = bulkheadRegistry.bulkhead("boo");
10051

10152
// Registering metrics in prometeus CollectorRegistry
10253
collectorRegistry.register(BulkheadMetricsCollector.ofBulkheadRegistry(rateLimiterRegistry));
103-
--
104-
105-
Every collector exposes more methods for binding corresponding objects, for example,
106-
you can use suppliers, collections or even collect metrics for a single object.
107-
108-
===== Call Meter
109-
110-
Simple example without labels
111-
112-
[source,java]
113-
--
114-
final CollectorRegistry registry = new CollectorRegistry();
115-
116-
final CallMeter meter = CallMeter.of("foo_call", "Foo call help", registry);
117-
118-
CallMeter.decorateCompletionStageSupplier(meter, () -> supplyAsync(() -> { /* ... */ }));
119-
--
120-
121-
Advanced example with labels
122-
123-
[source,java]
124-
--
125-
final CollectorRegistry registry = new CollectorRegistry();
126-
127-
final CallMeter meter = CallMeter
128-
.builder()
129-
.name("foo_call")
130-
.help("Foo call help")
131-
.labelNames("label_1")
132-
.build()
133-
.register(registry);
134-
135-
meter.labels("boo").executeRunnable(() -> { /* ... */ });
136-
137-
CallMeter.decorateCompletionStageSupplier(
138-
meter.labels("baz"),
139-
() -> supplyAsync(() -> { /* ... */ })
140-
);
141-
142-
--
143-
54+
--

resilience4j-documentation/src/docs/asciidoc/addon_guides/springboot.adoc

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
==== Gradle
44

5-
Add the Spring Boot Starter of Resilience4j to your compile dependency:
5+
Add the Spring Boot Starter of Resilience4j to your compile dependency.
6+
You also need Spring Boot Actuator and Spring Boot AOP.
67

78
[source,groovy, subs="attributes"]
89
----
@@ -14,40 +15,22 @@ repositories {
1415
1516
dependencies {
1617
compile('io.github.resilience4j:resilience4j-spring-boot:{release-version}')
18+
compile('org.springframework.boot:spring-boot-starter-actuator')
19+
compile('org.springframework.boot:spring-boot-starter-aop')
1720
}
1821
----
1922

2023
==== Supported Types by Spring boot starter resilience aspects
2124

22-
Rate limiter , Retry , Circuit breaker and Bulkhead now support Synchronous return types ,CompletableFutures , RxJava2 types and Reactor types .
25+
RateLimiter, Retry, CircuitBreaker and Bulkhead annotations support synchronous return types, asynchronous types like CompletableFutures and reactive types like RxJava2 and Reactor.
2326

2427
==== Monitoring
2528

2629
Spring Boot Actuator health information can be used to check the status of your running application.
2730
It is often used by monitoring software to alert someone if a production system has serious issues.
2831

29-
==== Retry
30-
When you enable retry, metrics are automatically published on the metrics endpoint.
31-
32-
For example:
33-
34-
[source,json]
35-
----
36-
{
37-
"names": [
38-
"resilience4j.retry.backendA.failedCallsWithoutRetry",
39-
"resilience4j.retry.backendA.failedCallsWithRetry",
40-
"resilience4j.retry.backendA.successCalls",
41-
"resilience4j.retry.backendA.successCallsWithRetry"
42-
]
43-
}
44-
----
45-
46-
When you want to publish Retry/AsyncRetry endpoints on the Prometheus endpoint, you have to add the dependency `io.micrometer:micrometer-registry-prometheus`.
47-
and you have same metrics exposed there , check circuit breaker below for more information about the example.
48-
4932
==== CircuitBreaker
50-
This demo publishes the status and metrics of all CircuitBreakers via a custom `CircuitBreakerHealthIndicator`.
33+
The starter publishes the status and metrics of all CircuitBreakers via a custom `CircuitBreakerHealthIndicator`.
5134
A closed CircuitBreaker state is mapped to UP, an open state to DOWN and a half-open state to UNKNOWN.
5235

5336
For example:
@@ -123,8 +106,28 @@ resilience4j_circuitbreaker_states{name="backendA",state="open",} 0.0
123106
resilience4j_circuitbreaker_states{name="backendA",state="half_open",} 0.0
124107
----
125108

109+
==== Retry
110+
When you enable retry, metrics are automatically published on the metrics endpoint.
111+
112+
For example:
113+
114+
[source,json]
115+
----
116+
{
117+
"names": [
118+
"resilience4j.retry.backendA.failedCallsWithoutRetry",
119+
"resilience4j.retry.backendA.failedCallsWithRetry",
120+
"resilience4j.retry.backendA.successCalls",
121+
"resilience4j.retry.backendA.successCallsWithRetry"
122+
]
123+
}
124+
----
125+
126+
When you want to publish Retry/AsyncRetry endpoints on the Prometheus endpoint, you have to add the dependency `io.micrometer:micrometer-registry-prometheus`.
127+
and you have same metrics exposed there , check circuit breaker below for more information about the example.
128+
126129
==== RateLimiter
127-
This demo publishes the status and metrics of all RateLimiter via a custom `RateLimiterHealthIndicator`.
130+
The starter publishes the status and metrics of all RateLimiter via a custom `RateLimiterHealthIndicator`.
128131
RateLimiterHealthIndicator changes its state DOWN only if there is some permission waiting threads
129132
and they won't be able to unblock until timeout.
130133

0 commit comments

Comments
 (0)