优化
This commit is contained in:
+18
@@ -2,6 +2,7 @@ package com.baiyue.eventbridge.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baiyue.eventbridge.domain.BridgeInbox;
|
||||
import com.baiyue.eventbridge.metrics.InboxMetricsSnapshot;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
@@ -60,4 +61,21 @@ public interface BridgeInboxMapper extends BaseMapper<BridgeInbox> {
|
||||
WHERE event_id=#{eventId} AND status='DEAD'
|
||||
""")
|
||||
int replayDead(@Param("eventId") String eventId, @Param("reason") String reason);
|
||||
|
||||
/**
|
||||
* Scheduled observability aggregation. The status predicate uses idx_bridge_inbox_consume;
|
||||
* Prometheus collection never invokes this query directly.
|
||||
*/
|
||||
@Select("""
|
||||
SELECT target_region AS targetRegion, event_type AS eventType,
|
||||
SUM(CASE WHEN status IN ('RECEIVED','RETRY','PROCESSING') THEN 1 ELSE 0 END) AS backlogCount,
|
||||
COALESCE(TIMESTAMPDIFF(MICROSECOND,
|
||||
MIN(CASE WHEN status IN ('RECEIVED','RETRY','PROCESSING') THEN received_at END),
|
||||
CURRENT_TIMESTAMP(3)) / 1000000.0, 0) AS oldestPendingAgeSeconds,
|
||||
SUM(CASE WHEN status='DEAD' THEN 1 ELSE 0 END) AS deadCount
|
||||
FROM bridge_inbox
|
||||
WHERE status IN ('RECEIVED','RETRY','PROCESSING','DEAD')
|
||||
GROUP BY target_region, event_type
|
||||
""")
|
||||
List<InboxMetricsSnapshot> observabilitySnapshots();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user