Skip to content

Conversation

@k-fish
Copy link
Member

@k-fish k-fish commented Dec 12, 2025

Add TRACE_ITEM_METRIC to valid event types for performance alerts. Update entity subscription to use TraceMetrics module for trace metric alerts.

Additionally, this adds more thorough validation for EAP queries, specifically for trace_metrics as they have a unique aggregate syntax (instead of count(column) it's almost always count(column, <metric tuple>)) that we need to enforce. This should work on both sides of old and new alerts so we're forwards and backwards compatible during the workflow switch over.

Add TRACE_ITEM_METRIC to valid event types for performance alerts.
Update entity subscription to use TraceMetrics module for trace metric alerts.
@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Dec 12, 2025
@codecov
Copy link

codecov bot commented Dec 12, 2025

Codecov Report

❌ Patch coverage is 97.46835% with 2 lines in your changes missing coverage. Please review.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/sentry/explore/utils.py 75.00% 1 Missing ⚠️
src/sentry/incidents/metric_issue_detector.py 93.33% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           master   #104901      +/-   ##
===========================================
- Coverage   80.64%    80.56%   -0.08%     
===========================================
  Files        9335      9343       +8     
  Lines      403011    402073     -938     
  Branches    25695     25695              
===========================================
- Hits       325001    323944    -1057     
- Misses      77544     77663     +119     
  Partials      466       466              

@getsantry
Copy link
Contributor

getsantry bot commented Jan 3, 2026

This pull request has gone three weeks without activity. In another week, I will close it.

But! If you comment or otherwise update it, I will reset the clock, and if you add the label WIP, I will leave it alone unless WIP is removed ... forever!


"A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀

@getsantry getsantry bot added the Stale label Jan 3, 2026
@k-fish k-fish marked this pull request as ready for review January 6, 2026 16:13
@k-fish k-fish requested review from a team as code owners January 6, 2026 16:13
@getsantry getsantry bot removed the Stale label Jan 7, 2026
Add TRACE_ITEM_METRIC to valid event types for performance alerts.
Update entity subscription to use TraceMetrics module for trace metric alerts.
logger.exception("Invalid trace metrics aggregate: %s %s", aggregate, e)
raise serializers.ValidationError(
{"aggregate": f"Invalid trace metrics aggregate: {aggregate}"}
)
Copy link
Contributor

Choose a reason for hiding this comment

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

Validation error loses specific error message details

Low Severity

When validate_trace_metrics_aggregate catches an InvalidSearchQuery exception, it discards the specific error message from e and replaces it with a generic message. This includes cases where trace_metric is None (which raises an InvalidSearchQuery with "must specify metric name, type, and unit") and errors from resolve_function. The original error is only logged but not returned to the user, making it difficult to understand why a trace metrics aggregate is invalid.

Fix in Cursor Fix in Web

def test_extract_eap_metrics_alert(self) -> None:
assert (
get_alert_type_from_aggregate_dataset(
"count(span.duration)", Dataset.EventsAnalyticsPlatform
Copy link
Member

Choose a reason for hiding this comment

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

should we leave this one in?

@k-fish k-fish requested a review from a team as a code owner January 13, 2026 19:28
@k-fish k-fish force-pushed the feat/tracemetrics/add-alerts-backend branch from ddfd167 to dc03815 Compare January 13, 2026 20:15
@getsentry getsentry deleted a comment from sentry bot Jan 13, 2026
@k-fish k-fish removed the request for review from a team January 13, 2026 20:16
@k-fish k-fish merged commit d4c45d6 into master Jan 13, 2026
66 checks passed
@k-fish k-fish deleted the feat/tracemetrics/add-alerts-backend branch January 13, 2026 20:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Backend Automatically applied to PRs that change backend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants