Page MenuHomePhabricator

[backup] Improve logging
ClosedPublic

Authored by michal on Dec 22 2023, 7:35 AM.
Tags
None
Referenced Files
F3504473: D10451.diff
Fri, Dec 20, 9:05 AM
Unknown Object (File)
Mon, Dec 16, 6:06 AM
Unknown Object (File)
Fri, Nov 22, 6:41 AM
Unknown Object (File)
Nov 16 2024, 7:34 PM
Unknown Object (File)
Nov 16 2024, 7:34 PM
Unknown Object (File)
Nov 16 2024, 7:33 PM
Unknown Object (File)
Nov 16 2024, 7:33 PM
Unknown Object (File)
Nov 16 2024, 7:28 PM
Subscribers

Details

Summary

Improve logging in the backup service. Cleaned up the instrument macros.

Depends on D10428

Test Plan

Run tests, check that logs are correctly displayed.

Diff Detail

Repository
rCOMM Comm
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

services/backup/src/http/handlers/backup.rs
32 ↗(On Diff #34988)

This was moved because otherwise it didn't have the backup_id field (as it's filled in later in the current().record call).

If there are any errors before this line they should still be displayed in the span (but without the backup_id field).

shared/comm-lib/src/auth/types.rs
113–116 ↗(On Diff #34988)

I'm only logging user_id and device_id here and skipping the access token. I think that's fine but I want to make sure? (cc @varun, @ashoat)

shared/comm-lib/src/auth/types.rs
113–116 ↗(On Diff #34988)

Definitely we should skip the access token. I wonder a little bit about logging user_id and device_id... is it necessary? I'm wondering if we're basically creating an access log of when people use Comm, which is metadata that could be used to compromise privacy

shared/comm-lib/src/auth/types.rs
113–116 ↗(On Diff #34988)

When I was working on the initial version of the backup service with @kamil it was already pretty hard to debug when something went wrong (e.g. mapping a failed backup upload on a client to the service logs) and it will be even worse with real usage. The backup stored in db already keeps the user_id and creation timestamp.
But I understand the security concern and it's not strictly necessary so I can remove it if it's risky.

shared/comm-lib/src/auth/types.rs
113–116 ↗(On Diff #34988)

Let's remove it for now, and we can bring it back temporarily if we really think it's necessary at some point

bartek requested changes to this revision.Jan 5 2024, 12:27 AM

Requesting changes to remove sensitive fields for now

shared/comm-lib/src/auth/types.rs
113–116 ↗(On Diff #34988)

If it was included only for debug purposes (no info/warn/error logs), then it could stay, here this is used as "instrument" field so it will be displayed in all logs and we don't want it.
For debugging purposes, this is already implemented in #[derive(Debug)] trait.

On the other hand, I strongly agree that having such logs greatly improves debugging experience, especially on staging/prod, Maybe we could use sth like "hash key" for this struct, so in logs we're at least able to distinguish which logs belong to given request/backup/owner. For instance, some HTTP loggers include random request_id which allow to track logs when there are multiple simultaneous requests.

This revision now requires changes to proceed.Jan 5 2024, 12:27 AM

Removed logging of sensitive data.

michal edited the test plan for this revision. (Show Details)
This revision is now accepted and ready to land.Jan 8 2024, 4:44 AM
This revision was landed with ongoing or failed builds.Jan 8 2024, 7:20 AM
This revision was automatically updated to reflect the committed changes.