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

feat: support OpenTelemetry metrics #115

Merged
merged 8 commits into from
Aug 29, 2024

Conversation

evansims
Copy link
Member

Description

Introduces OpenTelemetry metrics reporting into the SDK for specific actions. We're intentionally starting with only a few metric events that we can then grow over time.

We don't have any formal documentation for this currently. We'll write this as we roll it out across all SDKs, so here is a summary of the events and the associated attributes:

Supported Metrics

Metric Name Type Description
fga-client.request.duration Histogram The total request time for FGA requests
fga-client.query.duration Histogram The amount of time the FGA server took to internally process nd evaluate the request
fga-client.credentials.request Counter The total number of times a new token was requested when using ClientCredentials

Supported attributes

Attribute Name Type Description
fga-client.response.model_id string The authorization model ID that the FGA server used
fga-client.request.method string The FGA method/action that was performed (e.g. check, listObjects, ...) in camelCase
fga-client.request.store_id string The store ID that was sent as part of the request
fga-client.request.model_id string The authorization model ID that was sent as part of the request, if any
fga-client.request.client_id string The client ID associated with the request, if any
fga-client.user string The user that is associated with the action of the request for check and list objects
fga-client.request.retries int The number of retries attempted (starting from 1 for the original request). Deprecated, use http.request.resend_count
http.request.resend_count int The number of retries attempted (starting from 1 for the original request)
http.status_code int The status code of the response. Deprecated, use http.response.status_code
http.response.status_code int The status code of the response
http.method string The HTTP method for the request. Deprecated, use http.request.method
http.request.method string The HTTP method for the request
http.host string Host identifier of the origin the request was sent to
url.scheme string HTTP Scheme of the request (http/https)
url.full string Full URL of the request
user_agent.original string User Agent used in the query
http.client.request.duration int The total request time for FGA requests
http.server.request.duration int The amount of time the FGA server took to internally process nd evaluate the request

References

Closes #105

Review Checklist

  • 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]
  • 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 evansims added the enhancement New feature or request label Jul 30, 2024
@evansims evansims marked this pull request as ready for review July 30, 2024 06:25
@evansims evansims requested a review from a team as a code owner July 30, 2024 06:25
@codecov-commenter
Copy link

codecov-commenter commented Jul 30, 2024

Codecov Report

Attention: Patch coverage is 60.11029% with 217 lines in your changes missing coverage. Please review.

Project coverage is 25.45%. Comparing base (d1fa227) to head (16bb77c).

Files Patch % Lines
api_open_fga.go 55.55% 110 Missing and 10 partials ⚠️
internal/telemetry/attributes.go 34.09% 84 Missing and 3 partials ⚠️
internal/telemetry/telemetry.go 89.47% 2 Missing and 2 partials ⚠️
oauth2/internal/token.go 0.00% 3 Missing and 1 partial ⚠️
credentials/credentials.go 33.33% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #115      +/-   ##
==========================================
+ Coverage   23.58%   25.45%   +1.87%     
==========================================
  Files          95      102       +7     
  Lines       10033    10576     +543     
==========================================
+ Hits         2366     2692     +326     
- Misses       7412     7612     +200     
- Partials      255      272      +17     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@rhamzeh rhamzeh left a comment

Choose a reason for hiding this comment

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

This does not yet implement fga_client.user right?

api_open_fga.go Outdated Show resolved Hide resolved
@evansims
Copy link
Member Author

evansims commented Jul 30, 2024

This does not yet implement fga_client.user right?

Correct, I haven't quite figured out how to approach that yet

This is now supported 😄

@evansims evansims force-pushed the feat/support-opentelemetry-metrics branch from 505dbd9 to 8fba0f5 Compare July 30, 2024 21:06
@evansims evansims requested a review from rhamzeh August 27, 2024 17:41
@evansims evansims added this pull request to the merge queue Aug 29, 2024
Merged via the queue into main with commit 0887f1c Aug 29, 2024
9 checks passed
@evansims evansims deleted the feat/support-opentelemetry-metrics branch August 29, 2024 03:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Export metrics
5 participants