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: measure uploads using sentry metrics #406

Merged
merged 3 commits into from
Feb 21, 2024
Merged

Conversation

joseph-sentry
Copy link
Contributor

Purpose/Motivation

Adding Sentry DDM to the various upload endpoints

Links to relevant tickets

Fixes: codecov/engineering-team#1178

What does this PR do?

  • generate_upload_sentry_metrics_tags in upload helpers to generate tags for metrics, tags are:
    • agent: uploader or cli
    • version: which version of the agent
    • action: coverage vs test results
    • private: is the repo the upload is being made to private?
    • is_shelter_request: is the request coming from shelter
  • get_agent_from_headers and get_version_from_headers to parse User-Agent header to get agent and version, if it fails to parse it will return unsupported-user-agent

Note: My auto formatter went off while saving some of the files and the linter did not undo them, so this PR comes with some formatting changes to some of the files that have not been visited recently.

@joseph-sentry joseph-sentry requested a review from a team as a code owner February 17, 2024 00:26
@codecov-staging
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

📢 Thoughts on this report? Let us know!

@codecov-qa
Copy link

codecov-qa bot commented Feb 17, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (5111f78) 96.10% compared to head (858939c) 96.10%.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #406   +/-   ##
=======================================
  Coverage   96.10%   96.10%           
=======================================
  Files         637      637           
  Lines       16673    16693   +20     
=======================================
+ Hits        16023    16043   +20     
  Misses        650      650           
Flag Coverage Δ
unit 96.10% <100.00%> (+<0.01%) ⬆️
unit-latest-uploader 96.10% <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.

Copy link

codecov-public-qa bot commented Feb 17, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (5111f78) 96.10% compared to head (858939c) 96.10%.

Impacted file tree graph

@@           Coverage Diff           @@
##             main     #406   +/-   ##
=======================================
  Coverage   96.10%   96.10%           
=======================================
  Files         637      637           
  Lines       16673    16693   +20     
=======================================
+ Hits        16023    16043   +20     
  Misses        650      650           
Flag Coverage Δ
unit 96.10% <100.00%> (+<0.01%) ⬆️
unit-latest-uploader 96.10% <100.00%> (+<0.01%) ⬆️

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

Files Coverage Δ
upload/helpers.py 94.62% <100.00%> (+0.28%) ⬆️
upload/views/legacy.py 95.52% <100.00%> (+0.04%) ⬆️
upload/views/test_results.py 98.48% <100.00%> (+0.04%) ⬆️
upload/views/uploads.py 98.98% <100.00%> (+0.02%) ⬆️

Impacted file tree graph

Copy link
Contributor

@giovanni-guidini giovanni-guidini left a comment

Choose a reason for hiding this comment

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

some nit suggestions but looks good 👍


def get_agent_from_headers(headers):
try:
return headers["User-Agent"].split("/")[0].split("-")[1]
Copy link
Contributor

Choose a reason for hiding this comment

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

[nit] add a comment with the expected values for the User-Agent.

It'll make it clearer for the reader why these splits are necessary and what sort of values we expect.

err=str(e),
),
)
return "unsupported-user-agent"
Copy link
Contributor

Choose a reason for hiding this comment

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

[nit] maybe "unknown" is better than "unsupported" here IF (and only if, I actually don't know) we actually process the upload

err=str(e),
),
)
return "unsupported-user-agent"
Copy link
Contributor

Choose a reason for hiding this comment

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

Same nit suggestion as function above

Copy link

codecov bot commented Feb 20, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (5111f78) 95.80% compared to head (858939c) 95.80%.
Report is 1 commits behind head on main.

Changes have been made to critical files, which contain lines commonly executed in production. Learn more

Additional details and impacted files
@@          Coverage Diff          @@
##            main    #406   +/-   ##
=====================================
  Coverage   95.80   95.80           
=====================================
  Files        757     757           
  Lines      17252   17272   +20     
=====================================
+ Hits       16527   16547   +20     
  Misses       725     725           
Flag Coverage Δ
unit 96.10% <100.00%> (+<0.01%) ⬆️
unit-latest-uploader 96.10% <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.

Copy link

@barnett-yuxiang barnett-yuxiang left a comment

Choose a reason for hiding this comment

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

Is this version management more dangerous?

@joseph-sentry joseph-sentry merged commit 64a6de2 into main Feb 21, 2024
19 of 20 checks passed
@joseph-sentry joseph-sentry deleted the joseph/upload-metrics branch February 21, 2024 20:04
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.

[API] Instrument upload endpoints
3 participants