Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
9 changes: 5 additions & 4 deletions src/sentry/scm/private/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,15 +112,16 @@ def exec_provider_fn[P: Provider, T](
if provider.is_rate_limited(referrer):
raise SCMCodedError(provider, referrer, code="rate_limit_exceeded")

provider_name = provider.__class__.__name__

try:
result = provider_fn()
record_count(
"sentry.scm.actions.success_by_provider", 1, {"provider": provider.__class__.__name__}
)
record_count("sentry.scm.actions.success_by_provider", 1, {"provider": provider_name})
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

where do these metrics go? would it be better to have a single metric name w/ 2 attributes?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yes but cardinality comes at a premium and this reduces it.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

yeah that's why I was wondering where we save these metrics

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

oh I see. datadog and sentry.

record_count("sentry.scm.actions.success_by_referrer", 1, {"referrer": referrer})
return result
except SCMError:
raise
except Exception as e:
record_count("sentry.scm.actions.failed", 1, {})
record_count("sentry.scm.actions.failed_by_provider", 1, {"provider": provider_name})
record_count("sentry.scm.actions.failed_by_referrer", 1, {"referrer": referrer})
raise SCMUnhandledException from e
5 changes: 4 additions & 1 deletion tests/sentry/scm/unit/test_scm_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -751,7 +751,10 @@ def get_branch(self, branch, request_options=None):
assert isinstance(scm, GetBranchProtocol)
scm.get_branch(branch="main")

assert metrics == [("sentry.scm.actions.failed", 1, {})]
assert metrics == [
("sentry.scm.actions.failed_by_provider", 1, {"provider": ExplodingProvider.__name__}),
("sentry.scm.actions.failed_by_referrer", 1, {"referrer": "shared"}),
]


def test_exec_passes_custom_referrer():
Expand Down
Loading