query_runtime/observability/
cache_fill_event.rs1use std::time::Duration;
4
5#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
7pub enum LakehouseCacheFillOutcome {
8 Completed,
10 Failed,
12 Abandoned,
16}
17
18#[derive(Debug, Clone, PartialEq, Eq)]
20pub struct LakehouseCacheFillErrorEvent {
21 #[doc(hidden)]
22 pub code: String,
23 #[doc(hidden)]
24 pub kind: String,
25 #[doc(hidden)]
26 pub status: String,
27 #[doc(hidden)]
28 pub operation: String,
29}
30
31#[derive(Debug, Clone, PartialEq, Eq)]
33pub struct LakehouseCacheFillEvent {
34 #[doc(hidden)]
35 pub outcome: LakehouseCacheFillOutcome,
36 #[doc(hidden)]
37 pub bytes: Option<u64>,
38 #[doc(hidden)]
39 pub elapsed: Duration,
40 #[doc(hidden)]
41 pub cache_path_hash: String,
42 #[doc(hidden)]
43 pub stable_id_hash: String,
44 #[doc(hidden)]
45 pub file_index: Option<usize>,
46 #[doc(hidden)]
47 pub chunk_index: Option<usize>,
48 #[doc(hidden)]
49 pub error: Option<LakehouseCacheFillErrorEvent>,
50}
51
52#[derive(Debug, Clone, PartialEq, Eq)]
54pub struct LakehouseCacheFillEventSnapshot {
55 pub outcome: &'static str,
57 pub bytes: Option<u64>,
59 pub elapsed: Duration,
61 pub cache_path_hash: String,
63 pub stable_id_hash: String,
65 pub file_index: Option<usize>,
67 pub chunk_index: Option<usize>,
69 pub error_code: Option<String>,
71 pub error_kind: Option<String>,
73 pub error_status: Option<String>,
75 pub error_operation: Option<String>,
77}
78
79impl LakehouseCacheFillOutcome {
80 const fn as_str(self) -> &'static str {
81 match self {
82 Self::Completed => "completed",
83 Self::Failed => "failed",
84 Self::Abandoned => "abandoned",
85 }
86 }
87}
88
89impl From<&LakehouseCacheFillEvent> for LakehouseCacheFillEventSnapshot {
90 fn from(event: &LakehouseCacheFillEvent) -> Self {
91 Self {
92 outcome: event.outcome.as_str(),
93 bytes: event.bytes,
94 elapsed: event.elapsed,
95 cache_path_hash: event.cache_path_hash.clone(),
96 stable_id_hash: event.stable_id_hash.clone(),
97 file_index: event.file_index,
98 chunk_index: event.chunk_index,
99 error_code: event.error.as_ref().map(|error| error.code.clone()),
100 error_kind: event.error.as_ref().map(|error| error.kind.clone()),
101 error_status: event.error.as_ref().map(|error| error.status.clone()),
102 error_operation: event.error.as_ref().map(|error| error.operation.clone()),
103 }
104 }
105}