|
8 | 8 | from sentry_kafka_schemas.schema_types.buffered_segments_v1 import SegmentSpan
|
9 | 9 |
|
10 | 10 | from sentry import options
|
11 |
| -from sentry.constants import INSIGHT_MODULE_FILTERS |
| 11 | +from sentry.constants import INSIGHT_MODULE_FILTERS, DataCategory |
12 | 12 | from sentry.dynamic_sampling.rules.helpers.latest_releases import record_latest_release
|
13 | 13 | from sentry.event_manager import INSIGHT_MODULE_TO_PROJECT_FLAG_NAME
|
14 | 14 | from sentry.issues.grouptype import PerformanceStreamedSpansGroupTypeExperimental
|
|
32 | 32 | from sentry.spans.grouping.api import load_span_grouping_config
|
33 | 33 | from sentry.utils import metrics
|
34 | 34 | from sentry.utils.dates import to_datetime
|
| 35 | +from sentry.utils.outcomes import Outcome, track_outcome |
35 | 36 | from sentry.utils.projectflags import set_project_flag_and_signal
|
36 | 37 |
|
37 | 38 | logger = logging.getLogger(__name__)
|
@@ -64,6 +65,7 @@ def process_segment(unprocessed_spans: list[SegmentSpan]) -> list[Span]:
|
64 | 65 | _create_models(segment_span, project)
|
65 | 66 | _detect_performance_problems(segment_span, spans, project)
|
66 | 67 | _record_signals(segment_span, spans, project)
|
| 68 | + _track_outcomes(segment_span, spans) |
67 | 69 |
|
68 | 70 | return spans
|
69 | 71 |
|
@@ -260,3 +262,22 @@ def _record_signals(segment_span: Span, spans: list[Span], project: Project) ->
|
260 | 262 | first_insight_span_received,
|
261 | 263 | module=module,
|
262 | 264 | )
|
| 265 | + |
| 266 | + |
| 267 | +@metrics.wraps("spans.consumers.process_segments.record_outcomes") |
| 268 | +def _track_outcomes(segment_span: Span, spans: list[Span]) -> None: |
| 269 | + """ |
| 270 | + Record outcomes for all spans in the segment. |
| 271 | + """ |
| 272 | + |
| 273 | + track_outcome( |
| 274 | + org_id=segment_span["organization_id"], |
| 275 | + project_id=segment_span["project_id"], |
| 276 | + key_id=cast(int | None, segment_span.get("key_id", None)), |
| 277 | + outcome=Outcome.ACCEPTED, |
| 278 | + reason=None, |
| 279 | + timestamp=to_datetime(segment_span["received"]), |
| 280 | + event_id=None, |
| 281 | + category=DataCategory.SPAN_INDEXED, |
| 282 | + quantity=len(spans), |
| 283 | + ) |
0 commit comments