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

chore(integrations): SourceCodeSearchEndpoint metrics #80956

Merged
merged 5 commits into from
Nov 25, 2024

Conversation

mifu67
Copy link
Contributor

@mifu67 mifu67 commented Nov 18, 2024

Add metrics to handle_search_issues, handle_search_repositories, and get.

@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Nov 18, 2024
src/sentry/integrations/gitlab/search.py Dismissed Show dismissed Hide dismissed
src/sentry/integrations/gitlab/search.py Dismissed Show dismissed Hide dismissed
Copy link

codecov bot commented Nov 18, 2024

Codecov Report

Attention: Patch coverage is 98.24561% with 2 lines in your changes missing coverage. Please review.

✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
...ntry/integrations/source_code_management/search.py 96.96% 1 Missing ⚠️
src/sentry/integrations/vsts/search.py 85.71% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #80956      +/-   ##
==========================================
+ Coverage   80.32%   80.33%   +0.01%     
==========================================
  Files        7215     7215              
  Lines      319443   319409      -34     
  Branches    20773    20773              
==========================================
+ Hits       256583   256604      +21     
+ Misses      62466    62411      -55     
  Partials      394      394              

@mifu67 mifu67 marked this pull request as ready for review November 18, 2024 23:39
@mifu67 mifu67 requested review from a team as code owners November 18, 2024 23:39
Copy link
Member

@iamrajjoshi iamrajjoshi left a comment

Choose a reason for hiding this comment

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

where we record failure vs halt all lgtm, just a note about adding a reason for recording halts.

src/sentry/integrations/bitbucket/search.py Outdated Show resolved Hide resolved
src/sentry/integrations/source_code_management/metrics.py Outdated Show resolved Hide resolved
src/sentry/integrations/source_code_management/metrics.py Outdated Show resolved Hide resolved
Copy link
Member

@GabeVillalobos GabeVillalobos left a comment

Choose a reason for hiding this comment

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

Nice work! We just need a bit more context on the halt cases and we should be good to go.

src/sentry/integrations/bitbucket/search.py Outdated Show resolved Hide resolved
src/sentry/integrations/gitlab/search.py Outdated Show resolved Hide resolved
Comment on lines +64 to +65
assert halt1.args[0] == EventLifecycleOutcome.SUCCESS
assert halt2.args[0] == EventLifecycleOutcome.SUCCESS
Copy link
Member

Choose a reason for hiding this comment

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

Super minor naming Nit: these are success metrics, not halts

Copy link
Member

@iamrajjoshi iamrajjoshi left a comment

Choose a reason for hiding this comment

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

Spongebob Thumb

lgtm

@mifu67 mifu67 merged commit 5b70513 into master Nov 25, 2024
50 checks passed
@mifu67 mifu67 deleted the mifu67/scse-observability-metrics branch November 25, 2024 17:37
Comment on lines +55 to +57
logger.info(
"bitbucket.issue-search-no-issue-tracker",
extra={"installation_id": installation.model.id, "repo": repo},
Copy link
Member

Choose a reason for hiding this comment

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

will there be a followup task to remove these extra logs?

response = installation.search_issues(query=full_query, repo=repo)
except ApiError as e:
if "no issue tracker" in str(e):
lifecycle.record_halt(str(SourceCodeSearchEndpointHaltReason.NO_ISSUE_TRACKER))
Copy link
Member

Choose a reason for hiding this comment

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

since SourceCodeSearchEndpointHaltReason is a StrEnum, you shouldn't need to cast it into a string again

except ApiError as err:
if err.code == 403:
lifecycle.record_halt(str(SourceCodeSearchEndpointHaltReason.RATE_LIMITED))
return Response({"detail": "Rate limit exceeded"}, status=429)
Copy link
Member

Choose a reason for hiding this comment

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

lol not sure why we're returning a 429 on a 403 🤔

try:
response = installation.search_projects(query)
except ApiError as e:
lifecyle.record_failure(e)
Copy link
Member

Choose a reason for hiding this comment

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

if a 400 is a user-related error response, should this be halt instead?

Copy link

sentry-io bot commented Nov 29, 2024

Suspect Issues

This pull request was deployed and Sentry observed the following issues:

  • ‼️ IdentityNotValid: HTTP 400 (invalid_grant): AADSTS50057: The user account is disabled. Trace ID: 88ee2567-e310-4a41... /extensions/vsts/search/{organization_id_or_slu... View Issue

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

andrewshie-sentry pushed a commit that referenced this pull request Dec 2, 2024
Add metrics to `handle_search_issues`, `handle_search_repositories`, and
`get`.
@github-actions github-actions bot locked and limited conversation to collaborators Dec 15, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Scope: Backend Automatically applied to PRs that change backend components
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants