Page MenuHomePhabricator

[services][blob] Use tracing for logs
ClosedPublic

Authored by bartek on Nov 28 2022, 2:14 AM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, Dec 20, 11:06 AM
Unknown Object (File)
Fri, Dec 20, 11:04 AM
Unknown Object (File)
Fri, Dec 20, 10:52 AM
Unknown Object (File)
Fri, Dec 20, 10:37 AM
Unknown Object (File)
Fri, Dec 20, 4:49 AM
Unknown Object (File)
Nov 10 2024, 10:05 PM
Unknown Object (File)
Nov 9 2024, 2:20 PM
Unknown Object (File)
Nov 9 2024, 1:46 PM

Details

Summary

Related ENG-2308

Similar to identity service, I introduced the tracing library here. I enhanced its configuration to take level filter from environment variables. It defaults to INFO everywhere, what corresponds to the identity service behavior.

Default environment variable name is RUST_LOG but it can be changed if needed.

A few examples:

  • cargo run - (default) showing INFO logs and higher (warn/error)
  • RUST_LOG=debug - showing DEBUG+, includes dependencies (e.g. AWS logs)
  • RUST_LOG=blob=trace - showing TRACE+ logs for the blob service, INFO+ for dependencies

Depends on D5728

Adding @ashoat as this introduces a new dependency (already used in identity service though).

Test Plan

RUST_LOG=blob=trace cargo run and see the logs

Diff Detail

Repository
rCOMM Comm
Lint
No Lint Coverage
Unit
No Test Coverage

Event Timeline

bartek held this revision as a draft.
bartek published this revision for review.Nov 28 2022, 2:54 AM

looks to be pretty standard way to use tracing

cc @max and @tomek on usage of tracing over log. Seems that tracing crate is preferred for asynchronous tracing.

tomek added inline comments.
services/blob/src/main.rs
49–55 ↗(On Diff #18855)

It's a matter of style, but even though this comment is useful, it might get easily out of sync with the code. A lot better approach would be to extract a function with the exact same name as this comment. By doing that we're ensuring that the name and code remain in sync.

This revision is now accepted and ready to land.Nov 28 2022, 11:11 PM
max added inline comments.
services/blob/src/main.rs
49–55 ↗(On Diff #18855)

It's a matter of style, but even though this comment is useful, it might get easily out of sync with the code. A lot better approach would be to extract a function with the exact same name as this comment. By doing that we're ensuring that the name and code remain in sync.

I agree with @tomek, can we extract this?

  • Rebase
  • Extracted initialization code to configure_logging()
This revision was landed with ongoing or failed builds.Nov 30 2022, 6:53 AM
This revision was automatically updated to reflect the committed changes.