Skip to content

Commit f916bd6

Browse files
committed
Retain old 'protobuf' feature, make explicit types
Signed-off-by: John Howard <john.howard@solo.io>
1 parent df02515 commit f916bd6

9 files changed

Lines changed: 73 additions & 64 deletions

File tree

CHANGELOG.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1414
### Changed
1515

1616
- Updated `prost`, `prost-build`, and `prost-types` dependencies to `v0.14`.
17-
- The `protobuf` feature now generates and encodes Prometheus
17+
- The `prometheus_protobuf` feature generates and encodes Prometheus
1818
`io.prometheus.client` protobuf messages from `metrics.proto` rather than the
19-
OpenMetrics protobuf data model. This is a breaking change for users of the `protobuf` feature.
19+
OpenMetrics protobuf data model.
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
21+
The `protobuf` and `openmetrics_protobuf` features retain the old, deprecated, OpenMetrics protobuf support which will
2222
be removed in a future release.
2323

2424
## [0.24.1]

Cargo.toml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,10 @@ documentation = "https://docs.rs/prometheus-client"
1212

1313
[features]
1414
default = []
15-
protobuf = ["dep:prost", "dep:prost-types", "dep:prost-build"]
16-
legacy_protobuf = ["dep:prost", "dep:prost-types", "dep:prost-build"]
17-
protobuf-protox = ["protobuf", "dep:protox"]
15+
prometheus_protobuf = ["dep:prost", "dep:prost-types", "dep:prost-build"]
16+
openmetrics_protobuf = ["dep:prost", "dep:prost-types", "dep:prost-build"]
17+
protobuf = ["openmetrics_protobuf"]
18+
protobuf-protox = ["dep:protox"]
1819

1920
# This feature provides additional APIs for testing downstream code using
2021
# `prometheus-client`.
@@ -76,7 +77,7 @@ required-features = []
7677
name = "proto"
7778
path = "benches/encoding/proto.rs"
7879
harness = false
79-
required-features = ["protobuf"]
80+
required-features = ["prometheus_protobuf"]
8081

8182
# Passing arguments to the docsrs builder in order to properly document cfg's.
8283
# More information: https://docs.rs/about/builds#cross-compiling

benches/encoding/proto.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// https://github.com/tikv/rust-prometheus/blob/ab1ca7285d3463504381a5025ae1951e020d6796/benches/text_encoder.rs:write
33

44
use criterion::{black_box, criterion_group, criterion_main, Criterion};
5-
use prometheus_client::encoding::protobuf;
5+
use prometheus_client::encoding::prometheus_protobuf;
66
use prometheus_client::metrics::counter::Counter;
77
use prometheus_client::metrics::family::Family;
88
use prometheus_client::metrics::histogram::{exponential_buckets, Histogram};
@@ -75,7 +75,7 @@ pub fn proto(c: &mut Criterion) {
7575
}
7676

7777
b.iter(|| {
78-
let metric_set = protobuf::encode(&registry).unwrap();
78+
let metric_set = prometheus_protobuf::encode(&registry).unwrap();
7979
black_box(metric_set);
8080
})
8181
});

build.rs

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

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

77
Ok(())
88
}
99

1010
#[allow(clippy::vec_init_then_push)] // False positive due to feature flags
11-
#[cfg(any(feature = "protobuf", feature = "legacy_protobuf"))]
11+
#[cfg(any(feature = "prometheus_protobuf", feature = "openmetrics_protobuf"))]
1212
fn compile_protos() -> Result<(), Box<dyn Error>> {
1313
let mut protos = Vec::new();
1414

15-
#[cfg(feature = "protobuf")]
15+
#[cfg(feature = "prometheus_protobuf")]
1616
protos.push("src/encoding/proto/metrics.proto");
17-
#[cfg(feature = "legacy_protobuf")]
17+
#[cfg(feature = "openmetrics_protobuf")]
1818
protos.push("src/encoding/proto/openmetrics_data_model.proto");
1919

2020
let includes = ["src/encoding/proto/"];

derive-encode/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ quote = "1"
1717
syn = "2"
1818

1919
[dev-dependencies]
20-
prometheus-client = { path = "../", features = ["protobuf"] }
20+
prometheus-client = { path = "../", features = ["prometheus_protobuf"] }
2121
trybuild = "1"
2222

2323
[lib]

derive-encode/tests/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ fn basic_flow() {
4747

4848
mod protobuf {
4949
use crate::{Labels, Method};
50-
use prometheus_client::encoding::protobuf::encode;
51-
use prometheus_client::encoding::protobuf::prometheus_data_model;
50+
use prometheus_client::encoding::prometheus_protobuf::encode;
51+
use prometheus_client::encoding::prometheus_protobuf::prometheus_data_model;
5252
use prometheus_client::metrics::counter::Counter;
5353
use prometheus_client::metrics::family::Family;
5454
use prometheus_client::registry::Registry;

0 commit comments

Comments
 (0)