Skip to content

fix: record the credentials request metric with the token request's attributes - #410

Open
cvas22 wants to merge 1 commit into
openfga:mainfrom
cvas22:fix/149-credentials-request-attributes
Open

cvas22 wants to merge 1 commit into
openfga:mainfrom
cvas22:fix/149-credentials-request-attributes

Conversation

@cvas22

@cvas22 cvas22 commented Nov 5, 2026

Copy link
Copy Markdown

Description

OAuth2Client recorded the fga-client.credentials.request counter with a hard-coded empty attributes map (#149, #208), so the metric had none of the configured attributes: no host, URL, method, status code or resend count.

HttpRequestAttempt already collects those attributes for the token request, but they never made it back to getAccessToken(), where the counter was recorded. The counter is now recorded in exchangeToken(), right after the token request succeeds, with attempt.getTelemetryAttributes(). As before, it's recorded once per successful exchange, and the attribute filtering from the telemetry configuration still applies in Metrics.

Fixes #149
Fixes #208

Testing

New credentialsRequestMetricHasTheTokenRequestAttributes in OAuth2ClientTest: it intercepts the Metrics instance with Mockito's mockConstruction, exchanges a token, and checks that credentialsRequest is called once with the token request's http.host, http.request.method and http.response.status_code. That avoids adding the OpenTelemetry SDK as a test dependency.

I haven't run the Gradle build locally, so I'm relying on CI for compilation and the test run.

…ttributes

OAuth2Client recorded fga-client.credentials.request with a hard-coded
empty attributes map, so the metric had no host, status code or other
attributes. Record it in exchangeToken with the attributes that
HttpRequestAttempt collected for the token request.

Fixes openfga#149
Fixes openfga#208

Signed-off-by: Srinivas Chippagiri <cvas22@gmail.com>
@cvas22
cvas22 requested a review from a team as a code owner November 5, 2026 09:39
@coderabbitai

coderabbitai Bot commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 17 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 77500185-ab49-49fd-94aa-b605c7a45358
Commits

Reviewing files that changed from the base of the PR and between bc745c9 and c1774d9.

Files selected for processing: 2

  • src/main/java/dev/openfga/sdk/api/auth/OAuth2Client.java
  • src/test/java/dev/openfga/sdk/api/auth/OAuth2ClientTest.java
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

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 this pull request may close these issues.

Empty Telemetry Attributes in OAuth2Client telemetry attributes not sent on token exchange request

1 participant