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

feat: Track Upload Sent events for Coverage/BA/TA (attempt 2) #1195

Open
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

spalmurray-codecov
Copy link
Contributor

@spalmurray-codecov spalmurray-codecov commented Mar 4, 2025

Adds event tracking of 'Upload Sent' events for Coverage, Bundles, and test results.

It seems in some cases commit may not have an author set during upload ingest. In these cases we've decided to attribute the events to a special anonymous user that has a special user id constant in shared.

Last time I merged this PR it was breaking uploads because it seems sometimes commit author is also not defined there, which we were not expecting. This second attempt adds the fallback user id to coverage uploads as well.

Note that we are using commit.id instead of the commit sha because a full commit sha is functionally identifiable information (for public repos at least). No reason to use this when we have an internal id that does the same thing but is only useful to us.

Copy link

sentry-io bot commented Mar 4, 2025

🔍 Existing Issues For Review

Your pull request is modifying functions with the following pre-existing issues:

📄 File: upload/views/uploads.py

Function Unhandled Issue
send_analytics_data AttributeError: 'NoneType' object has no attribute 'ownerid' /upload/{service}/{repo}/upl...
Event Count: 9

Did you find this useful? React with a 👍 or 👎

Copy link

codecov bot commented Mar 4, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.86%. Comparing base (f77e387) to head (1589140).

✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1195   +/-   ##
=======================================
  Coverage   95.86%   95.86%           
=======================================
  Files         493      493           
  Lines       16870    16876    +6     
=======================================
+ Hits        16173    16179    +6     
  Misses        697      697           
Flag Coverage Δ
unit 95.86% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@codecov-notifications
Copy link

codecov-notifications bot commented Mar 4, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@spalmurray-codecov spalmurray-codecov force-pushed the spalmurray/amplitude-upload-event branch from 1272b27 to 1589140 Compare March 10, 2025 20:38
Copy link

overwatch-beta bot commented Mar 10, 2025

🚨 Sentry detected 7 potential issues in your recent changes 🚨

Lower risk findings

@spalmurray-codecov spalmurray-codecov marked this pull request as ready for review March 10, 2025 20:40
@spalmurray-codecov spalmurray-codecov requested a review from a team as a code owner March 10, 2025 20:40
Comment on lines 174 to 176
"user_ownerid": commit.author.ownerid
if commit.author
else UNKNOWN_USER_OWNERID,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

the only change is these lines

if commit.author
else UNKNOWN_USER_OWNERID,
"ownerid": commit.repository.author.ownerid,
"repoid": commit.repository.repoid,
Copy link
Contributor

Choose a reason for hiding this comment

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

putting a note here (mostly for myself) to figure out whether we would gain anything from using author_id and repository_id here instead of accessing those values via attrs

Copy link
Contributor Author

Choose a reason for hiding this comment

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

not sure I follow. Where are author_id and repository_id defined?

Copy link
Contributor

Choose a reason for hiding this comment

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

they are not defined explicitly anywhere: here's some context https://docs.djangoproject.com/en/dev/ref/models/fields/#database-representation

there's nothing todo on this PR for this comment, i just wanted to make a note to revisit this and check whether we can avoid some reads from the database here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ahh okay I'm with you. I've been under the assumption that there are no reads for accessing like this. Assumed it would be populated on the already read commit in scope here (though we may need to explicitly add a select_related here to achieve that). Please lmk if I'm wrong I do not want to be doing more than one fetch for the commit's attrs. Side Q does django automatically cache any of this stuff?

Copy link
Contributor

@ajay-sentry ajay-sentry left a comment

Choose a reason for hiding this comment

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

looks good!

Copy link
Contributor

sentry-autofix bot commented Mar 13, 2025

🚨 Sentry detected 10 potential issues in your recent changes 🚨

Lower risk findings

Did you find this useful? React with a 👍 or 👎

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

Successfully merging this pull request may close these issues.

3 participants