diff --git a/Cargo.toml b/Cargo.toml index 5429956b..695e523e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,9 +19,10 @@ features = ["nightly"] [features] default = ["protobuf"] -gen = ["protobuf-codegen-pure"] +gen = ["prost-build"] nightly = ["libc"] process = ["libc", "procfs"] +protobuf = ["prost", "prost-types"] push = ["reqwest", "libc", "protobuf"] [dependencies] @@ -30,7 +31,8 @@ fnv = "^1.0" lazy_static = "^1.4" libc = { version = "^0.2", optional = true } parking_lot = "^0.11" -protobuf = { version = "^2.0", optional = true } +prost = { version = "^0.7", optional = true } +prost-types = { version = "^0.7", optional = true } regex = "^1.3" reqwest = { version = "^0.11", features = ["blocking"], optional = true } thiserror = "^1.0" @@ -45,6 +47,7 @@ hyper = { version = "^0.14", features = ["server", "http1", "tcp"] } tokio = { version = "^1.0", features = ["macros", "rt-multi-thread"] } [build-dependencies] +prost-build = { versopm = "^0.7", optional = true } protobuf-codegen-pure = { version = "^2.0", optional = true } [workspace] diff --git a/build.rs b/build.rs index b556f0b3..29d083ea 100644 --- a/build.rs +++ b/build.rs @@ -2,13 +2,12 @@ #[cfg(feature = "gen")] fn generate_protobuf_binding_file() { - protobuf_codegen_pure::run(protobuf_codegen_pure::Args { - out_dir: "proto", - input: &["proto/proto_model.proto"], - includes: &["proto"], - ..Default::default() - }) - .unwrap(); + use prost_build::Config; + use std::path::Path; + + let mut cfg = Config::new(); + cfg.out_dir(Path::new("proto")); + cfg.compile_protos(&["proto/proto_model.proto"], &["proto"]).unwrap(); } #[cfg(not(feature = "gen"))] diff --git a/proto/io.prometheus.client.rs b/proto/io.prometheus.client.rs new file mode 100644 index 00000000..dff1a5e5 --- /dev/null +++ b/proto/io.prometheus.client.rs @@ -0,0 +1,94 @@ +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct LabelPair { + #[prost(string, optional, tag="1")] + pub name: ::core::option::Option<::prost::alloc::string::String>, + #[prost(string, optional, tag="2")] + pub value: ::core::option::Option<::prost::alloc::string::String>, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct Gauge { + #[prost(double, optional, tag="1")] + pub value: ::core::option::Option, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct Counter { + #[prost(double, optional, tag="1")] + pub value: ::core::option::Option, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct Quantile { + #[prost(double, optional, tag="1")] + pub quantile: ::core::option::Option, + #[prost(double, optional, tag="2")] + pub value: ::core::option::Option, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct Summary { + #[prost(uint64, optional, tag="1")] + pub sample_count: ::core::option::Option, + #[prost(double, optional, tag="2")] + pub sample_sum: ::core::option::Option, + #[prost(message, repeated, tag="3")] + pub quantile: ::prost::alloc::vec::Vec, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct Untyped { + #[prost(double, optional, tag="1")] + pub value: ::core::option::Option, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct Histogram { + #[prost(uint64, optional, tag="1")] + pub sample_count: ::core::option::Option, + #[prost(double, optional, tag="2")] + pub sample_sum: ::core::option::Option, + /// Ordered in increasing order of upper_bound, +Inf bucket is optional. + #[prost(message, repeated, tag="3")] + pub bucket: ::prost::alloc::vec::Vec, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct Bucket { + /// Cumulative in increasing order. + #[prost(uint64, optional, tag="1")] + pub cumulative_count: ::core::option::Option, + /// Inclusive. + #[prost(double, optional, tag="2")] + pub upper_bound: ::core::option::Option, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct Metric { + #[prost(message, repeated, tag="1")] + pub label: ::prost::alloc::vec::Vec, + #[prost(message, optional, tag="2")] + pub gauge: ::core::option::Option, + #[prost(message, optional, tag="3")] + pub counter: ::core::option::Option, + #[prost(message, optional, tag="4")] + pub summary: ::core::option::Option, + #[prost(message, optional, tag="5")] + pub untyped: ::core::option::Option, + #[prost(message, optional, tag="7")] + pub histogram: ::core::option::Option, + #[prost(int64, optional, tag="6")] + pub timestamp_ms: ::core::option::Option, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct MetricFamily { + #[prost(string, optional, tag="1")] + pub name: ::core::option::Option<::prost::alloc::string::String>, + #[prost(string, optional, tag="2")] + pub help: ::core::option::Option<::prost::alloc::string::String>, + #[prost(enumeration="MetricType", optional, tag="3")] + pub r#type: ::core::option::Option, + #[prost(message, repeated, tag="4")] + pub metric: ::prost::alloc::vec::Vec, +} +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] +#[repr(i32)] +pub enum MetricType { + Counter = 0, + Gauge = 1, + Summary = 2, + Untyped = 3, + Histogram = 4, +}