1use time::OffsetDateTime;
4
5use crate::executor::TokioRuntimeMetrics;
6
7use super::{ConfigTableField, ConfigTableFieldType, Error, row_with_ts};
8
9impl TokioRuntimeMetrics {
10 pub fn tsdb_fields() -> Vec<ConfigTableField> {
12 vec![
13 ConfigTableField {
14 field_name: "workers_count".to_string(),
15 data_type: ConfigTableFieldType::NumericInteger,
16 },
17 ConfigTableField {
18 field_name: "total_park_count".to_string(),
19 data_type: ConfigTableFieldType::NumericInteger,
20 },
21 ConfigTableField {
22 field_name: "max_park_count".to_string(),
23 data_type: ConfigTableFieldType::NumericInteger,
24 },
25 ConfigTableField {
26 field_name: "min_park_count".to_string(),
27 data_type: ConfigTableFieldType::NumericInteger,
28 },
29 ConfigTableField {
30 field_name: "total_busy_duration".to_string(),
31 data_type: ConfigTableFieldType::NumericDoublePrecision,
32 },
33 ConfigTableField {
34 field_name: "max_busy_duration".to_string(),
35 data_type: ConfigTableFieldType::NumericDoublePrecision,
36 },
37 ConfigTableField {
38 field_name: "min_busy_duration".to_string(),
39 data_type: ConfigTableFieldType::NumericDoublePrecision,
40 },
41 ConfigTableField {
42 field_name: "global_queue_depth".to_string(),
43 data_type: ConfigTableFieldType::NumericInteger,
44 },
45 ConfigTableField {
46 field_name: "mean_poll_duration".to_string(),
47 data_type: ConfigTableFieldType::NumericDoublePrecision,
48 },
49 ConfigTableField {
50 field_name: "mean_poll_duration_worker_min".to_string(),
51 data_type: ConfigTableFieldType::NumericDoublePrecision,
52 },
53 ConfigTableField {
54 field_name: "mean_poll_duration_worker_max".to_string(),
55 data_type: ConfigTableFieldType::NumericDoublePrecision,
56 },
57 ConfigTableField {
58 field_name: "total_noop_count".to_string(),
59 data_type: ConfigTableFieldType::NumericInteger,
60 },
61 ConfigTableField {
62 field_name: "max_noop_count".to_string(),
63 data_type: ConfigTableFieldType::NumericInteger,
64 },
65 ConfigTableField {
66 field_name: "min_noop_count".to_string(),
67 data_type: ConfigTableFieldType::NumericInteger,
68 },
69 ConfigTableField {
70 field_name: "total_steal_count".to_string(),
71 data_type: ConfigTableFieldType::NumericInteger,
72 },
73 ConfigTableField {
74 field_name: "max_steal_count".to_string(),
75 data_type: ConfigTableFieldType::NumericInteger,
76 },
77 ConfigTableField {
78 field_name: "min_steal_count".to_string(),
79 data_type: ConfigTableFieldType::NumericInteger,
80 },
81 ConfigTableField {
82 field_name: "total_steal_operations".to_string(),
83 data_type: ConfigTableFieldType::NumericInteger,
84 },
85 ConfigTableField {
86 field_name: "max_steal_operations".to_string(),
87 data_type: ConfigTableFieldType::NumericInteger,
88 },
89 ConfigTableField {
90 field_name: "min_steal_operations".to_string(),
91 data_type: ConfigTableFieldType::NumericInteger,
92 },
93 ConfigTableField {
94 field_name: "num_remote_schedules".to_string(),
95 data_type: ConfigTableFieldType::NumericInteger,
96 },
97 ConfigTableField {
98 field_name: "total_local_schedule_count".to_string(),
99 data_type: ConfigTableFieldType::NumericInteger,
100 },
101 ConfigTableField {
102 field_name: "max_local_schedule_count".to_string(),
103 data_type: ConfigTableFieldType::NumericInteger,
104 },
105 ConfigTableField {
106 field_name: "min_local_schedule_count".to_string(),
107 data_type: ConfigTableFieldType::NumericInteger,
108 },
109 ConfigTableField {
110 field_name: "total_overflow_count".to_string(),
111 data_type: ConfigTableFieldType::NumericInteger,
112 },
113 ConfigTableField {
114 field_name: "max_overflow_count".to_string(),
115 data_type: ConfigTableFieldType::NumericInteger,
116 },
117 ConfigTableField {
118 field_name: "min_overflow_count".to_string(),
119 data_type: ConfigTableFieldType::NumericInteger,
120 },
121 ConfigTableField {
122 field_name: "total_polls_count".to_string(),
123 data_type: ConfigTableFieldType::NumericInteger,
124 },
125 ConfigTableField {
126 field_name: "max_polls_count".to_string(),
127 data_type: ConfigTableFieldType::NumericInteger,
128 },
129 ConfigTableField {
130 field_name: "min_polls_count".to_string(),
131 data_type: ConfigTableFieldType::NumericInteger,
132 },
133 ConfigTableField {
134 field_name: "total_local_queue_depth".to_string(),
135 data_type: ConfigTableFieldType::NumericInteger,
136 },
137 ConfigTableField {
138 field_name: "max_local_queue_depth".to_string(),
139 data_type: ConfigTableFieldType::NumericInteger,
140 },
141 ConfigTableField {
142 field_name: "min_local_queue_depth".to_string(),
143 data_type: ConfigTableFieldType::NumericInteger,
144 },
145 ConfigTableField {
146 field_name: "blocking_queue_depth".to_string(),
147 data_type: ConfigTableFieldType::NumericInteger,
148 },
149 ConfigTableField {
150 field_name: "live_tasks_count".to_string(),
151 data_type: ConfigTableFieldType::NumericInteger,
152 },
153 ConfigTableField {
154 field_name: "blocking_threads_count".to_string(),
155 data_type: ConfigTableFieldType::NumericInteger,
156 },
157 ConfigTableField {
158 field_name: "idle_blocking_threads_count".to_string(),
159 data_type: ConfigTableFieldType::NumericInteger,
160 },
161 ConfigTableField {
162 field_name: "budget_forced_yield_count".to_string(),
163 data_type: ConfigTableFieldType::NumericInteger,
164 },
165 ConfigTableField {
166 field_name: "io_driver_ready_count".to_string(),
167 data_type: ConfigTableFieldType::NumericInteger,
168 },
169 ConfigTableField {
170 field_name: "busy_ratio".to_string(),
171 data_type: ConfigTableFieldType::NumericDoublePrecision,
172 },
173 ]
174 }
175
176 pub fn tsdb_row(self) -> Result<String, Error> {
178 let time = OffsetDateTime::now_utc();
179
180 row_with_ts(
181 &time,
182 &[
183 self.workers_count.to_string(),
184 self.total_park_count.to_string(),
185 self.max_park_count.to_string(),
186 self.min_park_count.to_string(),
187 (self.total_busy_duration.as_nanos() as f64 / 1_000_000.0).to_string(),
188 (self.max_busy_duration.as_nanos() as f64 / 1_000_000.0).to_string(),
189 (self.min_busy_duration.as_nanos() as f64 / 1_000_000.0).to_string(),
190 self.global_queue_depth.to_string(),
191 (self.mean_poll_duration.as_nanos() as f64 / 1_000_000.0).to_string(),
192 (self.mean_poll_duration_worker_min.as_nanos() as f64 / 1_000_000.0).to_string(),
193 (self.mean_poll_duration_worker_max.as_nanos() as f64 / 1_000_000.0).to_string(),
194 self.total_noop_count.to_string(),
195 self.max_noop_count.to_string(),
196 self.min_noop_count.to_string(),
197 self.total_steal_count.to_string(),
198 self.max_steal_count.to_string(),
199 self.min_steal_count.to_string(),
200 self.total_steal_operations.to_string(),
201 self.max_steal_operations.to_string(),
202 self.min_steal_operations.to_string(),
203 self.num_remote_schedules.to_string(),
204 self.total_local_schedule_count.to_string(),
205 self.max_local_schedule_count.to_string(),
206 self.min_local_schedule_count.to_string(),
207 self.total_overflow_count.to_string(),
208 self.max_overflow_count.to_string(),
209 self.min_overflow_count.to_string(),
210 self.total_polls_count.to_string(),
211 self.max_polls_count.to_string(),
212 self.min_polls_count.to_string(),
213 self.total_local_queue_depth.to_string(),
214 self.max_local_queue_depth.to_string(),
215 self.min_local_queue_depth.to_string(),
216 self.blocking_queue_depth.to_string(),
217 self.live_tasks_count.to_string(),
218 self.blocking_threads_count.to_string(),
219 self.idle_blocking_threads_count.to_string(),
220 self.budget_forced_yield_count.to_string(),
221 self.io_driver_ready_count.to_string(),
222 self.busy_ratio.to_string(),
223 ],
224 )
225 }
226}