reifydb_core/event/
metric.rs1use reifydb_value::value::{datetime::DateTime, duration::Duration};
5use serde::{Deserialize, Serialize};
6
7use crate::{
8 common::CommitVersion, encoded::key::EncodedKey, fingerprint::RequestFingerprint, metric::StatementMetric,
9 profiler::ProfilerCategoryId,
10};
11
12define_event! {
13
14
15 pub struct MultiCommittedEvent {
16 pub writes: Vec<MultiWrite>,
17 pub deletes: Vec<MultiDelete>,
18 pub drops: Vec<MultiDrop>,
19 pub version: CommitVersion,
20 }
21}
22
23#[derive(Clone, Debug)]
24pub struct MultiWrite {
25 pub key: EncodedKey,
26 pub value_bytes: u64,
27}
28
29#[derive(Clone, Debug)]
30pub struct MultiDelete {
31 pub key: EncodedKey,
32 pub value_bytes: u64,
33}
34
35#[derive(Clone, Debug)]
36pub struct MultiDrop {
37 pub key: EncodedKey,
38 pub value_bytes: u64,
39}
40
41define_event! {
42
43 pub struct CdcWrittenEvent {
44 pub entries: Vec<CdcWrite>,
45 pub version: CommitVersion,
46 }
47}
48
49#[derive(Clone, Debug)]
50pub struct CdcWrite {
51 pub key: EncodedKey,
52 pub value_bytes: u64,
53}
54
55#[derive(Clone, Debug)]
56pub struct CdcEviction {
57 pub key: EncodedKey,
58 pub value_bytes: u64,
59}
60
61define_event! {
62
63 pub struct CdcEvictedEvent {
64 pub entries: Vec<CdcEviction>,
65 pub version: CommitVersion,
66 }
67}
68
69#[derive(Debug, Clone, Serialize, Deserialize)]
70pub enum Request {
71 Query {
72 fingerprint: RequestFingerprint,
73 statements: Vec<StatementMetric>,
74 },
75 Command {
76 fingerprint: RequestFingerprint,
77 statements: Vec<StatementMetric>,
78 },
79 Admin {
80 fingerprint: RequestFingerprint,
81 statements: Vec<StatementMetric>,
82 },
83}
84
85define_event! {
86
87 pub struct RequestExecutedEvent {
88 pub request: Request,
89 pub total: Duration,
90 pub compute: Duration,
91 pub success: bool,
92 pub timestamp: DateTime,
93 }
94}
95
96#[derive(Clone, Debug)]
97pub struct ProfilerAggregateRow {
98 pub category: ProfilerCategoryId,
99 pub span_name: String,
100 pub dim_1: Option<String>,
101 pub dim_2: Option<String>,
102 pub calls: u64,
103 pub total_us: u64,
104 pub min_us: u32,
105 pub max_us: u32,
106 pub p50_us: u32,
107 pub p60_us: u32,
108 pub p70_us: u32,
109 pub p75_us: u32,
110 pub p80_us: u32,
111 pub p85_us: u32,
112 pub p90_us: u32,
113 pub p95_us: u32,
114 pub p98_us: u32,
115 pub p99_us: u32,
116 pub extras_sum: [u64; 4],
117}
118
119define_event! {
120
121 pub struct ProfilerSnapshotEvent {
122 pub timestamp: DateTime,
123 pub rows: Vec<ProfilerAggregateRow>,
124 }
125}