Repository navigation
Conversation
…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>
|
No actionable comments were generated in the recent review. WalkthroughOAuth2Client now records credential-request metrics with telemetry attributes from the successful token-exchange HTTP attempt. A new test checks the host, response status, and request method attributes. ChangesCredential request metrics
Estimated code review effort: 2 (Simple) | ~10 minutes Change: Bug fix · Severity of issue fixed: Low Possibly related PRs
Suggested reviewers: Merge Risk:
|
…equest-attributes # Conflicts: # src/test/java/dev/openfga/sdk/api/auth/OAuth2ClientTest.java
|
@SoulPancake friendly ping on this one, thx |
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues block the credential-request telemetry update.
No open issues 🎉
What changed in this PR
Fixes credential-request telemetry for issues #149 and #208 by recording the counter with attributes collected from the token HTTP request instead of an empty map.
Changes:
- Moves metric recording into
exchangeToken(), retaining one recording per successful exchange. - Adds a regression test verifying the counter is called once with the token request’s host, method, and response status.
| File | Description |
|---|---|
| src/test/java/dev/openfga/sdk/api/auth/OAuth2ClientTest.java | Tests credential-request metric attributes using mocked Metrics construction. |
| src/main/java/dev/openfga/sdk/api/auth/OAuth2Client.java | Records the credentials counter with the HTTP attempt’s telemetry attributes. |
Review effort: Balanced
Description
OAuth2Clientrecorded thefga-client.credentials.requestcounter 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.HttpRequestAttemptalready collects those attributes for the token request, but they never made it back togetAccessToken(), where the counter was recorded. The counter is now recorded inexchangeToken(), right after the token request succeeds, withattempt.getTelemetryAttributes(). As before, it's recorded once per successful exchange, and the attribute filtering from the telemetry configuration still applies inMetrics.Fixes #149
Fixes #208
Testing
New
credentialsRequestMetricHasTheTokenRequestAttributesinOAuth2ClientTest: it intercepts theMetricsinstance with Mockito'smockConstruction, exchanges a token, and checks thatcredentialsRequestis called once with the token request'shttp.host,http.request.methodandhttp.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.
Summary by CodeRabbit