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

MPP-3352: Add first Glean metrics to measure email mask usage #4452

Merged
merged 24 commits into from
Mar 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
ab2f13d
Add draft metrics, glean_parser, and gen'ed code
jwhitlock Feb 26, 2024
a53db83
Make RELAY_CHANNEL_NAME a public type
jwhitlock Feb 26, 2024
8bde20b
Add plan data as profile properties
jwhitlock Feb 26, 2024
2257058
Add metrics_id properties to masks
jwhitlock Feb 26, 2024
f9f48c1
Add RelayGleanLogger, tests
jwhitlock Feb 26, 2024
9bbfe15
Add glean events to API
jwhitlock Feb 26, 2024
88e4fbb
Add glean events to email processing
jwhitlock Feb 26, 2024
69c6509
Do not emit metrics if the user has opted-out
jwhitlock Feb 26, 2024
9f3c33c
Add bug URLs to Glean metrics YAML
jwhitlock Feb 28, 2024
ef4d5de
Pass user to create_expected_glean_event
jwhitlock Mar 5, 2024
3106cc6
Create AddressViewSet base class
jwhitlock Mar 5, 2024
51e20a1
Explain why row ID isn't sufficent for uniqueness.
jwhitlock Mar 5, 2024
700454a
Adjust descriptions
jwhitlock Mar 5, 2024
985e3a3
Only send Glean events for emails blocked by mask
jwhitlock Mar 6, 2024
899f2fd
Remove can_retry from email_blocked event
jwhitlock Mar 6, 2024
f5beadd
Remove draft comment from relay-server-metrics
jwhitlock Mar 6, 2024
7dac89a
Add name for error log
jwhitlock Mar 6, 2024
9714417
Omit data in email_dropped log when user opts-out
jwhitlock Mar 6, 2024
f0a2377
Add comments for payload value checks
jwhitlock Mar 6, 2024
84c7e56
Skip coverage for fail-only code
jwhitlock Mar 6, 2024
4dd457c
Fix test of _get_keys_from_headers
jwhitlock Mar 6, 2024
d305176
Rename to assert_log_reply_email_dropped
jwhitlock Mar 8, 2024
1c2dc20
Rename to assert_log_incoming_email_dropped
jwhitlock Mar 8, 2024
37e8b6c
Split up RequestData tests
jwhitlock Mar 8, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ jobs:
description: "What command should the job run?"
default: "pytest"
type: enum
enum: ["pytest", "black", "mypy", "build_email_tracker_lists"]
enum: ["pytest", "black", "mypy", "build_email_tracker_lists", "build_glean", "check_glean"]
test_results_filename:
description: "What is the name of the jUnit XML test output? (Optional)"
default: ""
Expand Down Expand Up @@ -697,6 +697,11 @@ workflows:
test_results_filename: pytest-iq-enabled.xml
filters: *default_filters

- python_job:
name: check generated glean_parser files
command: check_glean
filters: *default_filters

- test_frontend:
requires:
- build_frontend
Expand Down
81 changes: 80 additions & 1 deletion .circleci/python_job.bash
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
: ${TEST_DB_NAME:=test.sqlite3}
: ${TEST_DB_URL:=sqlite:///test.sqlite3}
: ${DATABASE_ENGINE:=sqlite}
: ${GLEAN_OUTPUT_FOLDER:=privaterelay/glean}
: ${GLEAN_INPUT_YAML:=telemetry/glean/relay-server-metrics.yaml}

# Run black to check Python format
function run_black {
Expand Down Expand Up @@ -73,13 +75,85 @@ function run_build_email_tracker_lists {
cp /home/circleci/project/emails/tracker_lists/level-two-trackers.json /tmp/workspace/email-trackers/
}



# Run commands to build the backend Glean code
function run_build_glean {
local OUTPUT_FOLDER=${1:-$GLEAN_OUTPUT_FOLDER}
local INPUT_YAML=${2:-$GLEAN_INPUT_YAML}
set -x
glean_parser translate --format python_server --output ${OUTPUT_FOLDER} ${INPUT_YAML}
black ${OUTPUT_FOLDER}
case "$OSTYPE" in
darwin* | bsd*)
echo "Using BSD sed";
sed -i '' \
-e 's/^AUTOGENERATED BY glean_parser \(.* DO NOT EDIT.\) DO NOT COMMIT.$/AUTOGENERATED BY glean_parser \1 To recreate, run:\n\nbash .circleci\/python_job.bash run build_glean/' \
${OUTPUT_FOLDER}/server_events.py;;
linux*)
echo "Using GNU sed";
sed -i \
-e 's/^AUTOGENERATED BY glean_parser \(.* DO NOT EDIT.\) DO NOT COMMIT.$/AUTOGENERATED BY glean_parser \1 To recreate, run:\n\nbash .circleci\/python_job.bash run build_glean/' \
${OUTPUT_FOLDER}/server_events.py;;
*)
echo "Unknown OSTYPE '${OSTYPE}'";;
esac
}

# Run commands to check if the backend Glean code has changed
function run_check_glean {
GLEAN_TEST_FOLDER=`mktemp -d`
echo "Created temporary folder $GLEAN_TEST_FOLDER"
echo "Re-running glean_parser..."
echo
run_build_glean $GLEAN_TEST_FOLDER
set +x

echo
echo "Checking new files against checked-in files..."
local HAS_DIFFS=0
local HAS_FILES=0
local EXIT_CODE=0
for FILENAME in `find ${GLEAN_TEST_FOLDER} -type f -exec basename \{\} \;`
do
HAS_FILES=1
if [[ 0 -ne `cmp --silent "${GLEAN_TEST_FOLDER}/${FILENAME}" "${GLEAN_OUTPUT_FOLDER}/${FILENAME}"` ]]
then
HAS_DIFFS=1
fi
done
if [ $HAS_FILES -eq 0 ]
then
echo "glean_parser did not generate any files!"
EXIT_CODE=1
fi
if [ $HAS_DIFFS -eq 1 ]
then
echo "*** Differences detected - need to re-run glean_parser ***"
diff $GLEAN_OUTPUT_FOLDER $GLEAN_TEST_FOLDER
EXIT_CODE=1
fi
if [ "$GLEAN_TEST_FOLDER" != "" ]
then
echo "Removing temporary folder $GLEAN_TEST_FOLDER"
rm -rf $GLEAN_TEST_FOLDER
fi
if [ $EXIT_CODE -eq 0 ]
then
echo "✓ Files are identical"
else
exit 1
fi
}


# Run a command by name
# $1 - The command to run - black, mypy, pytest, or build_email_tracker_lists
# Remaining arguments are passed to the run_COMMAND function
function run_command {
local COMMAND=${1:-}
case $COMMAND in
black | mypy | pytest | build_email_tracker_lists)
black | mypy | pytest | build_email_tracker_lists | build_glean | check_glean)
:;;
"")
echo "No command passed - '$COMMAND'"
Expand Down Expand Up @@ -142,3 +216,8 @@ function switch_to_production {
git status
pip install -r requirements.txt
}

if [ "$1" == "run" ]
then
run_command "$2"
fi
Loading