feat: privacy mode to suppress logs and tracing #17
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
starting on a privacy_mode param that would suppress logs and tracing for just that single request. requested by Polaris / Osmosis
How it works
We added a "X-Privacy-Mode" header in https://github.com/LIT-Protocol/lit-peer/pull/17/files#diff-444d506d6b348808f56db7bb8fb7c677ee5f67b68bf3457a8c04c7c3630f6c04 which sets a variable to suppress logging and tracing for the duration of that rocket request, and only for that request.
If privacy mode is enabled, we don't get any metrics, not even on endpoint usage. So, if privacy mode is enabled, we also log the request method and path before turning off logging, so that we can at least track those basic metrics of how many times an endpoint was hit.
To enable this, we added a SubscriberExt layer
let subscriber = subscriber.with(crate::utils::rocket::privacy_mode::PrivacyModeLayer);that will disable logging and tracing when privacy mode is set.Tests
We have a test of this new header, but it only checks for logs. We probably need to manually check that the traces are excluded too.