Skip to content

Commit fb2837d

Browse files
committed
Setup prost
1 parent e1b197b commit fb2837d

File tree

3 files changed

+105
-9
lines changed

3 files changed

+105
-9
lines changed

Cargo.toml

+5-2
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,10 @@ features = ["nightly"]
1919

2020
[features]
2121
default = ["protobuf"]
22-
gen = ["protobuf-codegen-pure"]
22+
gen = ["prost-build"]
2323
nightly = ["libc"]
2424
process = ["libc", "procfs"]
25+
protobuf = ["prost", "prost-types"]
2526
push = ["reqwest", "libc", "protobuf"]
2627

2728
[dependencies]
@@ -30,7 +31,8 @@ fnv = "^1.0"
3031
lazy_static = "^1.4"
3132
libc = { version = "^0.2", optional = true }
3233
parking_lot = "^0.11"
33-
protobuf = { version = "^2.0", optional = true }
34+
prost = { version = "^0.7", optional = true }
35+
prost-types = { version = "^0.7", optional = true }
3436
regex = "^1.3"
3537
reqwest = { version = "^0.11", features = ["blocking"], optional = true }
3638
thiserror = "^1.0"
@@ -45,6 +47,7 @@ hyper = { version = "^0.14", features = ["server", "http1", "tcp"] }
4547
tokio = { version = "^1.0", features = ["macros", "rt-multi-thread"] }
4648

4749
[build-dependencies]
50+
prost-build = { versopm = "^0.7", optional = true }
4851
protobuf-codegen-pure = { version = "^2.0", optional = true }
4952

5053
[workspace]

build.rs

+6-7
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,12 @@
22

33
#[cfg(feature = "gen")]
44
fn generate_protobuf_binding_file() {
5-
protobuf_codegen_pure::run(protobuf_codegen_pure::Args {
6-
out_dir: "proto",
7-
input: &["proto/proto_model.proto"],
8-
includes: &["proto"],
9-
..Default::default()
10-
})
11-
.unwrap();
5+
use prost_build::Config;
6+
use std::path::Path;
7+
8+
let mut cfg = Config::new();
9+
cfg.out_dir(Path::new("proto"));
10+
cfg.compile_protos(&["proto/proto_model.proto"], &["proto"]).unwrap();
1211
}
1312

1413
#[cfg(not(feature = "gen"))]

proto/io.prometheus.client.rs

+94
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
#[derive(Clone, PartialEq, ::prost::Message)]
2+
pub struct LabelPair {
3+
#[prost(string, optional, tag="1")]
4+
pub name: ::core::option::Option<::prost::alloc::string::String>,
5+
#[prost(string, optional, tag="2")]
6+
pub value: ::core::option::Option<::prost::alloc::string::String>,
7+
}
8+
#[derive(Clone, PartialEq, ::prost::Message)]
9+
pub struct Gauge {
10+
#[prost(double, optional, tag="1")]
11+
pub value: ::core::option::Option<f64>,
12+
}
13+
#[derive(Clone, PartialEq, ::prost::Message)]
14+
pub struct Counter {
15+
#[prost(double, optional, tag="1")]
16+
pub value: ::core::option::Option<f64>,
17+
}
18+
#[derive(Clone, PartialEq, ::prost::Message)]
19+
pub struct Quantile {
20+
#[prost(double, optional, tag="1")]
21+
pub quantile: ::core::option::Option<f64>,
22+
#[prost(double, optional, tag="2")]
23+
pub value: ::core::option::Option<f64>,
24+
}
25+
#[derive(Clone, PartialEq, ::prost::Message)]
26+
pub struct Summary {
27+
#[prost(uint64, optional, tag="1")]
28+
pub sample_count: ::core::option::Option<u64>,
29+
#[prost(double, optional, tag="2")]
30+
pub sample_sum: ::core::option::Option<f64>,
31+
#[prost(message, repeated, tag="3")]
32+
pub quantile: ::prost::alloc::vec::Vec<Quantile>,
33+
}
34+
#[derive(Clone, PartialEq, ::prost::Message)]
35+
pub struct Untyped {
36+
#[prost(double, optional, tag="1")]
37+
pub value: ::core::option::Option<f64>,
38+
}
39+
#[derive(Clone, PartialEq, ::prost::Message)]
40+
pub struct Histogram {
41+
#[prost(uint64, optional, tag="1")]
42+
pub sample_count: ::core::option::Option<u64>,
43+
#[prost(double, optional, tag="2")]
44+
pub sample_sum: ::core::option::Option<f64>,
45+
/// Ordered in increasing order of upper_bound, +Inf bucket is optional.
46+
#[prost(message, repeated, tag="3")]
47+
pub bucket: ::prost::alloc::vec::Vec<Bucket>,
48+
}
49+
#[derive(Clone, PartialEq, ::prost::Message)]
50+
pub struct Bucket {
51+
/// Cumulative in increasing order.
52+
#[prost(uint64, optional, tag="1")]
53+
pub cumulative_count: ::core::option::Option<u64>,
54+
/// Inclusive.
55+
#[prost(double, optional, tag="2")]
56+
pub upper_bound: ::core::option::Option<f64>,
57+
}
58+
#[derive(Clone, PartialEq, ::prost::Message)]
59+
pub struct Metric {
60+
#[prost(message, repeated, tag="1")]
61+
pub label: ::prost::alloc::vec::Vec<LabelPair>,
62+
#[prost(message, optional, tag="2")]
63+
pub gauge: ::core::option::Option<Gauge>,
64+
#[prost(message, optional, tag="3")]
65+
pub counter: ::core::option::Option<Counter>,
66+
#[prost(message, optional, tag="4")]
67+
pub summary: ::core::option::Option<Summary>,
68+
#[prost(message, optional, tag="5")]
69+
pub untyped: ::core::option::Option<Untyped>,
70+
#[prost(message, optional, tag="7")]
71+
pub histogram: ::core::option::Option<Histogram>,
72+
#[prost(int64, optional, tag="6")]
73+
pub timestamp_ms: ::core::option::Option<i64>,
74+
}
75+
#[derive(Clone, PartialEq, ::prost::Message)]
76+
pub struct MetricFamily {
77+
#[prost(string, optional, tag="1")]
78+
pub name: ::core::option::Option<::prost::alloc::string::String>,
79+
#[prost(string, optional, tag="2")]
80+
pub help: ::core::option::Option<::prost::alloc::string::String>,
81+
#[prost(enumeration="MetricType", optional, tag="3")]
82+
pub r#type: ::core::option::Option<i32>,
83+
#[prost(message, repeated, tag="4")]
84+
pub metric: ::prost::alloc::vec::Vec<Metric>,
85+
}
86+
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
87+
#[repr(i32)]
88+
pub enum MetricType {
89+
Counter = 0,
90+
Gauge = 1,
91+
Summary = 2,
92+
Untyped = 3,
93+
Histogram = 4,
94+
}

0 commit comments

Comments
 (0)