Skip to content

Commit 6c0ece9

Browse files
committed
Bring back legacy proto
1 parent 63ccfdb commit 6c0ece9

7 files changed

Lines changed: 1362 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: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,25 @@
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+
#[cfg(any(feature = "protobuf", feature = "legacy_protobuf"))]
1111
fn compile_protos() -> Result<(), Box<dyn Error>> {
12-
let protos = ["src/encoding/proto/metrics.proto"];
12+
let mut protos = Vec::new();
13+
14+
#[cfg(feature = "protobuf")]
15+
protos.push("src/encoding/proto/metrics.proto");
16+
#[cfg(feature = "legacy_protobuf")]
17+
protos.push("src/encoding/proto/openmetrics_data_model.proto");
18+
1319
let includes = ["src/encoding/proto/"];
1420

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

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

0 commit comments

Comments
 (0)