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

editoast: make authorizer's logs less noisy #8834

Merged
merged 1 commit into from
Sep 12, 2024

Conversation

woshilapin
Copy link
Contributor

So far, each request on an endpoint show the returned value of the authorizer.

  2024-09-11T05:01:31.226339Z  INFO editoast_authz::authorizer: return: true
    at editoast_authz/src/authorizer.rs
    in editoast_authz::authorizer::check_roles with user: superuser (Super User), user_roles: {}, required_roles: {RollingStockCollectionRead}
    in tower_http::trace::make_span::request with method: GET, uri: /light_rolling_stock, version: HTTP/1.1

It makes the logs on editoast pretty noisy. The ret on the tracing::instrument produces a log event (without ret we would still have the span). Ideally, we would like the information of the span to live for the entire duration of the request/response cycle.

However, since the authorizer is not a middleware (feature is on the way I believe), we cannot make the span lives for the entire request/response cycle, it only lives for the very beginning of the endpoint. This means that useful contextual information like user, user_roles or required_roles won't be visible through the logs produced in the endpoint.

In the meantime, leaving ret, but making the default level to DEBUG seems an OK improvement.

So far, each request on an endpoint show the returned value of the
authorizer.

```
  2024-09-11T05:01:31.226339Z  INFO editoast_authz::authorizer: return: true
    at editoast_authz/src/authorizer.rs
    in editoast_authz::authorizer::check_roles with user: superuser (Super User), user_roles: {}, required_roles: {RollingStockCollectionRead}
    in tower_http::trace::make_span::request with method: GET, uri: /light_rolling_stock, version: HTTP/1.1
```

It makes the logs on `editoast` pretty noisy. The `ret` on the
`tracing::instrument` produces a log event (without `ret` we would still
have the span). Ideally, we would like the information of the span to
live for the entire duration of the request/response cycle.

However, since the authorizer is not a middleware (feature is on the way
I believe), we cannot make the span lives for the entire request/response
cycle, it only lives for the very beginning of the endpoint. This means
that useful contextual information like `user`, `user_roles` or
`required_roles` won't be visible through the logs produced in the
endpoint.

In the meantime, leaving `ret`, but making the default level to `DEBUG`
seems an OK improvement.

Signed-off-by: Jean SIMARD <[email protected]>
@woshilapin woshilapin requested a review from a team as a code owner September 11, 2024 17:31
@codecov-commenter
Copy link

codecov-commenter commented Sep 11, 2024

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 37.04%. Comparing base (a902ca2) to head (93aecb9).
Report is 7 commits behind head on dev.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@             Coverage Diff              @@
##                dev    #8834      +/-   ##
============================================
- Coverage     37.07%   37.04%   -0.04%     
+ Complexity     2212     2209       -3     
============================================
  Files          1255     1255              
  Lines        114111   114134      +23     
  Branches       3189     3182       -7     
============================================
- Hits          42307    42279      -28     
- Misses        69907    69963      +56     
+ Partials       1897     1892       -5     
Flag Coverage Δ
core 74.79% <ø> (-0.01%) ⬇️
editoast 72.41% <100.00%> (-0.03%) ⬇️
front 14.92% <ø> (-0.02%) ⬇️
gateway 2.20% <ø> (ø)
osrdyne 2.71% <ø> (ø)
railjson_generator 87.49% <ø> (ø)
tests 86.37% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

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

Copy link
Contributor

@flomonster flomonster left a comment

Choose a reason for hiding this comment

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

LGTM

@woshilapin woshilapin added this pull request to the merge queue Sep 12, 2024
Merged via the queue into dev with commit bc8b913 Sep 12, 2024
23 checks passed
@woshilapin woshilapin deleted the wsl/editoast/authorizer-less-noisy branch September 12, 2024 09:56
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.

3 participants