Skip to content

Conversation

@jjbayer
Copy link
Member

@jjbayer jjbayer commented Sep 24, 2025

See https://linear.app/getsentry/project/align-sentry-span-kafka-schema-with-span-v2-a77fced29f22/overview.

Requires getsentry/sentry-kafka-schemas#440.

Closes: INGEST-533, INGEST-535, INGEST-536, INGEST-539


Note

Switch span processing from legacy data fields to Span V2 attributes, updating buffers, consumers, enrichment, conversion, grouping, insights, and tests.

  • Spans processing (Span V2 migration):
    • Replace data[...] with attributes[...] across enrichment, shims, message handling, and conversion; add attribute_value helper and Attributes types.
    • Rename precise timestamps to start_timestamp/end_timestamp; remove end_timestamp_precise usage; compute and store sentry.duration_ms and sentry.exclusive_time_ms in attributes.
    • Buffer: change Span.end_timestamp_precise -> end_timestamp; when flushing, set attributes.sentry.segment.id and attributes.sentry.is_segment instead of top-level fields.
    • Conversion: build TraceItem.attributes from attributes + selected top-level fields; rename some attributes (e.g., sentry.description -> sentry.raw_description); encode span links with allowed attribute keys.
    • Enrichment: infer shared/mobile flags, TTID/TTFD, and exclusive time into attributes (not data).
    • Message pipeline: read segment_id/flags from attributes, update breakdowns into attributes, and use attributes for releases/environments/signals.
    • Grouping: fall back to attribute-based description and transaction for segment grouping.
    • Insights: add FilterSpan.from_span_attributes and use it for module detection.
  • Tests:
    • Update fixtures/expectations to Span V2 (attributes, new timestamps, buffer flush output).

Written by Cursor Bugbot for commit e15c5ee. This will update automatically on new commits. Configure here.

@linear
Copy link

linear bot commented Sep 24, 2025

@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Sep 24, 2025
@codecov
Copy link

codecov bot commented Sep 24, 2025

⚠️ JUnit XML file not found

The CLI was unable to find any JUnit XML files to upload.
For more help, visit our troubleshooting guide.

@jjbayer jjbayer changed the title ref(spans): Use new kafka schema in span / segment consumer ref(spans): Stop using span.data in span consumers Sep 24, 2025
@github-actions github-actions bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Sep 30, 2025
@github-actions
Copy link
Contributor

🚨 Warning: This pull request contains Frontend and Backend changes!

It's discouraged to make changes to Sentry's Frontend and Backend in a single pull request. The Frontend and Backend are not atomically deployed. If the changes are interdependent of each other, they must be separated into two pull requests and be made forward or backwards compatible, such that the Backend or Frontend can be safely deployed independently.

Have questions? Please ask in the #discuss-dev-infra channel.

@jjbayer jjbayer changed the title ref(spans): Stop using span.data in span consumers ref(spans): Use Span V2 kafka schema in span consumers Sep 30, 2025


def _find_segment_span(spans: list[SegmentSpan]) -> SegmentSpan | None:
def _find_segment_span(spans: list[SpanEvent]) -> SpanEvent | None:
Copy link
Member Author

Choose a reason for hiding this comment

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

Both kafka topics ("ingest-spans" and "buffered-segments") now use the same span format.

@jjbayer
Copy link
Member Author

jjbayer commented Sep 30, 2025

Tests will be red until getsentry/sentry-kafka-schemas#440 gets merged.

cursor[bot]

This comment was marked as outdated.

I64_MAX = 2**63 - 1

FIELD_TO_ATTRIBUTE = {
"description": "sentry.raw_description",
Copy link
Member

Choose a reason for hiding this comment

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

This is no longer necessary because sentry.description is instead renamed to sentry.raw_description?

Copy link
Member Author

Choose a reason for hiding this comment

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

Exactly!

@jjbayer jjbayer added Do Not Merge Don't merge and removed Scope: Frontend Automatically applied to PRs that change frontend components labels Oct 1, 2025
@jjbayer jjbayer requested a review from a team as a code owner October 2, 2025 04:31
github-merge-queue bot pushed a commit to getsentry/relay that referenced this pull request Oct 2, 2025
Before we merge getsentry/sentry#100181, we
should make sure that there is no way back for the kafka producer (i.e.
relay) to produce old span messages.

- [ ] Handle kafka schema validation errors in integration tests.

ref: INGEST-535
@jjbayer jjbayer merged commit b660982 into master Oct 2, 2025
66 checks passed
@jjbayer jjbayer deleted the feat/spans-use-new-schema branch October 2, 2025 12:21
@jjbayer jjbayer removed the Do Not Merge Don't merge label Oct 2, 2025
github-merge-queue bot pushed a commit to getsentry/relay that referenced this pull request Oct 8, 2025
The span consumers in sentry have been [updated to use the new kafka
span schema](getsentry/sentry#100181), so we
can remove legacy fields from the producer.

Fixes INGEST-537
@github-actions github-actions bot locked and limited conversation to collaborators Oct 17, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

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