Skip to content

capture message #94667

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

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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
19 changes: 10 additions & 9 deletions src/sentry/integrations/utils/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,23 +148,24 @@ def record_event(
"extra": extra,
}

if isinstance(outcome_reason, BaseException):
# Capture exception in Sentry if create_issue is True
if create_issue:
# Capture exception in Sentry if create_issue is True
if create_issue:
if isinstance(outcome_reason, BaseException):
# If the outcome is halted, we want to set the level to warning
if outcome == EventLifecycleOutcome.HALTED:
sentry_sdk.set_level("warning")

event_id = sentry_sdk.capture_exception(
outcome_reason,
)
# Add exception summary but don't include full stack trace in logs
# TODO(iamrajjoshi): Phase this out once everyone is comfortable with just using the sentry issue
log_params["extra"]["exception_summary"] = repr(outcome_reason)

log_params["extra"]["slo_event_id"] = event_id
else:
level = "warning" if outcome == EventLifecycleOutcome.HALTED else "error"
event_id = sentry_sdk.capture_message(repr(outcome_reason), level=level)

# Add exception summary but don't include full stack trace in logs
# TODO(iamrajjoshi): Phase this out once everyone is comfortable with just using the sentry issue
log_params["extra"]["exception_summary"] = repr(outcome_reason)
elif isinstance(outcome_reason, str):
log_params["extra"]["slo_event_id"] = event_id
extra["outcome_reason"] = outcome_reason

if outcome == EventLifecycleOutcome.FAILURE:
Expand Down
Loading