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

perf: emit killswitch metrics when needed #71608

Closed
wants to merge 1 commit into from
Closed
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
2 changes: 1 addition & 1 deletion src/sentry/killswitches.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ def killswitch_matches_context(killswitch_name: str, context: Context, emit_metr
option_value = options.get(killswitch_name)
rv = _value_matches(killswitch_name, option_value, context)

if emit_metrics:
if emit_metrics and options.get("system.emit-kill-switch-metrics"):
Copy link
Member

Choose a reason for hiding this comment

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

I didn't see any callers that set emit_metrics=False. If you wanted to make a smaller change, you could have the option drive the sampling rate of the metric instead of dropping the metric entirely.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, but what is the purpose of having this metric in the first place? If killswitch is not enabled (I assume for 99% of the cases it is not enabled), this metric will behave similar to @metrics.wraps("ingest_consumer.process_event").

# metrics can have a meaningful performance impact, so allow caller to opt out
# TODO: re-evaluate after we make metric collection aysnc.
metrics.incr(
Expand Down
6 changes: 6 additions & 0 deletions src/sentry/options/defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,12 @@
default=False,
flags=FLAG_AUTOMATOR_MODIFIABLE,
)
# Enable kill switch metrics
register(
"system.emit-kill-switch-metrics",
default=False,
flags=FLAG_AUTOMATOR_MODIFIABLE,
)
# Redis
register(
"redis.clusters",
Expand Down
Loading