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

Add Constellation support for express & slow P3A metrics #20264

Merged
merged 12 commits into from
Nov 11, 2023

Conversation

DJAndries
Copy link
Collaborator

@DJAndries DJAndries commented Sep 23, 2023

Resolves brave/brave-browser#33217

Submitter Checklist:

  • I confirm that no security/privacy review is needed and no other type of reviews are needed, or that I have requested them
  • There is a ticket for my issue
  • Used Github auto-closing keywords in the PR description above
  • Wrote a good PR/commit description
  • Squashed any review feedback or "fixup" commits before merge, so that history is a record of what happened in the repo, not your PR
  • 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 wiki
    • npm run lint, npm run presubmit wiki, 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:

Use MITM proxy when using browser.

  1. Start with fresh profile.
  2. Ensure JSON metrics are sent as usual to p3a-json.brave.com. Ensure that the cadence field in the payload contains the correct value. If the metric is in the logs object (in local state), ensure the cadence is typical. If the metric is in logs_slow, ensure the cadence is slow. If the metric is in logs_express, ensure the cadence is express. Ensure that each metric sent to the server is marked as "sent" in the local state.
  3. Ensure requests are being made to star-randsrv.bsg.brave.com to prepare Constellation metrics. Ensure that the URL path is /instances/<cadence type>/randomness. When one request is sent for a particular cadence, check to see that metrics are being marked as "sent" as they are being sent to the server, by checking the correct "logs" object in local state. For the typical cadence, keep an eye on logs_constellation_prep. For the express cadence, keep an eye on logs_constellation_prep_express. For the slow cadence, keep an eye on logs_constellation_prep_slow.
  4. Ensure final measurements are being sent to collector.bsg.brave.com. The URL path should be /<cadence type>. Before metrics are sent to this server, they should appear under constellation_logs, constellation_logs_express and constellation_logs_slow after being prepared (from the requests being made in step 2). As soon as the metrics are sent to the collector, the metric should disappear in the relevant local state object.

@DJAndries DJAndries force-pushed the p3a-constellation-slow-express branch 2 times, most recently from 25a8ebf to fc4a171 Compare September 28, 2023 23:26
@DJAndries DJAndries marked this pull request as ready for review September 28, 2023 23:27
@DJAndries DJAndries requested review from a team and bridiver as code owners September 28, 2023 23:27
components/p3a/message_manager.cc Show resolved Hide resolved
components/p3a/message_manager.cc Show resolved Hide resolved
components/p3a/star_randomness_meta.cc Show resolved Hide resolved
components/p3a/star_randomness_meta.cc Show resolved Hide resolved
components/p3a/star_randomness_points.cc Show resolved Hide resolved
@DJAndries DJAndries force-pushed the p3a-constellation-slow-express branch 2 times, most recently from 6063f8f to d06573a Compare September 29, 2023 03:42
@DJAndries DJAndries force-pushed the p3a-constellation-slow-express branch from d06573a to f63003f Compare October 13, 2023 23:07
@DJAndries DJAndries force-pushed the p3a-constellation-slow-express branch from f63003f to b63af35 Compare October 24, 2023 00:29
Copy link
Collaborator

@bridiver bridiver left a comment

Choose a reason for hiding this comment

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

brave_domains url changes look ok

@kylehickinson kylehickinson requested a review from a team as a code owner November 1, 2023 13:53
@DJAndries DJAndries force-pushed the p3a-constellation-slow-express branch from 2aa2eec to 92947b3 Compare November 1, 2023 21:04
base::Time::FromNSDate(value));
}
}
+ BRAVE_MIGRATE_OBSOLETE_LOCAL_STATE_PREFS
Copy link
Collaborator

Choose a reason for hiding this comment

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

this can be done with a chromium_src override for MigrateObsoleteLocalStatePrefs

Copy link
Collaborator

Choose a reason for hiding this comment

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

Since this is how we've managed the overrides for the other 3 methods can we keep this for now and then I'll open a new PR removing the patch entirely after this merges?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think it wasn't possible in the other cases because the method name wasn't unique in the file. This is a very simple change to a chromium_src override

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yeah I just double checked, can only be done for MigrateObsoleteLocalStatePrefs and MigrateObsoleteBrowserStatePrefs. I'll update both

Copy link
Collaborator

Choose a reason for hiding this comment

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

there's probably still another way to make it work without patches in the other cases, but for now I just want to make sure we're not adding new patches

Copy link
Collaborator

Choose a reason for hiding this comment

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

For the time being, replaced the migrate methods over in this PR: 8a9fb74

Copy link
Collaborator

@kylehickinson kylehickinson left a comment

Choose a reason for hiding this comment

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

iOS++ tested locally with the BraveP3AConstellation feature flag enabled

@DJAndries DJAndries force-pushed the p3a-constellation-slow-express branch from 8a9fb74 to a66b052 Compare November 7, 2023 06:11
base::Value::Dict* inflight_dict =
creative_dict->FindDict(kInflightDictKey);
DCHECK(inflight_dict);
if (inflight_dict == nullptr) {
Copy link
Contributor

Choose a reason for hiding this comment

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

this is actually an anti-pattern, see code samples in https://chromium.googlesource.com/chromium/src/+/HEAD/styleguide/c++/checks.md

@DJAndries DJAndries force-pushed the p3a-constellation-slow-express branch from a66b052 to 055b624 Compare November 9, 2023 23:35
@DJAndries DJAndries merged commit 3f3b71b into master Nov 11, 2023
16 checks passed
@DJAndries DJAndries deleted the p3a-constellation-slow-express branch November 11, 2023 00:08
@github-actions github-actions bot added this to the 1.62.x - Nightly milestone Nov 11, 2023
@kylehickinson
Copy link
Collaborator

If uplifted please also uplift #21000

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.

Use Constellation for express & slow P3A metrics
6 participants