-
Notifications
You must be signed in to change notification settings - Fork 204
Switch from protobuf to prost #387
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 9 commits
1415290
c1f5190
35493eb
02be5a7
34926d5
06572e7
d1ebdb2
fcdd202
f49d053
2097820
9001ff8
7cb54c8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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<f64>, | ||
| } | ||
| #[derive(Clone, PartialEq, ::prost::Message)] | ||
| pub struct Counter { | ||
| #[prost(double, optional, tag="1")] | ||
| pub value: ::core::option::Option<f64>, | ||
| } | ||
| #[derive(Clone, PartialEq, ::prost::Message)] | ||
| pub struct Quantile { | ||
| #[prost(double, optional, tag="1")] | ||
| pub quantile: ::core::option::Option<f64>, | ||
| #[prost(double, optional, tag="2")] | ||
| pub value: ::core::option::Option<f64>, | ||
| } | ||
| #[derive(Clone, PartialEq, ::prost::Message)] | ||
| pub struct Summary { | ||
| #[prost(uint64, optional, tag="1")] | ||
| pub sample_count: ::core::option::Option<u64>, | ||
| #[prost(double, optional, tag="2")] | ||
| pub sample_sum: ::core::option::Option<f64>, | ||
| #[prost(message, repeated, tag="3")] | ||
| pub quantile: ::prost::alloc::vec::Vec<Quantile>, | ||
| } | ||
| #[derive(Clone, PartialEq, ::prost::Message)] | ||
| pub struct Untyped { | ||
| #[prost(double, optional, tag="1")] | ||
| pub value: ::core::option::Option<f64>, | ||
| } | ||
| #[derive(Clone, PartialEq, ::prost::Message)] | ||
| pub struct Histogram { | ||
| #[prost(uint64, optional, tag="1")] | ||
| pub sample_count: ::core::option::Option<u64>, | ||
| #[prost(double, optional, tag="2")] | ||
| pub sample_sum: ::core::option::Option<f64>, | ||
| /// Ordered in increasing order of upper_bound, +Inf bucket is optional. | ||
| #[prost(message, repeated, tag="3")] | ||
| pub bucket: ::prost::alloc::vec::Vec<Bucket>, | ||
| } | ||
| #[derive(Clone, PartialEq, ::prost::Message)] | ||
| pub struct Bucket { | ||
| /// Cumulative in increasing order. | ||
| #[prost(uint64, optional, tag="1")] | ||
| pub cumulative_count: ::core::option::Option<u64>, | ||
| /// Inclusive. | ||
| #[prost(double, optional, tag="2")] | ||
| pub upper_bound: ::core::option::Option<f64>, | ||
| } | ||
| #[derive(Clone, PartialEq, ::prost::Message)] | ||
| pub struct Metric { | ||
| #[prost(message, repeated, tag="1")] | ||
| pub label: ::prost::alloc::vec::Vec<LabelPair>, | ||
| #[prost(message, optional, tag="2")] | ||
| pub gauge: ::core::option::Option<Gauge>, | ||
| #[prost(message, optional, tag="3")] | ||
| pub counter: ::core::option::Option<Counter>, | ||
| #[prost(message, optional, tag="4")] | ||
| pub summary: ::core::option::Option<Summary>, | ||
| #[prost(message, optional, tag="5")] | ||
| pub untyped: ::core::option::Option<Untyped>, | ||
| #[prost(message, optional, tag="7")] | ||
| pub histogram: ::core::option::Option<Histogram>, | ||
| #[prost(int64, optional, tag="6")] | ||
| pub timestamp_ms: ::core::option::Option<i64>, | ||
| } | ||
| #[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<i32>, | ||
| #[prost(message, repeated, tag="4")] | ||
| pub metric: ::prost::alloc::vec::Vec<Metric>, | ||
| } | ||
| #[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, | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,7 +2,7 @@ | |
|
|
||
| use std::io::Write; | ||
|
|
||
| use protobuf::Message; | ||
| use prost::Message; | ||
|
|
||
| use crate::errors::Result; | ||
| use crate::proto::MetricFamily; | ||
|
|
@@ -31,7 +31,9 @@ impl Encoder for ProtobufEncoder { | |
| for mf in metric_families { | ||
| // Fail-fast checks. | ||
| check_metric_family(mf)?; | ||
| mf.write_length_delimited_to_writer(writer)?; | ||
| let mut buf = vec![]; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bummer that we need this intermediary buffer. We could change the
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Exactly. Actually, I did change to the
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's keep non-protobuf feature clean.. This immediate buffer only allocate once each encode call and I think the performance seems to be fine. |
||
| mf.encode_length_delimited(&mut buf)?; | ||
| writer.write_all(buf.as_slice())?; | ||
| } | ||
| Ok(()) | ||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.