Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ features = ["nightly"]

[features]
default = ["protobuf"]
gen = ["protobuf-codegen-pure"]
nightly = ["libc"]
process = ["libc", "procfs"]
protobuf = ["prost", "prost-build"]
push = ["reqwest", "libc", "protobuf"]

[dependencies]
Expand All @@ -30,7 +30,7 @@ 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 }
memchr = "^2.3"
reqwest = { version = "^0.11", features = ["blocking"], optional = true }
thiserror = "^1.0"
Expand All @@ -45,7 +45,7 @@ hyper = { version = "^0.14", features = ["server", "http1", "tcp"] }
tokio = { version = "^1.0", features = ["macros", "rt-multi-thread"] }

[build-dependencies]
protobuf-codegen-pure = { version = "^2.0", optional = true }
prost-build = { version = "^0.7", optional = true }

[workspace]
members = ["static-metric"]
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ Find the latest documentation at <https://docs.rs/prometheus>.

This crate provides several optional components which can be enabled via [Cargo `[features]`](https://doc.rust-lang.org/cargo/reference/features.html):

- `gen`: To generate protobuf client with the latest protobuf version instead of
using the pre-generated client.
- `protobuf`: Enable [Protocol Buffers](https://developers.google.com/protocol-buffers/) (aka Protobuf) based exposition format. (Enabled by default)

> Notice: Since version 2.0, Prometheus no longer supports the Protobuf-based format. You can read about the reasoning behind this change in [this document](https://github.com/OpenObservability/OpenMetrics/blob/master/legacy/markdown/protobuf_vs_text.md).

- `nightly`: Enable nightly only features.

Expand Down
12 changes: 3 additions & 9 deletions build.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
// Copyright 2019 TiKV Project Authors. Licensed under Apache-2.0.

#[cfg(feature = "gen")]
#[cfg(feature = "protobuf")]
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();
prost_build::compile_protos(&["proto/proto_model.proto"], &["proto"]).unwrap();
}

#[cfg(not(feature = "gen"))]
#[cfg(not(feature = "protobuf"))]
fn generate_protobuf_binding_file() {}

fn main() {
Expand Down
Loading