python-sdk icon indicating copy to clipboard operation
python-sdk copied to clipboard

feat(OpenTelemetry): add per-HTTP request counter metric

Open evansims opened this issue 1 year ago • 1 comments

Description

Added:

  • Adds a per-HTTP request counter metric, fga-client.request. It is disabled by default.

Changed:

  • Method signature on credentialsRequest now uses 1 as the default parameter value.
  • Changed default unit type in TelemetryCounter/TelemetryCounters. It mistakenly used milliseconds as the default unit type for counters previously.
  • Refactored TelemetryHistogram/TelemetryHistograms to use the shared default milliseconds unit type; not necessary to define it each time.

Fixed:

  • Moved fromRequest step above exception handling in the synchronous API Client to ensure those attributes were properly collected there. This was already the case in the asynchronous API client.
  • Moved http.request.resend_count increment to the top of the retry loop for the synchronous API client to ensure the proper value is collected when an API exception is raised.

References

Closes #130

Review Checklist

  • [x] I have clicked on "allow edits by maintainers".
  • [ ] I have added documentation for new/changed functionality in this PR or in a PR to openfga.dev [Provide a link to any relevant PRs in the references section above]
  • [x] The correct base branch is being used, if not main
  • [ ] I have added tests to validate that the change in functionality is working as expected

evansims avatar Sep 23 '24 16:09 evansims

Codecov Report

Attention: Patch coverage is 76.66667% with 7 lines in your changes missing coverage. Please review.

Project coverage is 69.17%. Comparing base (a00f039) to head (916442d). Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
openfga_sdk/telemetry/configuration.py 55.55% 4 Missing :warning:
openfga_sdk/telemetry/metrics.py 57.14% 3 Missing :warning:
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #135      +/-   ##
==========================================
+ Coverage   69.15%   69.17%   +0.01%     
==========================================
  Files         122      122              
  Lines        9746     9771      +25     
==========================================
+ Hits         6740     6759      +19     
- Misses       3006     3012       +6     

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov-commenter avatar Sep 23 '24 16:09 codecov-commenter