Skip to content

Commit b3a134e

Browse files
feat(crons): Record guage metric for total processing time (#59064)
We want to record metrics on how long it took for a check-in message to make it's way from being put into kafka (`LogAppendTime`) to fully completing the check-in process. This gauge gives us that.
1 parent cae1684 commit b3a134e

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/sentry/monitors/consumers/monitor_consumer.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,7 @@ def transform_checkin_uuid(
221221

222222
def _process_checkin(
223223
params: CheckinPayload,
224+
message_ts: datetime,
224225
start_time: datetime,
225226
project_id: int,
226227
source_sdk: str,
@@ -549,6 +550,14 @@ def update_existing_check_in(
549550
else:
550551
mark_ok(check_in, ts=start_time)
551552

553+
# how long in wall-clock time did it take for us to process this
554+
# check-in. This records from when the message was first appended
555+
# into the Kafka topic until we just completed processing.
556+
#
557+
# XXX: We are ONLY recording this metric for completed check-ins.
558+
delay = datetime.now() - message_ts
559+
metrics.gauge("monitors.checkin.completion_time", delay.total_seconds())
560+
552561
metrics.incr(
553562
"monitors.checkin.result",
554563
tags={**metric_kwargs, "status": "complete"},
@@ -603,7 +612,7 @@ def _process_message(
603612
project_id = int(wrapper["project_id"])
604613
source_sdk = wrapper["sdk"]
605614

606-
_process_checkin(params, start_time, project_id, source_sdk, txn)
615+
_process_checkin(params, ts, start_time, project_id, source_sdk, txn)
607616

608617

609618
class StoreMonitorCheckInStrategyFactory(ProcessingStrategyFactory[KafkaPayload]):

0 commit comments

Comments
 (0)