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

Log Rewards errors by default and add a feature flag for verbose logging #8598

Merged
merged 1 commit into from
Apr 29, 2021

Conversation

zenparsing
Copy link
Collaborator

@zenparsing zenparsing commented Apr 21, 2021

Resolves brave/brave-browser#15500

  • Enables logging of "error" level messages by default.
  • Adds a feature flag BraveRewardsVerboseLogging which can be used to turn on verbose logging.
  • Removes arbitrary data from existing error logging calls.
  • Adds logging of unexpected HTTP response status codes.
  • The existing --rewards=persist-logs=1 command line option is still supported, but deprecated in favor of specifying the feature flag on the command line with --enable-features=BraveRewardsVerboseLogging

Submitter Checklist:

  • I confirm that no security/privacy review is needed, or that I have requested one
  • There is a ticket for my issue
  • Used Github auto-closing keywords in the PR description above
  • Wrote a good PR/commit description
  • Added appropriate labels (QA/Yes or QA/No; release-notes/include or release-notes/exclude; OS/...) to the associated issue
  • Checked the PR locally: npm run test -- brave_browser_tests, npm run test -- brave_unit_tests, npm run lint, npm run gn_check, npm run tslint
  • Ran git rebase master (if needed)

Reviewer Checklist:

  • A security review is not needed, or a link to one is included in the PR description
  • New files have MPL-2.0 license header
  • Adequate test coverage exists to prevent regressions
  • Major classes, functions and non-trivial code blocks are well-commented
  • Changes in component dependencies are properly reflected in gn
  • Code follows the style guide
  • Test plan is specified in PR before merging

After-merge Checklist:

Test Plan:

Error logging

  • Given that verbose logging is not enabled
  • When Rewards encounters an error condition and logs an error
  • Then the error should be visible in the "Logs" tab of brave://rewards-internals

Possible test steps:

  • Open browser with clean profile pointed to staging.
  • Trigger a Rewards error:
    • Open the Rewards panel and solve UGP captcha incorrectly
  • Go to brave://rewards-internals
  • Select the "Logs" tab and click "Refresh"
  • Verify that an error has been logged
  • Verify that non-error messages do not appear

Verbose logging

  • Given that the user has enabled verbose logging from brave://flags
  • When the user interacts with Rewards
  • Then detailed logging should be visible in the "Logs" tab of brave://rewards-internals

Possible test steps

  • Open browser with clean profile pointed to staging.
  • Go to brave://flags and enable BraveRewardsVerboseLogging.
  • Relaunch the browser.
  • Go to brave://rewards-internals
  • Select the "Logs" tab and click "Refresh"
  • Verify that detailed information is logged.

@zenparsing zenparsing force-pushed the ksmith-rewards-log-errors branch 2 times, most recently from 45b9141 to 5f03daa Compare April 26, 2021 15:47
@zenparsing zenparsing marked this pull request as ready for review April 26, 2021 17:42
@zenparsing zenparsing requested review from tmancey and a team as code owners April 26, 2021 17:42
@zenparsing zenparsing requested a review from emerick April 26, 2021 17:47
@@ -334,6 +334,9 @@ RewardsServiceImpl::RewardsServiceImpl(Profile* profile)
content::URLDataSource::Add(profile_,
std::make_unique<BraveRewardsSource>(profile_));
ready_ = std::make_unique<base::OneShotEvent>();

if (base::FeatureList::IsEnabled(features::kVerboseLoggingFeature))
persist_log_level_ = kDiagnosticLogMaxVerboseLevel;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe worth checking the performance impact on Android?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think it would have any impact on performance. I can run through the branch and quickly check.

Copy link
Contributor

@emerick emerick left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Collaborator

@mkarolin mkarolin left a comment

Choose a reason for hiding this comment

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

chromium_src changes LGTM

const char kBraveRewardsVerboseLoggingName[] =
"Enable Brave Rewards verbose logging";
const char kBraveRewardsVerboseLoggingDescription[] =
"Enables detailed logging of Brave Rewards system events to a log file";
Copy link
Member

Choose a reason for hiding this comment

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

IMO this should have a warning that says this might log sensitive information.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Agreed - I'll add some preliminary text and attach a screenshot.

@@ -790,7 +790,7 @@ class RewardsServiceImpl : public RewardsService,
bool reset_states_;
bool ledger_for_testing_ = false;
bool resetting_rewards_ = false;
bool should_persist_logs_ = false;
int persist_log_level_ = 0;
Copy link
Collaborator

@tmancey tmancey Apr 27, 2021

Choose a reason for hiding this comment

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

0 will only log errors. Ideally, this should be 2, which will also log WARNINGS and INFO. Anything above INFO is considered verbose.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I agree that more logging would be ideal. Unfortunately, logging at 2 will create for us a dilemma: we'll likely have to remove useful information from messages at those levels, which will make those levels less useful for development and detailed debugging. I would prefer that we stay with logging only errors by default in this PR, and consider increasing the default log level as a future change.

@zenparsing zenparsing requested a review from a team as a code owner April 27, 2021 19:50
"Enables detailed logging of Brave Rewards system events to a log file "
"stored on your device. Please note that this file may contain sensitive "
"information. Please only submit it using "
"https://upload-support.brave.com/rewards.";
Copy link
Member

Choose a reason for hiding this comment

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

This might encourage people to send us these files who otherwise might not, and in general we want to collect as little of these log files if possible.

Could we change it to Note that this file may contain sensitive information. Do not share it unless asked to by Brave staff for debugging purposes. cc @hollons

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That suggestion looks much better to me! I'm going to go ahead and update the PR while we wait on more feedback.

@zenparsing
Copy link
Collaborator Author

CI Results:

  • MacOS and Linux build and tests succeeded, failed on Archive JUnit-formatted test results step (unrelated to PR).

Copy link
Contributor

@emerick emerick left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Collaborator

@tmancey tmancey left a comment

Choose a reason for hiding this comment

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

LGTM

@kjozwiak
Copy link
Member

kjozwiak commented May 18, 2021

Verification PASSED on Win 10 x64 using the following build:

Brave | 1.26.22 Chromium: 91.0.4472.57 (Official Build) nightly (64-bit)
--- | ---
Revision | e3443317fa07f1e9997e4a9c738eddfefc3c0292-refs/branch-heads/4472_54@{#6}
OS | Windows 10 OS Version 2009 (Build 19042.964)

Error logging

  • disconnected the internet/network and attempted to create a wallet within a new profile
  • after ~1minute, enabled the network/internet and created a wallet
  • connected to a production uphold account
  • verified that only errors are appearing in brave://rewards-internals while #brave-rewards-verbose-logging is disabled
  • ensured that Refresh, Clear & Download are working as expected

rewardError1

Verbose logging

  • enabled #brave-rewards-verbose-logging via brave://flags
  • once enabled, created a new wallet
  • connected to my production Uphold account
  • verified there's more detailed logs present under brave://rewards-internals
  • ensured that Refresh, Clear & Download are working as expected

verboseFlag

@kjozwiak
Copy link
Member

Went through the above cases on Android and added the verification notes on Nightly for uplift via #8841 (comment).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Log Rewards errors by default
7 participants