Skip to content

Commit df02515

Browse files
committed
Bring back legacy proto
Signed-off-by: John Howard <john.howard@solo.io>
1 parent 440d8cf commit df02515

7 files changed

Lines changed: 1365 additions & 43 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1818
`io.prometheus.client` protobuf messages from `metrics.proto` rather than the
1919
OpenMetrics protobuf data model. This is a breaking change for users of the `protobuf` feature.
2020
See [Issue](https://github.com/prometheus/OpenMetrics/issues/296) for more context.
21+
The `legacy_protobuf` feature retains the old, deprecated, OpenMetrics protobuf support which will
22+
be removed in a future release.
2123

2224
## [0.24.1]
2325

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ documentation = "https://docs.rs/prometheus-client"
1313
[features]
1414
default = []
1515
protobuf = ["dep:prost", "dep:prost-types", "dep:prost-build"]
16+
legacy_protobuf = ["dep:prost", "dep:prost-types", "dep:prost-build"]
1617
protobuf-protox = ["protobuf", "dep:protox"]
1718

1819
# This feature provides additional APIs for testing downstream code using

build.rs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,26 @@
11
use std::error::Error;
22

33
fn main() -> Result<(), Box<dyn Error>> {
4-
#[cfg(feature = "protobuf")]
4+
#[cfg(any(feature = "protobuf", feature = "legacy_protobuf"))]
55
compile_protos()?;
66

77
Ok(())
88
}
99

10-
#[cfg(feature = "protobuf")]
10+
#[allow(clippy::vec_init_then_push)] // False positive due to feature flags
11+
#[cfg(any(feature = "protobuf", feature = "legacy_protobuf"))]
1112
fn compile_protos() -> Result<(), Box<dyn Error>> {
12-
let protos = ["src/encoding/proto/metrics.proto"];
13+
let mut protos = Vec::new();
14+
15+
#[cfg(feature = "protobuf")]
16+
protos.push("src/encoding/proto/metrics.proto");
17+
#[cfg(feature = "legacy_protobuf")]
18+
protos.push("src/encoding/proto/openmetrics_data_model.proto");
19+
1320
let includes = ["src/encoding/proto/"];
1421

1522
#[cfg(feature = "protobuf-protox")]
16-
prost_build::compile_fds(protox::compile(protos, includes)?)?;
23+
prost_build::compile_fds(protox::compile(&protos, includes)?)?;
1724

1825
#[cfg(not(feature = "protobuf-protox"))]
1926
prost_build::compile_protos(&protos, &includes)?;

0 commit comments

Comments
 (0)