From 3073a21a710d83a658a7b0371f5236b9d1a24f21 Mon Sep 17 00:00:00 2001 From: cliffordxing Date: Tue, 25 Nov 2025 14:50:43 -0800 Subject: [PATCH 1/2] Include timestamp Attribute in Trace Item --- src/sentry/replays/usecases/ingest/event_parser.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/sentry/replays/usecases/ingest/event_parser.py b/src/sentry/replays/usecases/ingest/event_parser.py index b3ceb8749575a1..84e5b2331a3249 100644 --- a/src/sentry/replays/usecases/ingest/event_parser.py +++ b/src/sentry/replays/usecases/ingest/event_parser.py @@ -367,6 +367,7 @@ def as_trace_item( # eventually use the trace_id in its rightful position. trace_item_context["attributes"]["replay_id"] = context["replay_id"] trace_item_context["attributes"]["segment_id"] = context["segment_id"] + trace_item_context["attributes"]["timestamp"] = int(trace_item_context["timestamp"]) return new_trace_item( { From 1dbf899ffab0d808096c31eb0e8e442828a3bd75 Mon Sep 17 00:00:00 2001 From: cliffordxing Date: Tue, 25 Nov 2025 17:03:44 -0800 Subject: [PATCH 2/2] Add unit test and sentry.timestamp --- .../endpoints/organization_replay_details.py | 17 +++++++++++------ .../replays/usecases/ingest/event_parser.py | 1 - src/sentry/testutils/cases.py | 1 - .../endpoints/test_query_replay_instance_eap.py | 3 +++ 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/sentry/replays/endpoints/organization_replay_details.py b/src/sentry/replays/endpoints/organization_replay_details.py index 4ce642746725aa..08a450e688c4c4 100644 --- a/src/sentry/replays/endpoints/organization_replay_details.py +++ b/src/sentry/replays/endpoints/organization_replay_details.py @@ -39,8 +39,8 @@ def query_replay_instance_eap( select = [ Column("replay_id"), Function("min", parameters=[Column("project_id")], alias="agg_project_id"), - Function("min", parameters=[Column("timestamp")], alias="started_at"), - Function("max", parameters=[Column("timestamp")], alias="finished_at"), + Function("min", parameters=[Column("sentry.timestamp")], alias="started_at"), + Function("max", parameters=[Column("sentry.timestamp")], alias="finished_at"), Function("count", parameters=[Column("segment_id")], alias="count_segments"), Function("sum", parameters=[Column("count_error_events")], alias="count_errors"), Function("sum", parameters=[Column("count_warning_events")], alias="count_warnings"), @@ -51,7 +51,10 @@ def query_replay_instance_eap( Column("click_is_dead"), Function( "greaterOrEquals", - [Column("timestamp"), int(datetime(year=2023, month=7, day=24).timestamp())], + [ + Column("sentry.timestamp"), + int(datetime(year=2023, month=7, day=24).timestamp()), + ], ), ], alias="count_dead_clicks", @@ -62,7 +65,10 @@ def query_replay_instance_eap( Column("click_is_rage"), Function( "greaterOrEquals", - [Column("timestamp"), int(datetime(year=2023, month=7, day=24).timestamp())], + [ + Column("sentry.timestamp"), + int(datetime(year=2023, month=7, day=24).timestamp()), + ], ), ], alias="count_rage_clicks", @@ -84,8 +90,7 @@ def query_replay_instance_eap( attribute_types={ "replay_id": str, "project_id": int, - "timestamp": int, - "replay_start_timestamp": int, + "sentry.timestamp": int, "segment_id": int, "is_archived": int, "count_error_events": int, diff --git a/src/sentry/replays/usecases/ingest/event_parser.py b/src/sentry/replays/usecases/ingest/event_parser.py index 84e5b2331a3249..b3ceb8749575a1 100644 --- a/src/sentry/replays/usecases/ingest/event_parser.py +++ b/src/sentry/replays/usecases/ingest/event_parser.py @@ -367,7 +367,6 @@ def as_trace_item( # eventually use the trace_id in its rightful position. trace_item_context["attributes"]["replay_id"] = context["replay_id"] trace_item_context["attributes"]["segment_id"] = context["segment_id"] - trace_item_context["attributes"]["timestamp"] = int(trace_item_context["timestamp"]) return new_trace_item( { diff --git a/src/sentry/testutils/cases.py b/src/sentry/testutils/cases.py index 938b741d6a5fce..e73f1a0c42a33a 100644 --- a/src/sentry/testutils/cases.py +++ b/src/sentry/testutils/cases.py @@ -3860,7 +3860,6 @@ def create_eap_replay_breadcrumb( "replay_id": replay_id, "segment_id": segment_id, "project_id": project.id, - "timestamp": int(timestamp.timestamp()), "category": category, } diff --git a/tests/sentry/replays/endpoints/test_query_replay_instance_eap.py b/tests/sentry/replays/endpoints/test_query_replay_instance_eap.py index 089e317cd758ac..21995ec504f2ae 100644 --- a/tests/sentry/replays/endpoints/test_query_replay_instance_eap.py +++ b/tests/sentry/replays/endpoints/test_query_replay_instance_eap.py @@ -116,6 +116,9 @@ def test_eap_replay_query(self) -> None: assert "started_at" in replay1_data assert "finished_at" in replay1_data + assert replay1_data["started_at"] is not None, "started_at should not be None" + assert replay1_data["finished_at"] is not None, "finished_at should not be None" + assert replay1_data["count_dead_clicks"] == 3, "2 DEAD_CLICK + 1 RAGE_CLICK = 3 dead" assert replay1_data["count_rage_clicks"] == 1, "1 RAGE_CLICK = 1 rage"