Skip to content

Conversation

@shashjar
Copy link
Member

@shashjar shashjar commented Nov 18, 2025

Resolves EAP-318.

We're already forwarding occurrences to EAP via the Kafka backend based on the eventstream.eap_forwarding_rate option. This PR adds support for synchronously writing occurrences to EAP via POST request to /tests/entities/eap_items/insert_bytes in the SnubaEventStream. This logic will begin running if eventstream.eap_forwarding_rate is enabled for a self-hosted org.

@linear
Copy link

linear bot commented Nov 18, 2025

@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Nov 18, 2025
)

if resp.status == 200:
metrics.incr("eventstream.eap.occurrence_insert.success")
Copy link
Member Author

Choose a reason for hiding this comment

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

Open to different names for these metrics, currently eventstream.eap.occurrence_insert.success & eventstream.eap.occurrence_insert.failure

Copy link
Contributor

Choose a reason for hiding this comment

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

I might tweak to make clear that these are the synchronous metrics (as opposed to the kafka metrics) somewhow.

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure, will add a tag to the metrics and make the log message more specific

@shashjar shashjar marked this pull request as ready for review November 18, 2025 23:01
@shashjar shashjar requested a review from a team as a code owner November 18, 2025 23:01
try:
resp = snuba._snuba_pool.urlopen(
"POST",
"/tests/entities/eap_items/insert_bytes",
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: This is not the only place we use this URL in the repo... do you think it would be appropriate to break out to a constant? Maybe in a followup PR, probably not worth doing here/now.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, good idea. Will make that change in a follow-up PR.

)

if resp.status == 200:
metrics.incr("eventstream.eap.occurrence_insert.success")
Copy link
Contributor

Choose a reason for hiding this comment

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

I might tweak to make clear that these are the synchronous metrics (as opposed to the kafka metrics) somewhow.

@shashjar shashjar merged commit 34a654f into master Nov 20, 2025
65 checks passed
@shashjar shashjar deleted the snuba-event-stream-synchronous-write-of-occurrences-to-eap branch November 20, 2025 21:50
@codecov
Copy link

codecov bot commented Nov 20, 2025

Codecov Report

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

Files with missing lines Patch % Lines
src/sentry/eventstream/snuba.py 18.18% 9 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           master   #103566      +/-   ##
===========================================
+ Coverage   80.34%    80.60%   +0.25%     
===========================================
  Files        9255      9269      +14     
  Lines      395203    395930     +727     
  Branches    25201     25201              
===========================================
+ Hits       317527    319124    +1597     
+ Misses      77246     76376     -870     
  Partials      430       430              

shashjar added a commit that referenced this pull request Nov 20, 2025
…103780)

Follow-up to #103566.

Fixes
[ID-1112](https://linear.app/getsentry/issue/ID-1112/extract-testsentitieseap-itemsinsert-bytes-endpoint-name-out-into-a).

No change in logic; creates a constant for the EAP insert items endpoint
path ("/tests/entities/eap_items/insert_bytes") in a new utils file
`src/sentry/utils/eap.py`.
shashjar added a commit that referenced this pull request Nov 21, 2025
#103857)

Follow-up to #103566.

The previous logic did not correctly serialize the trace item when
making a POST request to the "/tests/entities/eap_items/insert_bytes"
endpoint. With this updated logic we should see successful EAP inserts
(example below).

Querying via `docker exec -it snuba-clickhouse-1 clickhouse-client
--query "SELECT item_id, project_id, organization_id, trace_id,
item_type, timestamp FROM eap_items_1_local ORDER BY timestamp DESC
LIMIT 5 FORMAT Pretty"`.

Before ingesting new event:
<img width="1061" height="183" alt="image"
src="https://github.com/user-attachments/assets/9d2eca89-8fc9-4ab5-9fb3-ae34fd862ef8"
/>

After ingesting new event:
<img width="1055" height="186" alt="image"
src="https://github.com/user-attachments/assets/18caf67e-4d4b-4232-a2a9-b00225a52396"
/>
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