The following Resilience4j components are instrumented:
- CircuitBreaker
- Bulkhead
- RateLimiter
- Retry
- TimeLimiter
To install:
- Download the latest release jar files.
- In the New Relic Java directory (the one containing newrelic.jar), create a directory named extensions if it does not already exist.
- Copy the downloaded jars into the extensions directory.
- Restart the application.
This module also collects and reports metrics from Resilience4j components (Circuit Breaker, Bulkhead, ThreadPool Bulkhead, Rate Limiter, and Retry) using New Relic Agent APIs. The metrics are periodically collected and sent to New Relic Insights as custom events.
To enable (default: true) /disable specific metrics collection and set the polling interval ( default: 1 minute ) , update the newrelic.yml
configuration file with the following parameters:
Resilience4j:
metrics:
# Circuit Breaker Metrics
circuitbreaker:
enabled: true
intervalminutes: 5
# Bulkhead Metrics
bulkhead:
enabled: true
intervalminutes: 5
# ThreadPool Bulkhead Metrics
threadpoolbulkhead:
enabled: true
intervalminutes: 5
# Rate Limiter Metrics
ratelimiter:
enabled: true
intervalminutes: 5
# Retry Metrics
retry:
enabled: true
intervalminutes: 5
These settings should be added to your newrelic.yml
configuration file. This configuration enables metrics collection for each Resilience4j component and sets the polling interval to 5 minutes. Adjust the intervalminutes
value as needed to set a different polling interval.
Enable Metrics Collection: Set the appropriate flags in the newrelic.yml file to enable metrics collection for the desired Resilience4j components.
Set Polling Interval: Configure the polling interval (in minutes) for each component's metrics collection.
Run the Application: Start your application. The metrics will be collected at the specified intervals and sent to New Relic Insights as custom events.
Monitor Metrics in New Relic: Log in to your New Relic account and navigate to the Insights section to view the custom events for the metrics collected.
This setup helps you monitor the performance and reliability of your Resilience4j components in real-time using New Relic's powerful monitoring and alerting capabilities.
The metrics collected from each Resilience4j pattern are reported as custom events to New Relic Insights. Below are the custom event tables where you can find the reported metrics:
- Custom Event Table Name:
CircuitBreakerMetrics
- Metrics:
Name
FailureRate
BufferedCalls
Failed
NotPermittedCalls
SlowCalls
SuccessfulCalls
SlowCallRate
SlowFailedCalls
SlowSuccessfulCalls
- Custom Event Table Name:
BulkheadMetrics
- Metrics:
Name
AvailableConcurrentCalls
MaxAllowedConcurrentCalls
- Custom Event Table Name:
ThreadPoolBulkheadMetrics
- Metrics:
Name
CoreThreadPoolSize
ThreadPoolSize
MaximumThreadPoolSize
QueueDepth
RemainingQueueCapacity
QueueCapacity
- Custom Event Table Name:
RetryMetrics
- Metrics:
Name
NumberOfSuccessfulCallsWithoutRetryAttempt
NumberOfFailedCallsWithoutRetryAttempt
NumberOfSuccessfulCallsWithRetryAttempt
NumberOfFailedCallsWithRetryAttempt
- Custom Event Table Name:
RateLimiterMetrics
- Metrics:
Name
AvailablePermissions
NumberOfWaitingThreads
-
Log in to New Relic: Access your New Relic account.
-
Query Custom Events: Use the following NRQL (New Relic Query Language) queries to access the custom events:
-
ThreadPoolBulkheadMetrics:
SELECT * FROM ThreadPoolBulkheadMetrics
-
RetryMetrics:
SELECT * FROM RetryMetrics
-
CircuitBreakerMetrics:
SELECT * FROM CircuitBreakerMetrics
-
RateLimiterMetrics:
SELECT * FROM RateLimiterMetrics
-
BulkheadMetrics:
SELECT * FROM BulkheadMetrics
-
These queries will display the custom events along with the collected metrics, allowing you to monitor and analyze the performance and reliability of your Resilience4j components in real-time.
Once installed, the instrumentation will track transactions through the Resilience4j components.
Building the extension requires that Gradle is installed. To build the extension jars from source, follow these steps:
To build a single extension with name extension, do the following:
- Set an environment variable NEW_RELIC_EXTENSIONS_DIR and set its value to the directory where you want the jar file built.
- Run the command: ./gradlew extension:clean extension:install
To build all extensions, do the following:
- Set an environment variable NEW_RELIC_EXTENSIONS_DIR and set its value to the directory where you want the jar file built.
- Run the command: ./gradlew clean install
New Relic has open-sourced this project. This project is provided AS-IS WITHOUT WARRANTY OR DEDICATED SUPPORT. Issues and contributions should be reported to the project here on GitHub.
We encourage you to bring your experiences and questions to the Explorers Hub where our community members collaborate on solutions and new ideas.
We encourage your contributions to improve [Project Name]! Keep in mind when you submit your pull request, you'll need to sign the CLA via the click-through using CLA-Assistant. You only have to sign the CLA one time per project. If you have any questions, or to execute our corporate CLA, required if your contribution is on behalf of a company, please drop us an email at opensource@newrelic.com.
A note about vulnerabilities
As noted in our security policy, New Relic is committed to the privacy and security of our customers and their data. We believe that providing coordinated disclosure by security researchers and engaging with the security community are important means to achieve our security goals.
If you believe you have found a security vulnerability in this project or any of New Relic's products or websites, we welcome and greatly appreciate you reporting it to New Relic through HackerOne.
New Relic Java Instrumentation for resilience4 is licensed under the Apache 2.0 License.
[If applicable: [Project Name] also uses source code from third-party libraries. You can find full details on which libraries are used and the terms under which they are licensed in the third-party notices document.]