Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reusable Fault Tolerance: Automatically Set Description for Metrics to Method Names #1060

Closed
AndreasPetersen opened this issue Oct 15, 2024 · 2 comments · Fixed by #1061
Closed
Milestone

Comments

@AndreasPetersen
Copy link

When using reusable fault tolerance, I would like the description of the FaultTolerance instance to be automatically bsed on the method name. Consider:

@ApplicationScoped
public class PreconfiguredFaultTolerance {
    @Produces
    @Identifier("my-fault-tolerance")
    public static final FaultTolerance<String> FT = FaultTolerance.<String>create()
            .withRetry().maxRetries(2).done()
            .withFallback().handler(() -> "fallback").done()
            .build();
}

and

@ApplicationScoped
@ApplyFaultTolerance("my-fault-tolerance")
public class MyService {
    public String doSomething() {
        ...
    }

    public String doSomethingElse() {
        ...
    }
}

The generated metrics for my-fault-tolerance will be an UUID as per the documentation. I could add withDescription("my-fault-tolerance") to my-fault-tolerance, but then I will not be able to distinguish between the doSomething and doSomethingElse methods.

If instead I used the regular annotations, the method attribute of the metrics is set to the names of the methods as expected.

@Ladicek
Copy link
Contributor

Ladicek commented Oct 15, 2024

That sounds natural, but it goes directly against the current design. A single FaultTolerance object has a single MeteredOperation and single MetricsRecorder, which means there's a single "method name" (the FT description). It doesn't even know it's used via @ApplyFaultTolerance.

We might be able to do something on the @ApplyFaultTolerance level to override the "method name", need to check.

But currently, this works as designed.

@AndreasPetersen
Copy link
Author

Wow, amazing that you managed to fix this so fast! Thanks a lot!

@Ladicek Ladicek added this to the 6.6.0 milestone Oct 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants