Skip to content

Conversation

@ygree
Copy link
Contributor

@ygree ygree commented Sep 13, 2025

What Does This Do

This instruments Resilience4j 2.x to make it visible in traces.
It introduces spans for Resilience4j function decorators, as well as tags representing circuit breaker and retry configuration and metrics snapshots.
It's targeting circuit breaker, retry, and fallback decorators in the core and reactor modules.

Motivation

Provide visibility of circuit breaker and retry scopes and attributes in traces.

Additional Notes

Resilience4J spans are not measured by default, but this can be enabled explicitly by DD_RESILIENCE4J_MEASURED_ENABLED.
The circuit breaker and retry snapshot metric tags can be enabled with DD_RESILIENCE4J_TAG_METRICS_ENABLED.

Example

  1. The resilience4j span scope makes the retry attempts visible. The span also includes the Resilience4j retry properties along with the metrics snapshot.
image
  1. The Resilience4j span represents a stack of decorators, which currently includes circuit breakers, retries, and fallbacks. The span includes the circuit breaker state, as well as other circuit breaker and retry properties, and snapshot metrics (when enabled with DD_RESILIENCE4J_TAG_METRICS_ENABLED).
image

Contributor Checklist

Jira ticket: OLDAIDM-540

ygree added 30 commits June 11, 2025 16:00
Clean up CircuitBreakerInstrumentation
…ion.

Fix muzzle check by excluding helper classes referencing an instrumented interface.
Extracted Resilience4jInstrumentation.
Minimize number of necessary wrapper.
Get rid of the muzzle problem caused by a wrapper extending an instrumented interface.
Pass the context holder at creation time.

TODO: Implement this for all types of combinators and eliminate reliance on the active span.
Pass the context holder at creation time.

TODO: Implement this for tracedCompletionStage
Pass the context holder at creation time.
…tead of trying to build a common context holder at a decorator construction time. This should simplify the solution and make it less prone to missing instrumentation and easier to apply to other integration like reactor, javarx, etc.
@ygree ygree requested a review from a team as a code owner September 22, 2025 19:03
@github-actions
Copy link
Contributor

github-actions bot commented Sep 22, 2025

Hi! 👋 Thanks for your pull request! 🎉

To help us review it, please make sure to:

  • Add at least one type, and one component or instrumentation label to the pull request

If you need help, please check our contributing guidelines.

@ygree ygree changed the title Resilience4j 2.x Resilience4j 2.x initial instrumentation Sep 22, 2025
@ygree ygree changed the title Resilience4j 2.x initial instrumentation Resilience4j 2.x Sep 22, 2025
@ygree ygree added inst: others All other instrumentations type: feature request labels Sep 23, 2025
@ygree ygree force-pushed the ygree/resilience4j branch from cdb0f47 to 5b2e1ab Compare September 24, 2025 18:22
@ygree ygree requested a review from amarziali September 24, 2025 19:21
@ygree
Copy link
Contributor Author

ygree commented Sep 24, 2025

@amarziali Thanks for your suggestions! I've made the necessary improvements.

Copy link
Contributor

@amarziali amarziali left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for having improved the library support with the resilience4j instrumentations. The changes looks good. I left few comments especially around strings that could be statically declared as constants


@Override
protected CharSequence spanType() {
return null;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

other instrumentations create a span type. why this is not doing the same?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm leaving it null because I don't see a suitable candidate among InternalSpanTypes. This is the default for many instrumentations and is treated as a custom span type. Do you think I need to be more specific in this case? I'm asking because I'm not sure how it's being used. If I'm not mistaken, OTel doesn't seem to have this concept.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can create your own span type if needed. It depends than if that tagging is used internally for something. i.e. you can use it for a particular display in the future. If not you can leave blank

@ygree ygree merged commit e9f8dc8 into master Sep 29, 2025
541 checks passed
@ygree ygree deleted the ygree/resilience4j branch September 29, 2025 15:11
@github-actions github-actions bot added this to the 1.54.0 milestone Sep 29, 2025
@ygree ygree changed the title Resilience4j 2.x Resilience4j 2+ Oct 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

inst: others All other instrumentations type: feature request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants