Skip to content

Bump kafka schemas#337

Merged
fpacifici merged 4 commits into
mainfrom
fpacifici/update_schemas
Jun 25, 2026
Merged

Bump kafka schemas#337
fpacifici merged 4 commits into
mainfrom
fpacifici/update_schemas

Conversation

@fpacifici

Copy link
Copy Markdown
Collaborator

Unfortunately we need to bump the library to update schemas as we have not done this
https://linear.app/getsentry/issue/STREAM-107/decouple-sentry-stream-from-sentry-kafka-schemas

@fpacifici fpacifici requested a review from a team as a code owner June 25, 2026 18:55
Comment thread sentry_streams/pyproject.toml

@untitaker untitaker left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

something weird is going on in the uv lockfile. why are so many transient deps bumped?

self.spans_list.append(value.payload)
self.total_duration += value.payload["duration_ms"]
span = value.payload
duration_ms = int((span["end_timestamp"] - span["start_timestamp"]) * 1000)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Bug: A KeyError may occur when calculating span duration, as start_timestamp or end_timestamp might be missing from the span data. The code lacks defensive checks.
Severity: HIGH

Suggested Fix

Verify that start_timestamp and end_timestamp are guaranteed to be present in all ingest_spans_v1.SpanEvent messages. If they can be missing, add defensive code to handle their absence, such as using the .get() method with a default value or wrapping the calculation in a try-except KeyError block to safely handle incomplete spans.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.

Location: sentry_streams/sentry_streams/examples/span_helpers.py#L45

Potential issue: The code calculates span duration by directly accessing
`span["end_timestamp"]` and `span["start_timestamp"]`. This calculation assumes both
keys are always present in span data from the `ingest_spans_v1` schema. However, raw
ingestion data may not always include these fields, for example, in the case of
in-progress spans. If a span is processed that is missing either of these keys, the
application will raise a `KeyError`, which could crash the message processing pipeline.
The code does not include any error handling or checks to prevent this.

@fpacifici fpacifici merged commit 24ac621 into main Jun 25, 2026
25 checks passed
@fpacifici fpacifici deleted the fpacifici/update_schemas branch June 25, 2026 21:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants