prometheus/
plain_model.rs

1// Copyright 2019 TiKV Project Authors. Licensed under Apache-2.0.
2
3//! Non-generated version of required structures provided by the protobuf.
4//! This version is used when the `protobuf` feature is turned off.
5
6#![allow(missing_docs)]
7
8#[derive(PartialEq, Clone, Default, Debug)]
9pub struct LabelPair {
10    name: String,
11    value: String,
12}
13
14impl LabelPair {
15    #[deprecated(note = "Use default()", since = "0.5.1")]
16    pub fn new() -> LabelPair {
17        Default::default()
18    }
19
20    #[deprecated(
21        note = "This method is protobuf specific and will be removed in a future version",
22        since = "0.5.1"
23    )]
24    pub fn clear_name(&mut self) {
25        self.name.clear();
26    }
27
28    pub fn set_name(&mut self, v: String) {
29        self.name = v;
30    }
31
32    pub fn get_name(&self) -> &str {
33        &self.name
34    }
35
36    pub fn set_value(&mut self, v: String) {
37        self.value = v;
38    }
39
40    pub fn get_value(&self) -> &str {
41        &self.value
42    }
43}
44
45#[derive(PartialEq, Clone, Default, Debug)]
46pub struct Gauge {
47    value: f64,
48}
49
50impl Gauge {
51    #[deprecated(note = "Use default()", since = "0.5.1")]
52    pub fn new() -> Gauge {
53        Default::default()
54    }
55
56    pub fn set_value(&mut self, v: f64) {
57        self.value = v;
58    }
59
60    pub fn get_value(&self) -> f64 {
61        self.value
62    }
63}
64
65#[derive(PartialEq, Clone, Default, Debug)]
66pub struct Counter {
67    value: f64,
68}
69
70impl Counter {
71    #[deprecated(note = "Use default()", since = "0.5.1")]
72    pub fn new() -> Counter {
73        Default::default()
74    }
75
76    // Param is passed by value, moved
77    pub fn set_value(&mut self, v: f64) {
78        self.value = v;
79    }
80
81    pub fn get_value(&self) -> f64 {
82        self.value
83    }
84}
85
86#[derive(PartialEq, Clone, Default, Debug)]
87pub struct Quantile {
88    quantile: f64,
89    value: f64,
90}
91
92impl Quantile {
93    #[deprecated(note = "Use default()", since = "0.5.1")]
94    pub fn new() -> Quantile {
95        Default::default()
96    }
97
98    pub fn set_quantile(&mut self, v: f64) {
99        self.quantile = v;
100    }
101
102    pub fn get_quantile(&self) -> f64 {
103        self.quantile
104    }
105
106    pub fn set_value(&mut self, v: f64) {
107        self.value = v;
108    }
109
110    pub fn get_value(&self) -> f64 {
111        self.value
112    }
113}
114
115#[derive(PartialEq, Clone, Default, Debug)]
116pub struct Summary {
117    sample_count: u64,
118    sample_sum: f64,
119    quantile: Vec<Quantile>,
120}
121
122impl Summary {
123    #[deprecated(note = "Use default()", since = "0.5.1")]
124    pub fn new() -> Summary {
125        Default::default()
126    }
127
128    pub fn set_sample_count(&mut self, v: u64) {
129        self.sample_count = v;
130    }
131
132    pub fn get_sample_count(&self) -> u64 {
133        self.sample_count
134    }
135
136    pub fn set_sample_sum(&mut self, v: f64) {
137        self.sample_sum = v;
138    }
139
140    pub fn get_sample_sum(&self) -> f64 {
141        self.sample_sum
142    }
143
144    pub fn set_quantile(&mut self, v: Vec<Quantile>) {
145        self.quantile = v;
146    }
147
148    pub fn get_quantile(&self) -> &[Quantile] {
149        &self.quantile
150    }
151}
152
153#[derive(PartialEq, Clone, Default, Debug)]
154pub struct Untyped {
155    value: f64,
156}
157
158impl Untyped {
159    #[deprecated(note = "Use default()", since = "0.5.1")]
160    pub fn new() -> Untyped {
161        Default::default()
162    }
163
164    #[deprecated(
165        note = "Untyped struct is protobuf specific and will be removed in a future version",
166        since = "0.5.1"
167    )]
168    pub fn set_value(&mut self, v: f64) {
169        self.value = v;
170    }
171
172    #[deprecated(
173        note = "Untyped struct is protobuf specific and will be removed in a future version",
174        since = "0.5.1"
175    )]
176    pub fn get_value(&self) -> f64 {
177        self.value
178    }
179}
180
181#[derive(PartialEq, Clone, Default, Debug)]
182pub struct Histogram {
183    sample_count: u64,
184    sample_sum: f64,
185    bucket: Vec<Bucket>,
186}
187
188impl Histogram {
189    #[deprecated(note = "Use default()", since = "0.5.1")]
190    pub fn new() -> Histogram {
191        Default::default()
192    }
193
194    pub fn set_sample_count(&mut self, v: u64) {
195        self.sample_count = v;
196    }
197
198    pub fn get_sample_count(&self) -> u64 {
199        self.sample_count
200    }
201
202    pub fn set_sample_sum(&mut self, v: f64) {
203        self.sample_sum = v;
204    }
205
206    pub fn get_sample_sum(&self) -> f64 {
207        self.sample_sum
208    }
209
210    pub fn set_bucket(&mut self, v: Vec<Bucket>) {
211        self.bucket = v;
212    }
213
214    pub fn get_bucket(&self) -> &[Bucket] {
215        &self.bucket
216    }
217}
218
219#[derive(PartialEq, Clone, Default, Debug)]
220pub struct Bucket {
221    cumulative_count: u64,
222    upper_bound: f64,
223}
224
225impl Bucket {
226    #[deprecated(note = "Use default()", since = "0.5.1")]
227    pub fn new() -> Bucket {
228        Default::default()
229    }
230
231    pub fn set_cumulative_count(&mut self, v: u64) {
232        self.cumulative_count = v;
233    }
234
235    pub fn get_cumulative_count(&self) -> u64 {
236        self.cumulative_count
237    }
238
239    pub fn set_upper_bound(&mut self, v: f64) {
240        self.upper_bound = v;
241    }
242
243    pub fn get_upper_bound(&self) -> f64 {
244        self.upper_bound
245    }
246}
247
248#[derive(PartialEq, Clone, Default, Debug)]
249pub struct Metric {
250    // message fields
251    label: Vec<LabelPair>,
252    gauge: Gauge,
253    counter: Counter,
254    summary: Summary,
255    untyped: Untyped,
256    histogram: Histogram,
257    timestamp_ms: i64,
258}
259
260impl Metric {
261    #[deprecated(note = "Use default()", since = "0.5.1")]
262    pub fn new() -> Metric {
263        Default::default()
264    }
265
266    pub fn set_label(&mut self, v: Vec<LabelPair>) {
267        self.label = v;
268    }
269
270    pub fn mut_label(&mut self) -> &mut [LabelPair] {
271        &mut self.label
272    }
273
274    pub fn take_label(&mut self) -> Vec<LabelPair> {
275        ::std::mem::replace(&mut self.label, Vec::new())
276    }
277
278    pub fn get_label(&self) -> &[LabelPair] {
279        &self.label
280    }
281
282    pub fn set_gauge(&mut self, v: Gauge) {
283        self.gauge = v;
284    }
285
286    pub fn get_gauge(&self) -> &Gauge {
287        &self.gauge
288    }
289
290    pub fn set_counter(&mut self, v: Counter) {
291        self.counter = v;
292    }
293
294    pub fn get_counter(&self) -> &Counter {
295        &self.counter
296    }
297
298    pub fn set_summary(&mut self, v: Summary) {
299        self.summary = v;
300    }
301
302    pub fn get_summary(&self) -> &Summary {
303        &self.summary
304    }
305
306    #[deprecated(
307        note = "This method is protobuf specific and will be removed in a future version",
308        since = "0.5.1"
309    )]
310    pub fn set_untyped(&mut self, v: Untyped) {
311        self.untyped = v;
312    }
313
314    #[deprecated(
315        note = "This method is protobuf specific and will be removed in a future version",
316        since = "0.5.1"
317    )]
318    pub fn get_untyped(&self) -> &Untyped {
319        &self.untyped
320    }
321
322    pub fn set_histogram(&mut self, v: Histogram) {
323        self.histogram = v;
324    }
325
326    pub fn get_histogram(&self) -> &Histogram {
327        &self.histogram
328    }
329
330    pub fn set_timestamp_ms(&mut self, v: i64) {
331        self.timestamp_ms = v;
332    }
333
334    pub fn get_timestamp_ms(&self) -> i64 {
335        self.timestamp_ms
336    }
337}
338
339#[derive(Clone, PartialEq, Eq, Debug, Hash, Copy)]
340pub enum MetricType {
341    COUNTER,
342    GAUGE,
343    SUMMARY,
344    UNTYPED,
345    HISTOGRAM,
346}
347
348impl Default for MetricType {
349    fn default() -> Self {
350        MetricType::COUNTER
351    }
352}
353
354#[derive(PartialEq, Clone, Default, Debug)]
355pub struct MetricFamily {
356    name: String,
357    help: String,
358    field_type: MetricType,
359    metric: Vec<Metric>,
360}
361
362impl MetricFamily {
363    #[deprecated(note = "Use default()", since = "0.5.1")]
364    pub fn new() -> MetricFamily {
365        Default::default()
366    }
367
368    pub fn clear_name(&mut self) {
369        self.name.clear();
370    }
371
372    pub fn set_name(&mut self, v: String) {
373        self.name = v;
374    }
375
376    pub fn get_name(&self) -> &str {
377        &self.name
378    }
379
380    pub fn set_help(&mut self, v: String) {
381        self.help = v;
382    }
383
384    pub fn get_help(&self) -> &str {
385        &self.help
386    }
387
388    pub fn set_field_type(&mut self, v: MetricType) {
389        self.field_type = v;
390    }
391
392    pub fn get_field_type(&self) -> MetricType {
393        self.field_type
394    }
395
396    #[deprecated(
397        note = "This method is protobuf specific and will be removed in a future version",
398        since = "0.5.1"
399    )]
400    pub fn clear_metric(&mut self) {
401        self.metric.clear();
402    }
403
404    pub fn set_metric(&mut self, v: Vec<Metric>) {
405        self.metric = v;
406    }
407
408    pub fn mut_metric(&mut self) -> &mut Vec<Metric> {
409        &mut self.metric
410    }
411
412    pub fn take_metric(&mut self) -> Vec<Metric> {
413        ::std::mem::replace(&mut self.metric, Vec::new())
414    }
415
416    pub fn get_metric(&self) -> &[Metric] {
417        &self.metric
418    }
419}