From a21fd3f1293cdf8dc8e8953c9872f710489c835a Mon Sep 17 00:00:00 2001 From: dzmitry-lahoda Date: Sat, 29 Apr 2023 23:04:24 +0100 Subject: [PATCH 1/2] support for grafana cloud which is snappy default and no suffix in url fixed generics more clarity on errors error description return in push Signed-off-by: Dzmitry Lahoda --- Cargo.toml | 3 ++- src/lib.rs | 2 +- src/push.rs | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 59 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index e2197605..95fb4b5e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,7 +22,7 @@ default = ["protobuf"] gen = ["protobuf-codegen-pure"] nightly = ["libc"] process = ["libc", "procfs"] -push = ["reqwest", "libc", "protobuf"] +push = ["reqwest", "libc", "protobuf", "snap"] [dependencies] cfg-if = "^1.0" @@ -31,6 +31,7 @@ lazy_static = "^1.4" libc = { version = "^0.2", optional = true } parking_lot = "^0.12" protobuf = { version = "^2.0", optional = true } +snap = { version = "^1.1", optional = true } memchr = "^2.3" reqwest = { version = "^0.11", features = ["blocking"], optional = true } thiserror = "^1.0" diff --git a/src/lib.rs b/src/lib.rs index 55cbea35..23465bca 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -224,7 +224,7 @@ pub use self::pulling_gauge::PullingGauge; #[cfg(feature = "push")] pub use self::push::{ hostname_grouping_key, push_add_collector, push_add_metrics, push_collector, push_metrics, - BasicAuthentication, + push_raw, BasicAuthentication, }; pub use self::registry::Registry; pub use self::registry::{default_registry, gather, register, unregister}; diff --git a/src/push.rs b/src/push.rs index 525b3421..5594aa7c 100644 --- a/src/push.rs +++ b/src/push.rs @@ -173,6 +173,62 @@ fn push( } } +/// Pushes snappy compressed data to url as is. +pub fn push_raw( + url: &str, + mfs: Vec, + method: &str, + basic_auth: Option, +) -> Result<()> { + let mut push_url = if url.contains("://") { + url.to_owned() + } else { + format!("http://{}", url) + }; + + if push_url.ends_with('/') { + push_url.pop(); + } + + let encoder = ProtobufEncoder::new(); + let mut proto_buf = Vec::new(); + + for mf in mfs { + // Ignore error, `no metrics` and `no name`. + let _ = encoder.encode(&[mf], &mut proto_buf); + } + + let buf = snap::raw::Encoder::new() + .compress_vec(&proto_buf) + .expect("msg"); + + let mut builder = HTTP_CLIENT + .request( + Method::from_str(method).unwrap(), + Url::from_str(&push_url).unwrap(), + ) + .header(CONTENT_TYPE, encoder.format_type()) + .header("Content-Encoding", "snappy") + .body(buf); + + if let Some(BasicAuthentication { username, password }) = basic_auth { + builder = builder.basic_auth(username, Some(password)); + } + + let response = builder.send().map_err(|e| Error::Msg(format!("{}", e)))?; + + match response.status() { + StatusCode::ACCEPTED => Ok(()), + StatusCode::OK => Ok(()), + _ => Err(Error::Msg(format!( + "unexpected status code {} while pushing to {} {}", + response.status(), + push_url, + response.text().map(|text| format!("with body `{}`", text)).unwrap_or_default() + ))), + } +} + fn push_from_collector( job: &str, grouping: HashMap, From 807118f9c111634b2b29beab1c65e63f9d2e915e Mon Sep 17 00:00:00 2001 From: dzmitry-lahoda Date: Sun, 30 Apr 2023 11:51:07 +0100 Subject: [PATCH 2/2] proto 3 Signed-off-by: dzmitry-lahoda --- Cargo.toml | 9 +- build.rs | 21 +- proto/gogo.proto | 144 +++ proto/gogo.rs | 327 +++++ proto/metrics.proto | 147 +++ proto/metrics.rs | 2276 +++++++++++++++++++++++++++++++++++ proto/mod.rs | 4 + proto/proto_model.proto | 81 -- proto/proto_model.rs | 2532 --------------------------------------- src/counter.rs | 14 +- src/desc.rs | 4 +- src/encoder/mod.rs | 8 +- src/encoder/text.rs | 101 +- src/errors.rs | 2 +- src/gauge.rs | 8 +- src/histogram.rs | 79 +- src/lib.rs | 50 +- src/metrics.rs | 6 +- src/pulling_gauge.rs | 18 +- src/push.rs | 20 +- src/registry.rs | 71 +- src/value.rs | 24 +- src/vec.rs | 12 +- 23 files changed, 3156 insertions(+), 2802 deletions(-) create mode 100644 proto/gogo.proto create mode 100644 proto/gogo.rs create mode 100644 proto/metrics.proto create mode 100644 proto/metrics.rs create mode 100644 proto/mod.rs delete mode 100644 proto/proto_model.proto delete mode 100644 proto/proto_model.rs diff --git a/Cargo.toml b/Cargo.toml index 95fb4b5e..eef76ee1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,8 +18,8 @@ travis-ci = { repository = "pingcap/rust-prometheus" } features = ["nightly"] [features] -default = ["protobuf"] -gen = ["protobuf-codegen-pure"] +default = ["protobuf", "push", "nightly", "gen"] +gen = ["protobuf-codegen"] nightly = ["libc"] process = ["libc", "procfs"] push = ["reqwest", "libc", "protobuf", "snap"] @@ -30,7 +30,7 @@ fnv = "^1.0" lazy_static = "^1.4" libc = { version = "^0.2", optional = true } parking_lot = "^0.12" -protobuf = { version = "^2.0", optional = true } +protobuf = { version = "^3.2", optional = true } snap = { version = "^1.1", optional = true } memchr = "^2.3" reqwest = { version = "^0.11", features = ["blocking"], optional = true } @@ -46,7 +46,8 @@ 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 } +protobuf-codegen = { version = "^3.2", optional = true } +protoc-bin-vendored = { version = "^3.0" } [workspace] members = ["static-metric"] diff --git a/build.rs b/build.rs index b556f0b3..f00f1aa3 100644 --- a/build.rs +++ b/build.rs @@ -2,13 +2,20 @@ #[cfg(feature = "gen")] 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(); + protobuf_codegen::Codegen:: default() + + .protoc() + // Use `protoc-bin-vendored` bundled protoc command, optional. + .protoc_path(&protoc_bin_vendored::protoc_bin_path().unwrap()) + + .include("proto").input("proto/metrics.proto").input("proto/gogo.proto").out_dir("proto").run_from_script() + // protobuf_codegen_pure::run(protobuf_codegen_pure::Args { + // out_dir: "proto", + // input: &["proto/metrics.proto"], + // includes: &["proto"], + // ..Default::default() + // }) + // .unwrap(); } #[cfg(not(feature = "gen"))] diff --git a/proto/gogo.proto b/proto/gogo.proto new file mode 100644 index 00000000..8947d90a --- /dev/null +++ b/proto/gogo.proto @@ -0,0 +1,144 @@ +// Protocol Buffers for Go with Gadgets +// +// Copyright (c) 2013, The GoGo Authors. All rights reserved. +// http://github.com/gogo/protobuf +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +syntax = "proto2"; +package gogoproto; + +import "google/protobuf/descriptor.proto"; + +option java_package = "com.google.protobuf"; +option java_outer_classname = "GoGoProtos"; +option go_package = "github.com/gogo/protobuf/gogoproto"; + +extend google.protobuf.EnumOptions { + optional bool goproto_enum_prefix = 62001; + optional bool goproto_enum_stringer = 62021; + optional bool enum_stringer = 62022; + optional string enum_customname = 62023; + optional bool enumdecl = 62024; +} + +extend google.protobuf.EnumValueOptions { + optional string enumvalue_customname = 66001; +} + +extend google.protobuf.FileOptions { + optional bool goproto_getters_all = 63001; + optional bool goproto_enum_prefix_all = 63002; + optional bool goproto_stringer_all = 63003; + optional bool verbose_equal_all = 63004; + optional bool face_all = 63005; + optional bool gostring_all = 63006; + optional bool populate_all = 63007; + optional bool stringer_all = 63008; + optional bool onlyone_all = 63009; + + optional bool equal_all = 63013; + optional bool description_all = 63014; + optional bool testgen_all = 63015; + optional bool benchgen_all = 63016; + optional bool marshaler_all = 63017; + optional bool unmarshaler_all = 63018; + optional bool stable_marshaler_all = 63019; + + optional bool sizer_all = 63020; + + optional bool goproto_enum_stringer_all = 63021; + optional bool enum_stringer_all = 63022; + + optional bool unsafe_marshaler_all = 63023; + optional bool unsafe_unmarshaler_all = 63024; + + optional bool goproto_extensions_map_all = 63025; + optional bool goproto_unrecognized_all = 63026; + optional bool gogoproto_import = 63027; + optional bool protosizer_all = 63028; + optional bool compare_all = 63029; + optional bool typedecl_all = 63030; + optional bool enumdecl_all = 63031; + + optional bool goproto_registration = 63032; + optional bool messagename_all = 63033; + + optional bool goproto_sizecache_all = 63034; + optional bool goproto_unkeyed_all = 63035; +} + +extend google.protobuf.MessageOptions { + optional bool goproto_getters = 64001; + optional bool goproto_stringer = 64003; + optional bool verbose_equal = 64004; + optional bool face = 64005; + optional bool gostring = 64006; + optional bool populate = 64007; + optional bool stringer = 67008; + optional bool onlyone = 64009; + + optional bool equal = 64013; + optional bool description = 64014; + optional bool testgen = 64015; + optional bool benchgen = 64016; + optional bool marshaler = 64017; + optional bool unmarshaler = 64018; + optional bool stable_marshaler = 64019; + + optional bool sizer = 64020; + + optional bool unsafe_marshaler = 64023; + optional bool unsafe_unmarshaler = 64024; + + optional bool goproto_extensions_map = 64025; + optional bool goproto_unrecognized = 64026; + + optional bool protosizer = 64028; + optional bool compare = 64029; + + optional bool typedecl = 64030; + + optional bool messagename = 64033; + + optional bool goproto_sizecache = 64034; + optional bool goproto_unkeyed = 64035; +} + +extend google.protobuf.FieldOptions { + optional bool nullable = 65001; + optional bool embed = 65002; + optional string customtype = 65003; + optional string customname = 65004; + optional string jsontag = 65005; + optional string moretags = 65006; + optional string casttype = 65007; + optional string castkey = 65008; + optional string castvalue = 65009; + + optional bool stdtime = 65010; + optional bool stdduration = 65011; + optional bool wktpointer = 65012; + +} \ No newline at end of file diff --git a/proto/gogo.rs b/proto/gogo.rs new file mode 100644 index 00000000..b6cbbfa8 --- /dev/null +++ b/proto/gogo.rs @@ -0,0 +1,327 @@ +// This file is generated by rust-protobuf 3.2.0. Do not edit +// .proto file is parsed by protoc 3.19.4 +// @generated + +// https://github.com/rust-lang/rust-clippy/issues/702 +#![allow(unknown_lints)] +#![allow(clippy::all)] + +#![allow(unused_attributes)] +#![cfg_attr(rustfmt, rustfmt::skip)] + +#![allow(box_pointers)] +#![allow(dead_code)] +#![allow(missing_docs)] +#![allow(non_camel_case_types)] +#![allow(non_snake_case)] +#![allow(non_upper_case_globals)] +#![allow(trivial_casts)] +#![allow(unused_results)] +#![allow(unused_mut)] + +//! Generated file from `gogo.proto` + +/// Generated files are compatible only with the same version +/// of protobuf runtime. +const _PROTOBUF_VERSION_CHECK: () = ::protobuf::VERSION_3_2_0; + +/// Extension fields +pub mod exts { + + pub const goproto_enum_prefix: ::protobuf::ext::ExtFieldOptional<::protobuf::descriptor::EnumOptions, bool> = ::protobuf::ext::ExtFieldOptional::new(62001, ::protobuf::descriptor::field_descriptor_proto::Type::TYPE_BOOL); + + pub const goproto_enum_stringer: ::protobuf::ext::ExtFieldOptional<::protobuf::descriptor::EnumOptions, bool> = ::protobuf::ext::ExtFieldOptional::new(62021, ::protobuf::descriptor::field_descriptor_proto::Type::TYPE_BOOL); + + pub const enum_stringer: ::protobuf::ext::ExtFieldOptional<::protobuf::descriptor::EnumOptions, bool> = ::protobuf::ext::ExtFieldOptional::new(62022, ::protobuf::descriptor::field_descriptor_proto::Type::TYPE_BOOL); + + pub const enum_customname: ::protobuf::ext::ExtFieldOptional<::protobuf::descriptor::EnumOptions, ::std::string::String> = ::protobuf::ext::ExtFieldOptional::new(62023, ::protobuf::descriptor::field_descriptor_proto::Type::TYPE_STRING); + + pub const enumdecl: ::protobuf::ext::ExtFieldOptional<::protobuf::descriptor::EnumOptions, bool> = ::protobuf::ext::ExtFieldOptional::new(62024, ::protobuf::descriptor::field_descriptor_proto::Type::TYPE_BOOL); + + pub const enumvalue_customname: ::protobuf::ext::ExtFieldOptional<::protobuf::descriptor::EnumValueOptions, ::std::string::String> = ::protobuf::ext::ExtFieldOptional::new(66001, ::protobuf::descriptor::field_descriptor_proto::Type::TYPE_STRING); + + pub const goproto_getters_all: ::protobuf::ext::ExtFieldOptional<::protobuf::descriptor::FileOptions, bool> = ::protobuf::ext::ExtFieldOptional::new(63001, ::protobuf::descriptor::field_descriptor_proto::Type::TYPE_BOOL); + + pub const goproto_enum_prefix_all: ::protobuf::ext::ExtFieldOptional<::protobuf::descriptor::FileOptions, bool> = ::protobuf::ext::ExtFieldOptional::new(63002, ::protobuf::descriptor::field_descriptor_proto::Type::TYPE_BOOL); + + pub const goproto_stringer_all: ::protobuf::ext::ExtFieldOptional<::protobuf::descriptor::FileOptions, bool> = ::protobuf::ext::ExtFieldOptional::new(63003, ::protobuf::descriptor::field_descriptor_proto::Type::TYPE_BOOL); + + pub const verbose_equal_all: ::protobuf::ext::ExtFieldOptional<::protobuf::descriptor::FileOptions, bool> = ::protobuf::ext::ExtFieldOptional::new(63004, ::protobuf::descriptor::field_descriptor_proto::Type::TYPE_BOOL); + + pub const face_all: ::protobuf::ext::ExtFieldOptional<::protobuf::descriptor::FileOptions, bool> = ::protobuf::ext::ExtFieldOptional::new(63005, ::protobuf::descriptor::field_descriptor_proto::Type::TYPE_BOOL); + + pub const gostring_all: ::protobuf::ext::ExtFieldOptional<::protobuf::descriptor::FileOptions, bool> = ::protobuf::ext::ExtFieldOptional::new(63006, ::protobuf::descriptor::field_descriptor_proto::Type::TYPE_BOOL); + + pub const populate_all: ::protobuf::ext::ExtFieldOptional<::protobuf::descriptor::FileOptions, bool> = ::protobuf::ext::ExtFieldOptional::new(63007, ::protobuf::descriptor::field_descriptor_proto::Type::TYPE_BOOL); + + pub const stringer_all: ::protobuf::ext::ExtFieldOptional<::protobuf::descriptor::FileOptions, bool> = ::protobuf::ext::ExtFieldOptional::new(63008, ::protobuf::descriptor::field_descriptor_proto::Type::TYPE_BOOL); + + pub const onlyone_all: ::protobuf::ext::ExtFieldOptional<::protobuf::descriptor::FileOptions, bool> = ::protobuf::ext::ExtFieldOptional::new(63009, ::protobuf::descriptor::field_descriptor_proto::Type::TYPE_BOOL); + + pub const equal_all: ::protobuf::ext::ExtFieldOptional<::protobuf::descriptor::FileOptions, bool> = ::protobuf::ext::ExtFieldOptional::new(63013, ::protobuf::descriptor::field_descriptor_proto::Type::TYPE_BOOL); + + pub const description_all: ::protobuf::ext::ExtFieldOptional<::protobuf::descriptor::FileOptions, bool> = ::protobuf::ext::ExtFieldOptional::new(63014, ::protobuf::descriptor::field_descriptor_proto::Type::TYPE_BOOL); + + pub const testgen_all: ::protobuf::ext::ExtFieldOptional<::protobuf::descriptor::FileOptions, bool> = ::protobuf::ext::ExtFieldOptional::new(63015, ::protobuf::descriptor::field_descriptor_proto::Type::TYPE_BOOL); + + pub const benchgen_all: ::protobuf::ext::ExtFieldOptional<::protobuf::descriptor::FileOptions, bool> = ::protobuf::ext::ExtFieldOptional::new(63016, ::protobuf::descriptor::field_descriptor_proto::Type::TYPE_BOOL); + + pub const marshaler_all: ::protobuf::ext::ExtFieldOptional<::protobuf::descriptor::FileOptions, bool> = ::protobuf::ext::ExtFieldOptional::new(63017, ::protobuf::descriptor::field_descriptor_proto::Type::TYPE_BOOL); + + pub const unmarshaler_all: ::protobuf::ext::ExtFieldOptional<::protobuf::descriptor::FileOptions, bool> = ::protobuf::ext::ExtFieldOptional::new(63018, ::protobuf::descriptor::field_descriptor_proto::Type::TYPE_BOOL); + + pub const stable_marshaler_all: ::protobuf::ext::ExtFieldOptional<::protobuf::descriptor::FileOptions, bool> = ::protobuf::ext::ExtFieldOptional::new(63019, ::protobuf::descriptor::field_descriptor_proto::Type::TYPE_BOOL); + + pub const sizer_all: ::protobuf::ext::ExtFieldOptional<::protobuf::descriptor::FileOptions, bool> = ::protobuf::ext::ExtFieldOptional::new(63020, ::protobuf::descriptor::field_descriptor_proto::Type::TYPE_BOOL); + + pub const goproto_enum_stringer_all: ::protobuf::ext::ExtFieldOptional<::protobuf::descriptor::FileOptions, bool> = ::protobuf::ext::ExtFieldOptional::new(63021, ::protobuf::descriptor::field_descriptor_proto::Type::TYPE_BOOL); + + pub const enum_stringer_all: ::protobuf::ext::ExtFieldOptional<::protobuf::descriptor::FileOptions, bool> = ::protobuf::ext::ExtFieldOptional::new(63022, ::protobuf::descriptor::field_descriptor_proto::Type::TYPE_BOOL); + + pub const unsafe_marshaler_all: ::protobuf::ext::ExtFieldOptional<::protobuf::descriptor::FileOptions, bool> = ::protobuf::ext::ExtFieldOptional::new(63023, ::protobuf::descriptor::field_descriptor_proto::Type::TYPE_BOOL); + + pub const unsafe_unmarshaler_all: ::protobuf::ext::ExtFieldOptional<::protobuf::descriptor::FileOptions, bool> = ::protobuf::ext::ExtFieldOptional::new(63024, ::protobuf::descriptor::field_descriptor_proto::Type::TYPE_BOOL); + + pub const goproto_extensions_map_all: ::protobuf::ext::ExtFieldOptional<::protobuf::descriptor::FileOptions, bool> = ::protobuf::ext::ExtFieldOptional::new(63025, ::protobuf::descriptor::field_descriptor_proto::Type::TYPE_BOOL); + + pub const goproto_unrecognized_all: ::protobuf::ext::ExtFieldOptional<::protobuf::descriptor::FileOptions, bool> = ::protobuf::ext::ExtFieldOptional::new(63026, ::protobuf::descriptor::field_descriptor_proto::Type::TYPE_BOOL); + + pub const gogoproto_import: ::protobuf::ext::ExtFieldOptional<::protobuf::descriptor::FileOptions, bool> = ::protobuf::ext::ExtFieldOptional::new(63027, ::protobuf::descriptor::field_descriptor_proto::Type::TYPE_BOOL); + + pub const protosizer_all: ::protobuf::ext::ExtFieldOptional<::protobuf::descriptor::FileOptions, bool> = ::protobuf::ext::ExtFieldOptional::new(63028, ::protobuf::descriptor::field_descriptor_proto::Type::TYPE_BOOL); + + pub const compare_all: ::protobuf::ext::ExtFieldOptional<::protobuf::descriptor::FileOptions, bool> = ::protobuf::ext::ExtFieldOptional::new(63029, ::protobuf::descriptor::field_descriptor_proto::Type::TYPE_BOOL); + + pub const typedecl_all: ::protobuf::ext::ExtFieldOptional<::protobuf::descriptor::FileOptions, bool> = ::protobuf::ext::ExtFieldOptional::new(63030, ::protobuf::descriptor::field_descriptor_proto::Type::TYPE_BOOL); + + pub const enumdecl_all: ::protobuf::ext::ExtFieldOptional<::protobuf::descriptor::FileOptions, bool> = ::protobuf::ext::ExtFieldOptional::new(63031, ::protobuf::descriptor::field_descriptor_proto::Type::TYPE_BOOL); + + pub const goproto_registration: ::protobuf::ext::ExtFieldOptional<::protobuf::descriptor::FileOptions, bool> = ::protobuf::ext::ExtFieldOptional::new(63032, ::protobuf::descriptor::field_descriptor_proto::Type::TYPE_BOOL); + + pub const messagename_all: ::protobuf::ext::ExtFieldOptional<::protobuf::descriptor::FileOptions, bool> = ::protobuf::ext::ExtFieldOptional::new(63033, ::protobuf::descriptor::field_descriptor_proto::Type::TYPE_BOOL); + + pub const goproto_sizecache_all: ::protobuf::ext::ExtFieldOptional<::protobuf::descriptor::FileOptions, bool> = ::protobuf::ext::ExtFieldOptional::new(63034, ::protobuf::descriptor::field_descriptor_proto::Type::TYPE_BOOL); + + pub const goproto_unkeyed_all: ::protobuf::ext::ExtFieldOptional<::protobuf::descriptor::FileOptions, bool> = ::protobuf::ext::ExtFieldOptional::new(63035, ::protobuf::descriptor::field_descriptor_proto::Type::TYPE_BOOL); + + pub const goproto_getters: ::protobuf::ext::ExtFieldOptional<::protobuf::descriptor::MessageOptions, bool> = ::protobuf::ext::ExtFieldOptional::new(64001, ::protobuf::descriptor::field_descriptor_proto::Type::TYPE_BOOL); + + pub const goproto_stringer: ::protobuf::ext::ExtFieldOptional<::protobuf::descriptor::MessageOptions, bool> = ::protobuf::ext::ExtFieldOptional::new(64003, ::protobuf::descriptor::field_descriptor_proto::Type::TYPE_BOOL); + + pub const verbose_equal: ::protobuf::ext::ExtFieldOptional<::protobuf::descriptor::MessageOptions, bool> = ::protobuf::ext::ExtFieldOptional::new(64004, ::protobuf::descriptor::field_descriptor_proto::Type::TYPE_BOOL); + + pub const face: ::protobuf::ext::ExtFieldOptional<::protobuf::descriptor::MessageOptions, bool> = ::protobuf::ext::ExtFieldOptional::new(64005, ::protobuf::descriptor::field_descriptor_proto::Type::TYPE_BOOL); + + pub const gostring: ::protobuf::ext::ExtFieldOptional<::protobuf::descriptor::MessageOptions, bool> = ::protobuf::ext::ExtFieldOptional::new(64006, ::protobuf::descriptor::field_descriptor_proto::Type::TYPE_BOOL); + + pub const populate: ::protobuf::ext::ExtFieldOptional<::protobuf::descriptor::MessageOptions, bool> = ::protobuf::ext::ExtFieldOptional::new(64007, ::protobuf::descriptor::field_descriptor_proto::Type::TYPE_BOOL); + + pub const stringer: ::protobuf::ext::ExtFieldOptional<::protobuf::descriptor::MessageOptions, bool> = ::protobuf::ext::ExtFieldOptional::new(67008, ::protobuf::descriptor::field_descriptor_proto::Type::TYPE_BOOL); + + pub const onlyone: ::protobuf::ext::ExtFieldOptional<::protobuf::descriptor::MessageOptions, bool> = ::protobuf::ext::ExtFieldOptional::new(64009, ::protobuf::descriptor::field_descriptor_proto::Type::TYPE_BOOL); + + pub const equal: ::protobuf::ext::ExtFieldOptional<::protobuf::descriptor::MessageOptions, bool> = ::protobuf::ext::ExtFieldOptional::new(64013, ::protobuf::descriptor::field_descriptor_proto::Type::TYPE_BOOL); + + pub const description: ::protobuf::ext::ExtFieldOptional<::protobuf::descriptor::MessageOptions, bool> = ::protobuf::ext::ExtFieldOptional::new(64014, ::protobuf::descriptor::field_descriptor_proto::Type::TYPE_BOOL); + + pub const testgen: ::protobuf::ext::ExtFieldOptional<::protobuf::descriptor::MessageOptions, bool> = ::protobuf::ext::ExtFieldOptional::new(64015, ::protobuf::descriptor::field_descriptor_proto::Type::TYPE_BOOL); + + pub const benchgen: ::protobuf::ext::ExtFieldOptional<::protobuf::descriptor::MessageOptions, bool> = ::protobuf::ext::ExtFieldOptional::new(64016, ::protobuf::descriptor::field_descriptor_proto::Type::TYPE_BOOL); + + pub const marshaler: ::protobuf::ext::ExtFieldOptional<::protobuf::descriptor::MessageOptions, bool> = ::protobuf::ext::ExtFieldOptional::new(64017, ::protobuf::descriptor::field_descriptor_proto::Type::TYPE_BOOL); + + pub const unmarshaler: ::protobuf::ext::ExtFieldOptional<::protobuf::descriptor::MessageOptions, bool> = ::protobuf::ext::ExtFieldOptional::new(64018, ::protobuf::descriptor::field_descriptor_proto::Type::TYPE_BOOL); + + pub const stable_marshaler: ::protobuf::ext::ExtFieldOptional<::protobuf::descriptor::MessageOptions, bool> = ::protobuf::ext::ExtFieldOptional::new(64019, ::protobuf::descriptor::field_descriptor_proto::Type::TYPE_BOOL); + + pub const sizer: ::protobuf::ext::ExtFieldOptional<::protobuf::descriptor::MessageOptions, bool> = ::protobuf::ext::ExtFieldOptional::new(64020, ::protobuf::descriptor::field_descriptor_proto::Type::TYPE_BOOL); + + pub const unsafe_marshaler: ::protobuf::ext::ExtFieldOptional<::protobuf::descriptor::MessageOptions, bool> = ::protobuf::ext::ExtFieldOptional::new(64023, ::protobuf::descriptor::field_descriptor_proto::Type::TYPE_BOOL); + + pub const unsafe_unmarshaler: ::protobuf::ext::ExtFieldOptional<::protobuf::descriptor::MessageOptions, bool> = ::protobuf::ext::ExtFieldOptional::new(64024, ::protobuf::descriptor::field_descriptor_proto::Type::TYPE_BOOL); + + pub const goproto_extensions_map: ::protobuf::ext::ExtFieldOptional<::protobuf::descriptor::MessageOptions, bool> = ::protobuf::ext::ExtFieldOptional::new(64025, ::protobuf::descriptor::field_descriptor_proto::Type::TYPE_BOOL); + + pub const goproto_unrecognized: ::protobuf::ext::ExtFieldOptional<::protobuf::descriptor::MessageOptions, bool> = ::protobuf::ext::ExtFieldOptional::new(64026, ::protobuf::descriptor::field_descriptor_proto::Type::TYPE_BOOL); + + pub const protosizer: ::protobuf::ext::ExtFieldOptional<::protobuf::descriptor::MessageOptions, bool> = ::protobuf::ext::ExtFieldOptional::new(64028, ::protobuf::descriptor::field_descriptor_proto::Type::TYPE_BOOL); + + pub const compare: ::protobuf::ext::ExtFieldOptional<::protobuf::descriptor::MessageOptions, bool> = ::protobuf::ext::ExtFieldOptional::new(64029, ::protobuf::descriptor::field_descriptor_proto::Type::TYPE_BOOL); + + pub const typedecl: ::protobuf::ext::ExtFieldOptional<::protobuf::descriptor::MessageOptions, bool> = ::protobuf::ext::ExtFieldOptional::new(64030, ::protobuf::descriptor::field_descriptor_proto::Type::TYPE_BOOL); + + pub const messagename: ::protobuf::ext::ExtFieldOptional<::protobuf::descriptor::MessageOptions, bool> = ::protobuf::ext::ExtFieldOptional::new(64033, ::protobuf::descriptor::field_descriptor_proto::Type::TYPE_BOOL); + + pub const goproto_sizecache: ::protobuf::ext::ExtFieldOptional<::protobuf::descriptor::MessageOptions, bool> = ::protobuf::ext::ExtFieldOptional::new(64034, ::protobuf::descriptor::field_descriptor_proto::Type::TYPE_BOOL); + + pub const goproto_unkeyed: ::protobuf::ext::ExtFieldOptional<::protobuf::descriptor::MessageOptions, bool> = ::protobuf::ext::ExtFieldOptional::new(64035, ::protobuf::descriptor::field_descriptor_proto::Type::TYPE_BOOL); + + pub const nullable: ::protobuf::ext::ExtFieldOptional<::protobuf::descriptor::FieldOptions, bool> = ::protobuf::ext::ExtFieldOptional::new(65001, ::protobuf::descriptor::field_descriptor_proto::Type::TYPE_BOOL); + + pub const embed: ::protobuf::ext::ExtFieldOptional<::protobuf::descriptor::FieldOptions, bool> = ::protobuf::ext::ExtFieldOptional::new(65002, ::protobuf::descriptor::field_descriptor_proto::Type::TYPE_BOOL); + + pub const customtype: ::protobuf::ext::ExtFieldOptional<::protobuf::descriptor::FieldOptions, ::std::string::String> = ::protobuf::ext::ExtFieldOptional::new(65003, ::protobuf::descriptor::field_descriptor_proto::Type::TYPE_STRING); + + pub const customname: ::protobuf::ext::ExtFieldOptional<::protobuf::descriptor::FieldOptions, ::std::string::String> = ::protobuf::ext::ExtFieldOptional::new(65004, ::protobuf::descriptor::field_descriptor_proto::Type::TYPE_STRING); + + pub const jsontag: ::protobuf::ext::ExtFieldOptional<::protobuf::descriptor::FieldOptions, ::std::string::String> = ::protobuf::ext::ExtFieldOptional::new(65005, ::protobuf::descriptor::field_descriptor_proto::Type::TYPE_STRING); + + pub const moretags: ::protobuf::ext::ExtFieldOptional<::protobuf::descriptor::FieldOptions, ::std::string::String> = ::protobuf::ext::ExtFieldOptional::new(65006, ::protobuf::descriptor::field_descriptor_proto::Type::TYPE_STRING); + + pub const casttype: ::protobuf::ext::ExtFieldOptional<::protobuf::descriptor::FieldOptions, ::std::string::String> = ::protobuf::ext::ExtFieldOptional::new(65007, ::protobuf::descriptor::field_descriptor_proto::Type::TYPE_STRING); + + pub const castkey: ::protobuf::ext::ExtFieldOptional<::protobuf::descriptor::FieldOptions, ::std::string::String> = ::protobuf::ext::ExtFieldOptional::new(65008, ::protobuf::descriptor::field_descriptor_proto::Type::TYPE_STRING); + + pub const castvalue: ::protobuf::ext::ExtFieldOptional<::protobuf::descriptor::FieldOptions, ::std::string::String> = ::protobuf::ext::ExtFieldOptional::new(65009, ::protobuf::descriptor::field_descriptor_proto::Type::TYPE_STRING); + + pub const stdtime: ::protobuf::ext::ExtFieldOptional<::protobuf::descriptor::FieldOptions, bool> = ::protobuf::ext::ExtFieldOptional::new(65010, ::protobuf::descriptor::field_descriptor_proto::Type::TYPE_BOOL); + + pub const stdduration: ::protobuf::ext::ExtFieldOptional<::protobuf::descriptor::FieldOptions, bool> = ::protobuf::ext::ExtFieldOptional::new(65011, ::protobuf::descriptor::field_descriptor_proto::Type::TYPE_BOOL); + + pub const wktpointer: ::protobuf::ext::ExtFieldOptional<::protobuf::descriptor::FieldOptions, bool> = ::protobuf::ext::ExtFieldOptional::new(65012, ::protobuf::descriptor::field_descriptor_proto::Type::TYPE_BOOL); +} + +static file_descriptor_proto_data: &'static [u8] = b"\ + \n\ngogo.proto\x12\tgogoproto\x1a\x20google/protobuf/descriptor.proto:N\ + \n\x13goproto_enum_prefix\x18\xb1\xe4\x03\x20\x01(\x08\x12\x1c.google.pr\ + otobuf.EnumOptionsR\x11goprotoEnumPrefix:R\n\x15goproto_enum_stringer\ + \x18\xc5\xe4\x03\x20\x01(\x08\x12\x1c.google.protobuf.EnumOptionsR\x13go\ + protoEnumStringer:C\n\renum_stringer\x18\xc6\xe4\x03\x20\x01(\x08\x12\ + \x1c.google.protobuf.EnumOptionsR\x0cenumStringer:G\n\x0fenum_customname\ + \x18\xc7\xe4\x03\x20\x01(\t\x12\x1c.google.protobuf.EnumOptionsR\x0eenum\ + Customname::\n\x08enumdecl\x18\xc8\xe4\x03\x20\x01(\x08\x12\x1c.google.p\ + rotobuf.EnumOptionsR\x08enumdecl:V\n\x14enumvalue_customname\x18\xd1\x83\ + \x04\x20\x01(\t\x12!.google.protobuf.EnumValueOptionsR\x13enumvalueCusto\ + mname:N\n\x13goproto_getters_all\x18\x99\xec\x03\x20\x01(\x08\x12\x1c.go\ + ogle.protobuf.FileOptionsR\x11goprotoGettersAll:U\n\x17goproto_enum_pref\ + ix_all\x18\x9a\xec\x03\x20\x01(\x08\x12\x1c.google.protobuf.FileOptionsR\ + \x14goprotoEnumPrefixAll:P\n\x14goproto_stringer_all\x18\x9b\xec\x03\x20\ + \x01(\x08\x12\x1c.google.protobuf.FileOptionsR\x12goprotoStringerAll:J\n\ + \x11verbose_equal_all\x18\x9c\xec\x03\x20\x01(\x08\x12\x1c.google.protob\ + uf.FileOptionsR\x0fverboseEqualAll:9\n\x08face_all\x18\x9d\xec\x03\x20\ + \x01(\x08\x12\x1c.google.protobuf.FileOptionsR\x07faceAll:A\n\x0cgostrin\ + g_all\x18\x9e\xec\x03\x20\x01(\x08\x12\x1c.google.protobuf.FileOptionsR\ + \x0bgostringAll:A\n\x0cpopulate_all\x18\x9f\xec\x03\x20\x01(\x08\x12\x1c\ + .google.protobuf.FileOptionsR\x0bpopulateAll:A\n\x0cstringer_all\x18\xa0\ + \xec\x03\x20\x01(\x08\x12\x1c.google.protobuf.FileOptionsR\x0bstringerAl\ + l:?\n\x0bonlyone_all\x18\xa1\xec\x03\x20\x01(\x08\x12\x1c.google.protobu\ + f.FileOptionsR\nonlyoneAll:;\n\tequal_all\x18\xa5\xec\x03\x20\x01(\x08\ + \x12\x1c.google.protobuf.FileOptionsR\x08equalAll:G\n\x0fdescription_all\ + \x18\xa6\xec\x03\x20\x01(\x08\x12\x1c.google.protobuf.FileOptionsR\x0ede\ + scriptionAll:?\n\x0btestgen_all\x18\xa7\xec\x03\x20\x01(\x08\x12\x1c.goo\ + gle.protobuf.FileOptionsR\ntestgenAll:A\n\x0cbenchgen_all\x18\xa8\xec\ + \x03\x20\x01(\x08\x12\x1c.google.protobuf.FileOptionsR\x0bbenchgenAll:C\ + \n\rmarshaler_all\x18\xa9\xec\x03\x20\x01(\x08\x12\x1c.google.protobuf.F\ + ileOptionsR\x0cmarshalerAll:G\n\x0funmarshaler_all\x18\xaa\xec\x03\x20\ + \x01(\x08\x12\x1c.google.protobuf.FileOptionsR\x0eunmarshalerAll:P\n\x14\ + stable_marshaler_all\x18\xab\xec\x03\x20\x01(\x08\x12\x1c.google.protobu\ + f.FileOptionsR\x12stableMarshalerAll:;\n\tsizer_all\x18\xac\xec\x03\x20\ + \x01(\x08\x12\x1c.google.protobuf.FileOptionsR\x08sizerAll:Y\n\x19goprot\ + o_enum_stringer_all\x18\xad\xec\x03\x20\x01(\x08\x12\x1c.google.protobuf\ + .FileOptionsR\x16goprotoEnumStringerAll:J\n\x11enum_stringer_all\x18\xae\ + \xec\x03\x20\x01(\x08\x12\x1c.google.protobuf.FileOptionsR\x0fenumString\ + erAll:P\n\x14unsafe_marshaler_all\x18\xaf\xec\x03\x20\x01(\x08\x12\x1c.g\ + oogle.protobuf.FileOptionsR\x12unsafeMarshalerAll:T\n\x16unsafe_unmarsha\ + ler_all\x18\xb0\xec\x03\x20\x01(\x08\x12\x1c.google.protobuf.FileOptions\ + R\x14unsafeUnmarshalerAll:[\n\x1agoproto_extensions_map_all\x18\xb1\xec\ + \x03\x20\x01(\x08\x12\x1c.google.protobuf.FileOptionsR\x17goprotoExtensi\ + onsMapAll:X\n\x18goproto_unrecognized_all\x18\xb2\xec\x03\x20\x01(\x08\ + \x12\x1c.google.protobuf.FileOptionsR\x16goprotoUnrecognizedAll:I\n\x10g\ + ogoproto_import\x18\xb3\xec\x03\x20\x01(\x08\x12\x1c.google.protobuf.Fil\ + eOptionsR\x0fgogoprotoImport:E\n\x0eprotosizer_all\x18\xb4\xec\x03\x20\ + \x01(\x08\x12\x1c.google.protobuf.FileOptionsR\rprotosizerAll:?\n\x0bcom\ + pare_all\x18\xb5\xec\x03\x20\x01(\x08\x12\x1c.google.protobuf.FileOption\ + sR\ncompareAll:A\n\x0ctypedecl_all\x18\xb6\xec\x03\x20\x01(\x08\x12\x1c.\ + google.protobuf.FileOptionsR\x0btypedeclAll:A\n\x0cenumdecl_all\x18\xb7\ + \xec\x03\x20\x01(\x08\x12\x1c.google.protobuf.FileOptionsR\x0benumdeclAl\ + l:Q\n\x14goproto_registration\x18\xb8\xec\x03\x20\x01(\x08\x12\x1c.googl\ + e.protobuf.FileOptionsR\x13goprotoRegistration:G\n\x0fmessagename_all\ + \x18\xb9\xec\x03\x20\x01(\x08\x12\x1c.google.protobuf.FileOptionsR\x0eme\ + ssagenameAll:R\n\x15goproto_sizecache_all\x18\xba\xec\x03\x20\x01(\x08\ + \x12\x1c.google.protobuf.FileOptionsR\x13goprotoSizecacheAll:N\n\x13gopr\ + oto_unkeyed_all\x18\xbb\xec\x03\x20\x01(\x08\x12\x1c.google.protobuf.Fil\ + eOptionsR\x11goprotoUnkeyedAll:J\n\x0fgoproto_getters\x18\x81\xf4\x03\ + \x20\x01(\x08\x12\x1f.google.protobuf.MessageOptionsR\x0egoprotoGetters:\ + L\n\x10goproto_stringer\x18\x83\xf4\x03\x20\x01(\x08\x12\x1f.google.prot\ + obuf.MessageOptionsR\x0fgoprotoStringer:F\n\rverbose_equal\x18\x84\xf4\ + \x03\x20\x01(\x08\x12\x1f.google.protobuf.MessageOptionsR\x0cverboseEqua\ + l:5\n\x04face\x18\x85\xf4\x03\x20\x01(\x08\x12\x1f.google.protobuf.Messa\ + geOptionsR\x04face:=\n\x08gostring\x18\x86\xf4\x03\x20\x01(\x08\x12\x1f.\ + google.protobuf.MessageOptionsR\x08gostring:=\n\x08populate\x18\x87\xf4\ + \x03\x20\x01(\x08\x12\x1f.google.protobuf.MessageOptionsR\x08populate:=\ + \n\x08stringer\x18\xc0\x8b\x04\x20\x01(\x08\x12\x1f.google.protobuf.Mess\ + ageOptionsR\x08stringer:;\n\x07onlyone\x18\x89\xf4\x03\x20\x01(\x08\x12\ + \x1f.google.protobuf.MessageOptionsR\x07onlyone:7\n\x05equal\x18\x8d\xf4\ + \x03\x20\x01(\x08\x12\x1f.google.protobuf.MessageOptionsR\x05equal:C\n\ + \x0bdescription\x18\x8e\xf4\x03\x20\x01(\x08\x12\x1f.google.protobuf.Mes\ + sageOptionsR\x0bdescription:;\n\x07testgen\x18\x8f\xf4\x03\x20\x01(\x08\ + \x12\x1f.google.protobuf.MessageOptionsR\x07testgen:=\n\x08benchgen\x18\ + \x90\xf4\x03\x20\x01(\x08\x12\x1f.google.protobuf.MessageOptionsR\x08ben\ + chgen:?\n\tmarshaler\x18\x91\xf4\x03\x20\x01(\x08\x12\x1f.google.protobu\ + f.MessageOptionsR\tmarshaler:C\n\x0bunmarshaler\x18\x92\xf4\x03\x20\x01(\ + \x08\x12\x1f.google.protobuf.MessageOptionsR\x0bunmarshaler:L\n\x10stabl\ + e_marshaler\x18\x93\xf4\x03\x20\x01(\x08\x12\x1f.google.protobuf.Message\ + OptionsR\x0fstableMarshaler:7\n\x05sizer\x18\x94\xf4\x03\x20\x01(\x08\ + \x12\x1f.google.protobuf.MessageOptionsR\x05sizer:L\n\x10unsafe_marshale\ + r\x18\x97\xf4\x03\x20\x01(\x08\x12\x1f.google.protobuf.MessageOptionsR\ + \x0funsafeMarshaler:P\n\x12unsafe_unmarshaler\x18\x98\xf4\x03\x20\x01(\ + \x08\x12\x1f.google.protobuf.MessageOptionsR\x11unsafeUnmarshaler:W\n\ + \x16goproto_extensions_map\x18\x99\xf4\x03\x20\x01(\x08\x12\x1f.google.p\ + rotobuf.MessageOptionsR\x14goprotoExtensionsMap:T\n\x14goproto_unrecogni\ + zed\x18\x9a\xf4\x03\x20\x01(\x08\x12\x1f.google.protobuf.MessageOptionsR\ + \x13goprotoUnrecognized:A\n\nprotosizer\x18\x9c\xf4\x03\x20\x01(\x08\x12\ + \x1f.google.protobuf.MessageOptionsR\nprotosizer:;\n\x07compare\x18\x9d\ + \xf4\x03\x20\x01(\x08\x12\x1f.google.protobuf.MessageOptionsR\x07compare\ + :=\n\x08typedecl\x18\x9e\xf4\x03\x20\x01(\x08\x12\x1f.google.protobuf.Me\ + ssageOptionsR\x08typedecl:C\n\x0bmessagename\x18\xa1\xf4\x03\x20\x01(\ + \x08\x12\x1f.google.protobuf.MessageOptionsR\x0bmessagename:N\n\x11gopro\ + to_sizecache\x18\xa2\xf4\x03\x20\x01(\x08\x12\x1f.google.protobuf.Messag\ + eOptionsR\x10goprotoSizecache:J\n\x0fgoproto_unkeyed\x18\xa3\xf4\x03\x20\ + \x01(\x08\x12\x1f.google.protobuf.MessageOptionsR\x0egoprotoUnkeyed:;\n\ + \x08nullable\x18\xe9\xfb\x03\x20\x01(\x08\x12\x1d.google.protobuf.FieldO\ + ptionsR\x08nullable:5\n\x05embed\x18\xea\xfb\x03\x20\x01(\x08\x12\x1d.go\ + ogle.protobuf.FieldOptionsR\x05embed:?\n\ncustomtype\x18\xeb\xfb\x03\x20\ + \x01(\t\x12\x1d.google.protobuf.FieldOptionsR\ncustomtype:?\n\ncustomnam\ + e\x18\xec\xfb\x03\x20\x01(\t\x12\x1d.google.protobuf.FieldOptionsR\ncust\ + omname:9\n\x07jsontag\x18\xed\xfb\x03\x20\x01(\t\x12\x1d.google.protobuf\ + .FieldOptionsR\x07jsontag:;\n\x08moretags\x18\xee\xfb\x03\x20\x01(\t\x12\ + \x1d.google.protobuf.FieldOptionsR\x08moretags:;\n\x08casttype\x18\xef\ + \xfb\x03\x20\x01(\t\x12\x1d.google.protobuf.FieldOptionsR\x08casttype:9\ + \n\x07castkey\x18\xf0\xfb\x03\x20\x01(\t\x12\x1d.google.protobuf.FieldOp\ + tionsR\x07castkey:=\n\tcastvalue\x18\xf1\xfb\x03\x20\x01(\t\x12\x1d.goog\ + le.protobuf.FieldOptionsR\tcastvalue:9\n\x07stdtime\x18\xf2\xfb\x03\x20\ + \x01(\x08\x12\x1d.google.protobuf.FieldOptionsR\x07stdtime:A\n\x0bstddur\ + ation\x18\xf3\xfb\x03\x20\x01(\x08\x12\x1d.google.protobuf.FieldOptionsR\ + \x0bstdduration:?\n\nwktpointer\x18\xf4\xfb\x03\x20\x01(\x08\x12\x1d.goo\ + gle.protobuf.FieldOptionsR\nwktpointerBE\n\x13com.google.protobufB\nGoGo\ + ProtosZ\"github.com/gogo/protobuf/gogoproto\ +"; + +/// `FileDescriptorProto` object which was a source for this generated file +fn file_descriptor_proto() -> &'static ::protobuf::descriptor::FileDescriptorProto { + static file_descriptor_proto_lazy: ::protobuf::rt::Lazy<::protobuf::descriptor::FileDescriptorProto> = ::protobuf::rt::Lazy::new(); + file_descriptor_proto_lazy.get(|| { + ::protobuf::Message::parse_from_bytes(file_descriptor_proto_data).unwrap() + }) +} + +/// `FileDescriptor` object which allows dynamic access to files +pub fn file_descriptor() -> &'static ::protobuf::reflect::FileDescriptor { + static generated_file_descriptor_lazy: ::protobuf::rt::Lazy<::protobuf::reflect::GeneratedFileDescriptor> = ::protobuf::rt::Lazy::new(); + static file_descriptor: ::protobuf::rt::Lazy<::protobuf::reflect::FileDescriptor> = ::protobuf::rt::Lazy::new(); + file_descriptor.get(|| { + let generated_file_descriptor = generated_file_descriptor_lazy.get(|| { + let mut deps = ::std::vec::Vec::with_capacity(1); + deps.push(::protobuf::descriptor::file_descriptor().clone()); + let mut messages = ::std::vec::Vec::with_capacity(0); + let mut enums = ::std::vec::Vec::with_capacity(0); + ::protobuf::reflect::GeneratedFileDescriptor::new_generated( + file_descriptor_proto(), + deps, + messages, + enums, + ) + }); + ::protobuf::reflect::FileDescriptor::new_generated_2(generated_file_descriptor) + }) +} diff --git a/proto/metrics.proto b/proto/metrics.proto new file mode 100644 index 00000000..9365eca4 --- /dev/null +++ b/proto/metrics.proto @@ -0,0 +1,147 @@ +// Copyright 2013 Prometheus Team +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// This is copied and lightly edited from +// github.com/prometheus/client_model/io/prometheus/client/metrics.proto +// and finally converted to proto3 syntax to make it usable for the +// gogo-protobuf approach taken within prometheus/prometheus. + +syntax = "proto3"; + +package io.prometheus.client; +option go_package = "io_prometheus_client"; + +import "gogo.proto"; +import "google/protobuf/timestamp.proto"; + +message LabelPair { + string name = 1; + string value = 2; +} + +enum MetricType { + // COUNTER must use the Metric field "counter". + COUNTER = 0; + // GAUGE must use the Metric field "gauge". + GAUGE = 1; + // SUMMARY must use the Metric field "summary". + SUMMARY = 2; + // UNTYPED must use the Metric field "untyped". + UNTYPED = 3; + // HISTOGRAM must use the Metric field "histogram". + HISTOGRAM = 4; + // GAUGE_HISTOGRAM must use the Metric field "histogram". + GAUGE_HISTOGRAM = 5; +} + +message Gauge { + double value = 1; +} + +message Counter { + double value = 1; + Exemplar exemplar = 2; +} + +message Quantile { + double quantile = 1; + double value = 2; +} + +message Summary { + uint64 sample_count = 1; + double sample_sum = 2; + repeated Quantile quantile = 3 [(gogoproto.nullable) = false]; +} + +message Untyped { + double value = 1; +} + +message Histogram { + uint64 sample_count = 1; + double sample_count_float = 4; // Overrides sample_count if > 0. + double sample_sum = 2; + // Buckets for the conventional histogram. + repeated Bucket bucket = 3 [(gogoproto.nullable) = false]; // Ordered in increasing order of upper_bound, +Inf bucket is optional. + + // Everything below here is for native histograms (also known as sparse histograms). + // Native histograms are an experimental feature without stability guarantees. + + // schema defines the bucket schema. Currently, valid numbers are -4 <= n <= 8. + // They are all for base-2 bucket schemas, where 1 is a bucket boundary in each case, and + // then each power of two is divided into 2^n logarithmic buckets. + // Or in other words, each bucket boundary is the previous boundary times 2^(2^-n). + // In the future, more bucket schemas may be added using numbers < -4 or > 8. + sint32 schema = 5; + double zero_threshold = 6; // Breadth of the zero bucket. + uint64 zero_count = 7; // Count in zero bucket. + double zero_count_float = 8; // Overrides sb_zero_count if > 0. + + // Negative buckets for the native histogram. + repeated BucketSpan negative_span = 9 [(gogoproto.nullable) = false]; + // Use either "negative_delta" or "negative_count", the former for + // regular histograms with integer counts, the latter for float + // histograms. + repeated sint64 negative_delta = 10; // Count delta of each bucket compared to previous one (or to zero for 1st bucket). + repeated double negative_count = 11; // Absolute count of each bucket. + + // Positive buckets for the native histogram. + repeated BucketSpan positive_span = 12 [(gogoproto.nullable) = false]; + // Use either "positive_delta" or "positive_count", the former for + // regular histograms with integer counts, the latter for float + // histograms. + repeated sint64 positive_delta = 13; // Count delta of each bucket compared to previous one (or to zero for 1st bucket). + repeated double positive_count = 14; // Absolute count of each bucket. +} + +message Bucket { + uint64 cumulative_count = 1; // Cumulative in increasing order. + double cumulative_count_float = 4; // Overrides cumulative_count if > 0. + double upper_bound = 2; // Inclusive. + Exemplar exemplar = 3; +} + +// A BucketSpan defines a number of consecutive buckets in a native +// histogram with their offset. Logically, it would be more +// straightforward to include the bucket counts in the Span. However, +// the protobuf representation is more compact in the way the data is +// structured here (with all the buckets in a single array separate +// from the Spans). +message BucketSpan { + sint32 offset = 1; // Gap to previous span, or starting point for 1st span (which can be negative). + uint32 length = 2; // Length of consecutive buckets. +} + +message Exemplar { + repeated LabelPair label = 1 [(gogoproto.nullable) = false]; + double value = 2; + google.protobuf.Timestamp timestamp = 3; // OpenMetrics-style. +} + +message Metric { + repeated LabelPair label = 1 [(gogoproto.nullable) = false]; + Gauge gauge = 2; + Counter counter = 3; + Summary summary = 4; + Untyped untyped = 5; + Histogram histogram = 7; + int64 timestamp_ms = 6; +} + +message MetricFamily { + string name = 1; + string help = 2; + MetricType type = 3; + repeated Metric metric = 4 [(gogoproto.nullable) = false]; +} \ No newline at end of file diff --git a/proto/metrics.rs b/proto/metrics.rs new file mode 100644 index 00000000..116769ff --- /dev/null +++ b/proto/metrics.rs @@ -0,0 +1,2276 @@ +// This file is generated by rust-protobuf 3.2.0. Do not edit +// .proto file is parsed by protoc 3.19.4 +// @generated + +// https://github.com/rust-lang/rust-clippy/issues/702 +#![allow(unknown_lints)] +#![allow(clippy::all)] + +#![allow(unused_attributes)] +#![cfg_attr(rustfmt, rustfmt::skip)] + +#![allow(box_pointers)] +#![allow(dead_code)] +#![allow(missing_docs)] +#![allow(non_camel_case_types)] +#![allow(non_snake_case)] +#![allow(non_upper_case_globals)] +#![allow(trivial_casts)] +#![allow(unused_results)] +#![allow(unused_mut)] + +//! Generated file from `metrics.proto` + +/// Generated files are compatible only with the same version +/// of protobuf runtime. +const _PROTOBUF_VERSION_CHECK: () = ::protobuf::VERSION_3_2_0; + +#[derive(PartialEq,Clone,Default,Debug)] +// @@protoc_insertion_point(message:io.prometheus.client.LabelPair) +pub struct LabelPair { + // message fields + // @@protoc_insertion_point(field:io.prometheus.client.LabelPair.name) + pub name: ::std::string::String, + // @@protoc_insertion_point(field:io.prometheus.client.LabelPair.value) + pub value: ::std::string::String, + // special fields + // @@protoc_insertion_point(special_field:io.prometheus.client.LabelPair.special_fields) + pub special_fields: ::protobuf::SpecialFields, +} + +impl<'a> ::std::default::Default for &'a LabelPair { + fn default() -> &'a LabelPair { + ::default_instance() + } +} + +impl LabelPair { + pub fn new() -> LabelPair { + ::std::default::Default::default() + } + + fn generated_message_descriptor_data() -> ::protobuf::reflect::GeneratedMessageDescriptorData { + let mut fields = ::std::vec::Vec::with_capacity(2); + let mut oneofs = ::std::vec::Vec::with_capacity(0); + fields.push(::protobuf::reflect::rt::v2::make_simpler_field_accessor::<_, _>( + "name", + |m: &LabelPair| { &m.name }, + |m: &mut LabelPair| { &mut m.name }, + )); + fields.push(::protobuf::reflect::rt::v2::make_simpler_field_accessor::<_, _>( + "value", + |m: &LabelPair| { &m.value }, + |m: &mut LabelPair| { &mut m.value }, + )); + ::protobuf::reflect::GeneratedMessageDescriptorData::new_2::( + "LabelPair", + fields, + oneofs, + ) + } +} + +impl ::protobuf::Message for LabelPair { + const NAME: &'static str = "LabelPair"; + + fn is_initialized(&self) -> bool { + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::Result<()> { + while let Some(tag) = is.read_raw_tag_or_eof()? { + match tag { + 10 => { + self.name = is.read_string()?; + }, + 18 => { + self.value = is.read_string()?; + }, + tag => { + ::protobuf::rt::read_unknown_or_skip_group(tag, is, self.special_fields.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u64 { + let mut my_size = 0; + if !self.name.is_empty() { + my_size += ::protobuf::rt::string_size(1, &self.name); + } + if !self.value.is_empty() { + my_size += ::protobuf::rt::string_size(2, &self.value); + } + my_size += ::protobuf::rt::unknown_fields_size(self.special_fields.unknown_fields()); + self.special_fields.cached_size().set(my_size as u32); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::Result<()> { + if !self.name.is_empty() { + os.write_string(1, &self.name)?; + } + if !self.value.is_empty() { + os.write_string(2, &self.value)?; + } + os.write_unknown_fields(self.special_fields.unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn special_fields(&self) -> &::protobuf::SpecialFields { + &self.special_fields + } + + fn mut_special_fields(&mut self) -> &mut ::protobuf::SpecialFields { + &mut self.special_fields + } + + fn new() -> LabelPair { + LabelPair::new() + } + + fn clear(&mut self) { + self.name.clear(); + self.value.clear(); + self.special_fields.clear(); + } + + fn default_instance() -> &'static LabelPair { + static instance: LabelPair = LabelPair { + name: ::std::string::String::new(), + value: ::std::string::String::new(), + special_fields: ::protobuf::SpecialFields::new(), + }; + &instance + } +} + +impl ::protobuf::MessageFull for LabelPair { + fn descriptor() -> ::protobuf::reflect::MessageDescriptor { + static descriptor: ::protobuf::rt::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::rt::Lazy::new(); + descriptor.get(|| file_descriptor().message_by_package_relative_name("LabelPair").unwrap()).clone() + } +} + +impl ::std::fmt::Display for LabelPair { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for LabelPair { + type RuntimeType = ::protobuf::reflect::rt::RuntimeTypeMessage; +} + +#[derive(PartialEq,Clone,Default,Debug)] +// @@protoc_insertion_point(message:io.prometheus.client.Gauge) +pub struct Gauge { + // message fields + // @@protoc_insertion_point(field:io.prometheus.client.Gauge.value) + pub value: f64, + // special fields + // @@protoc_insertion_point(special_field:io.prometheus.client.Gauge.special_fields) + pub special_fields: ::protobuf::SpecialFields, +} + +impl<'a> ::std::default::Default for &'a Gauge { + fn default() -> &'a Gauge { + ::default_instance() + } +} + +impl Gauge { + pub fn new() -> Gauge { + ::std::default::Default::default() + } + + fn generated_message_descriptor_data() -> ::protobuf::reflect::GeneratedMessageDescriptorData { + let mut fields = ::std::vec::Vec::with_capacity(1); + let mut oneofs = ::std::vec::Vec::with_capacity(0); + fields.push(::protobuf::reflect::rt::v2::make_simpler_field_accessor::<_, _>( + "value", + |m: &Gauge| { &m.value }, + |m: &mut Gauge| { &mut m.value }, + )); + ::protobuf::reflect::GeneratedMessageDescriptorData::new_2::( + "Gauge", + fields, + oneofs, + ) + } +} + +impl ::protobuf::Message for Gauge { + const NAME: &'static str = "Gauge"; + + fn is_initialized(&self) -> bool { + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::Result<()> { + while let Some(tag) = is.read_raw_tag_or_eof()? { + match tag { + 9 => { + self.value = is.read_double()?; + }, + tag => { + ::protobuf::rt::read_unknown_or_skip_group(tag, is, self.special_fields.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u64 { + let mut my_size = 0; + if self.value != 0. { + my_size += 1 + 8; + } + my_size += ::protobuf::rt::unknown_fields_size(self.special_fields.unknown_fields()); + self.special_fields.cached_size().set(my_size as u32); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::Result<()> { + if self.value != 0. { + os.write_double(1, self.value)?; + } + os.write_unknown_fields(self.special_fields.unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn special_fields(&self) -> &::protobuf::SpecialFields { + &self.special_fields + } + + fn mut_special_fields(&mut self) -> &mut ::protobuf::SpecialFields { + &mut self.special_fields + } + + fn new() -> Gauge { + Gauge::new() + } + + fn clear(&mut self) { + self.value = 0.; + self.special_fields.clear(); + } + + fn default_instance() -> &'static Gauge { + static instance: Gauge = Gauge { + value: 0., + special_fields: ::protobuf::SpecialFields::new(), + }; + &instance + } +} + +impl ::protobuf::MessageFull for Gauge { + fn descriptor() -> ::protobuf::reflect::MessageDescriptor { + static descriptor: ::protobuf::rt::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::rt::Lazy::new(); + descriptor.get(|| file_descriptor().message_by_package_relative_name("Gauge").unwrap()).clone() + } +} + +impl ::std::fmt::Display for Gauge { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for Gauge { + type RuntimeType = ::protobuf::reflect::rt::RuntimeTypeMessage; +} + +#[derive(PartialEq,Clone,Default,Debug)] +// @@protoc_insertion_point(message:io.prometheus.client.Counter) +pub struct Counter { + // message fields + // @@protoc_insertion_point(field:io.prometheus.client.Counter.value) + pub value: f64, + // @@protoc_insertion_point(field:io.prometheus.client.Counter.exemplar) + pub exemplar: ::protobuf::MessageField, + // special fields + // @@protoc_insertion_point(special_field:io.prometheus.client.Counter.special_fields) + pub special_fields: ::protobuf::SpecialFields, +} + +impl<'a> ::std::default::Default for &'a Counter { + fn default() -> &'a Counter { + ::default_instance() + } +} + +impl Counter { + pub fn new() -> Counter { + ::std::default::Default::default() + } + + fn generated_message_descriptor_data() -> ::protobuf::reflect::GeneratedMessageDescriptorData { + let mut fields = ::std::vec::Vec::with_capacity(2); + let mut oneofs = ::std::vec::Vec::with_capacity(0); + fields.push(::protobuf::reflect::rt::v2::make_simpler_field_accessor::<_, _>( + "value", + |m: &Counter| { &m.value }, + |m: &mut Counter| { &mut m.value }, + )); + fields.push(::protobuf::reflect::rt::v2::make_message_field_accessor::<_, Exemplar>( + "exemplar", + |m: &Counter| { &m.exemplar }, + |m: &mut Counter| { &mut m.exemplar }, + )); + ::protobuf::reflect::GeneratedMessageDescriptorData::new_2::( + "Counter", + fields, + oneofs, + ) + } +} + +impl ::protobuf::Message for Counter { + const NAME: &'static str = "Counter"; + + fn is_initialized(&self) -> bool { + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::Result<()> { + while let Some(tag) = is.read_raw_tag_or_eof()? { + match tag { + 9 => { + self.value = is.read_double()?; + }, + 18 => { + ::protobuf::rt::read_singular_message_into_field(is, &mut self.exemplar)?; + }, + tag => { + ::protobuf::rt::read_unknown_or_skip_group(tag, is, self.special_fields.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u64 { + let mut my_size = 0; + if self.value != 0. { + my_size += 1 + 8; + } + if let Some(v) = self.exemplar.as_ref() { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint64_size(len) + len; + } + my_size += ::protobuf::rt::unknown_fields_size(self.special_fields.unknown_fields()); + self.special_fields.cached_size().set(my_size as u32); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::Result<()> { + if self.value != 0. { + os.write_double(1, self.value)?; + } + if let Some(v) = self.exemplar.as_ref() { + ::protobuf::rt::write_message_field_with_cached_size(2, v, os)?; + } + os.write_unknown_fields(self.special_fields.unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn special_fields(&self) -> &::protobuf::SpecialFields { + &self.special_fields + } + + fn mut_special_fields(&mut self) -> &mut ::protobuf::SpecialFields { + &mut self.special_fields + } + + fn new() -> Counter { + Counter::new() + } + + fn clear(&mut self) { + self.value = 0.; + self.exemplar.clear(); + self.special_fields.clear(); + } + + fn default_instance() -> &'static Counter { + static instance: Counter = Counter { + value: 0., + exemplar: ::protobuf::MessageField::none(), + special_fields: ::protobuf::SpecialFields::new(), + }; + &instance + } +} + +impl ::protobuf::MessageFull for Counter { + fn descriptor() -> ::protobuf::reflect::MessageDescriptor { + static descriptor: ::protobuf::rt::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::rt::Lazy::new(); + descriptor.get(|| file_descriptor().message_by_package_relative_name("Counter").unwrap()).clone() + } +} + +impl ::std::fmt::Display for Counter { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for Counter { + type RuntimeType = ::protobuf::reflect::rt::RuntimeTypeMessage; +} + +#[derive(PartialEq,Clone,Default,Debug)] +// @@protoc_insertion_point(message:io.prometheus.client.Quantile) +pub struct Quantile { + // message fields + // @@protoc_insertion_point(field:io.prometheus.client.Quantile.quantile) + pub quantile: f64, + // @@protoc_insertion_point(field:io.prometheus.client.Quantile.value) + pub value: f64, + // special fields + // @@protoc_insertion_point(special_field:io.prometheus.client.Quantile.special_fields) + pub special_fields: ::protobuf::SpecialFields, +} + +impl<'a> ::std::default::Default for &'a Quantile { + fn default() -> &'a Quantile { + ::default_instance() + } +} + +impl Quantile { + pub fn new() -> Quantile { + ::std::default::Default::default() + } + + fn generated_message_descriptor_data() -> ::protobuf::reflect::GeneratedMessageDescriptorData { + let mut fields = ::std::vec::Vec::with_capacity(2); + let mut oneofs = ::std::vec::Vec::with_capacity(0); + fields.push(::protobuf::reflect::rt::v2::make_simpler_field_accessor::<_, _>( + "quantile", + |m: &Quantile| { &m.quantile }, + |m: &mut Quantile| { &mut m.quantile }, + )); + fields.push(::protobuf::reflect::rt::v2::make_simpler_field_accessor::<_, _>( + "value", + |m: &Quantile| { &m.value }, + |m: &mut Quantile| { &mut m.value }, + )); + ::protobuf::reflect::GeneratedMessageDescriptorData::new_2::( + "Quantile", + fields, + oneofs, + ) + } +} + +impl ::protobuf::Message for Quantile { + const NAME: &'static str = "Quantile"; + + fn is_initialized(&self) -> bool { + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::Result<()> { + while let Some(tag) = is.read_raw_tag_or_eof()? { + match tag { + 9 => { + self.quantile = is.read_double()?; + }, + 17 => { + self.value = is.read_double()?; + }, + tag => { + ::protobuf::rt::read_unknown_or_skip_group(tag, is, self.special_fields.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u64 { + let mut my_size = 0; + if self.quantile != 0. { + my_size += 1 + 8; + } + if self.value != 0. { + my_size += 1 + 8; + } + my_size += ::protobuf::rt::unknown_fields_size(self.special_fields.unknown_fields()); + self.special_fields.cached_size().set(my_size as u32); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::Result<()> { + if self.quantile != 0. { + os.write_double(1, self.quantile)?; + } + if self.value != 0. { + os.write_double(2, self.value)?; + } + os.write_unknown_fields(self.special_fields.unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn special_fields(&self) -> &::protobuf::SpecialFields { + &self.special_fields + } + + fn mut_special_fields(&mut self) -> &mut ::protobuf::SpecialFields { + &mut self.special_fields + } + + fn new() -> Quantile { + Quantile::new() + } + + fn clear(&mut self) { + self.quantile = 0.; + self.value = 0.; + self.special_fields.clear(); + } + + fn default_instance() -> &'static Quantile { + static instance: Quantile = Quantile { + quantile: 0., + value: 0., + special_fields: ::protobuf::SpecialFields::new(), + }; + &instance + } +} + +impl ::protobuf::MessageFull for Quantile { + fn descriptor() -> ::protobuf::reflect::MessageDescriptor { + static descriptor: ::protobuf::rt::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::rt::Lazy::new(); + descriptor.get(|| file_descriptor().message_by_package_relative_name("Quantile").unwrap()).clone() + } +} + +impl ::std::fmt::Display for Quantile { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for Quantile { + type RuntimeType = ::protobuf::reflect::rt::RuntimeTypeMessage; +} + +#[derive(PartialEq,Clone,Default,Debug)] +// @@protoc_insertion_point(message:io.prometheus.client.Summary) +pub struct Summary { + // message fields + // @@protoc_insertion_point(field:io.prometheus.client.Summary.sample_count) + pub sample_count: u64, + // @@protoc_insertion_point(field:io.prometheus.client.Summary.sample_sum) + pub sample_sum: f64, + // @@protoc_insertion_point(field:io.prometheus.client.Summary.quantile) + pub quantile: ::std::vec::Vec, + // special fields + // @@protoc_insertion_point(special_field:io.prometheus.client.Summary.special_fields) + pub special_fields: ::protobuf::SpecialFields, +} + +impl<'a> ::std::default::Default for &'a Summary { + fn default() -> &'a Summary { + ::default_instance() + } +} + +impl Summary { + pub fn new() -> Summary { + ::std::default::Default::default() + } + + fn generated_message_descriptor_data() -> ::protobuf::reflect::GeneratedMessageDescriptorData { + let mut fields = ::std::vec::Vec::with_capacity(3); + let mut oneofs = ::std::vec::Vec::with_capacity(0); + fields.push(::protobuf::reflect::rt::v2::make_simpler_field_accessor::<_, _>( + "sample_count", + |m: &Summary| { &m.sample_count }, + |m: &mut Summary| { &mut m.sample_count }, + )); + fields.push(::protobuf::reflect::rt::v2::make_simpler_field_accessor::<_, _>( + "sample_sum", + |m: &Summary| { &m.sample_sum }, + |m: &mut Summary| { &mut m.sample_sum }, + )); + fields.push(::protobuf::reflect::rt::v2::make_vec_simpler_accessor::<_, _>( + "quantile", + |m: &Summary| { &m.quantile }, + |m: &mut Summary| { &mut m.quantile }, + )); + ::protobuf::reflect::GeneratedMessageDescriptorData::new_2::( + "Summary", + fields, + oneofs, + ) + } +} + +impl ::protobuf::Message for Summary { + const NAME: &'static str = "Summary"; + + fn is_initialized(&self) -> bool { + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::Result<()> { + while let Some(tag) = is.read_raw_tag_or_eof()? { + match tag { + 8 => { + self.sample_count = is.read_uint64()?; + }, + 17 => { + self.sample_sum = is.read_double()?; + }, + 26 => { + self.quantile.push(is.read_message()?); + }, + tag => { + ::protobuf::rt::read_unknown_or_skip_group(tag, is, self.special_fields.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u64 { + let mut my_size = 0; + if self.sample_count != 0 { + my_size += ::protobuf::rt::uint64_size(1, self.sample_count); + } + if self.sample_sum != 0. { + my_size += 1 + 8; + } + for value in &self.quantile { + let len = value.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint64_size(len) + len; + }; + my_size += ::protobuf::rt::unknown_fields_size(self.special_fields.unknown_fields()); + self.special_fields.cached_size().set(my_size as u32); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::Result<()> { + if self.sample_count != 0 { + os.write_uint64(1, self.sample_count)?; + } + if self.sample_sum != 0. { + os.write_double(2, self.sample_sum)?; + } + for v in &self.quantile { + ::protobuf::rt::write_message_field_with_cached_size(3, v, os)?; + }; + os.write_unknown_fields(self.special_fields.unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn special_fields(&self) -> &::protobuf::SpecialFields { + &self.special_fields + } + + fn mut_special_fields(&mut self) -> &mut ::protobuf::SpecialFields { + &mut self.special_fields + } + + fn new() -> Summary { + Summary::new() + } + + fn clear(&mut self) { + self.sample_count = 0; + self.sample_sum = 0.; + self.quantile.clear(); + self.special_fields.clear(); + } + + fn default_instance() -> &'static Summary { + static instance: Summary = Summary { + sample_count: 0, + sample_sum: 0., + quantile: ::std::vec::Vec::new(), + special_fields: ::protobuf::SpecialFields::new(), + }; + &instance + } +} + +impl ::protobuf::MessageFull for Summary { + fn descriptor() -> ::protobuf::reflect::MessageDescriptor { + static descriptor: ::protobuf::rt::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::rt::Lazy::new(); + descriptor.get(|| file_descriptor().message_by_package_relative_name("Summary").unwrap()).clone() + } +} + +impl ::std::fmt::Display for Summary { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for Summary { + type RuntimeType = ::protobuf::reflect::rt::RuntimeTypeMessage; +} + +#[derive(PartialEq,Clone,Default,Debug)] +// @@protoc_insertion_point(message:io.prometheus.client.Untyped) +pub struct Untyped { + // message fields + // @@protoc_insertion_point(field:io.prometheus.client.Untyped.value) + pub value: f64, + // special fields + // @@protoc_insertion_point(special_field:io.prometheus.client.Untyped.special_fields) + pub special_fields: ::protobuf::SpecialFields, +} + +impl<'a> ::std::default::Default for &'a Untyped { + fn default() -> &'a Untyped { + ::default_instance() + } +} + +impl Untyped { + pub fn new() -> Untyped { + ::std::default::Default::default() + } + + fn generated_message_descriptor_data() -> ::protobuf::reflect::GeneratedMessageDescriptorData { + let mut fields = ::std::vec::Vec::with_capacity(1); + let mut oneofs = ::std::vec::Vec::with_capacity(0); + fields.push(::protobuf::reflect::rt::v2::make_simpler_field_accessor::<_, _>( + "value", + |m: &Untyped| { &m.value }, + |m: &mut Untyped| { &mut m.value }, + )); + ::protobuf::reflect::GeneratedMessageDescriptorData::new_2::( + "Untyped", + fields, + oneofs, + ) + } +} + +impl ::protobuf::Message for Untyped { + const NAME: &'static str = "Untyped"; + + fn is_initialized(&self) -> bool { + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::Result<()> { + while let Some(tag) = is.read_raw_tag_or_eof()? { + match tag { + 9 => { + self.value = is.read_double()?; + }, + tag => { + ::protobuf::rt::read_unknown_or_skip_group(tag, is, self.special_fields.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u64 { + let mut my_size = 0; + if self.value != 0. { + my_size += 1 + 8; + } + my_size += ::protobuf::rt::unknown_fields_size(self.special_fields.unknown_fields()); + self.special_fields.cached_size().set(my_size as u32); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::Result<()> { + if self.value != 0. { + os.write_double(1, self.value)?; + } + os.write_unknown_fields(self.special_fields.unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn special_fields(&self) -> &::protobuf::SpecialFields { + &self.special_fields + } + + fn mut_special_fields(&mut self) -> &mut ::protobuf::SpecialFields { + &mut self.special_fields + } + + fn new() -> Untyped { + Untyped::new() + } + + fn clear(&mut self) { + self.value = 0.; + self.special_fields.clear(); + } + + fn default_instance() -> &'static Untyped { + static instance: Untyped = Untyped { + value: 0., + special_fields: ::protobuf::SpecialFields::new(), + }; + &instance + } +} + +impl ::protobuf::MessageFull for Untyped { + fn descriptor() -> ::protobuf::reflect::MessageDescriptor { + static descriptor: ::protobuf::rt::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::rt::Lazy::new(); + descriptor.get(|| file_descriptor().message_by_package_relative_name("Untyped").unwrap()).clone() + } +} + +impl ::std::fmt::Display for Untyped { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for Untyped { + type RuntimeType = ::protobuf::reflect::rt::RuntimeTypeMessage; +} + +#[derive(PartialEq,Clone,Default,Debug)] +// @@protoc_insertion_point(message:io.prometheus.client.Histogram) +pub struct Histogram { + // message fields + // @@protoc_insertion_point(field:io.prometheus.client.Histogram.sample_count) + pub sample_count: u64, + // @@protoc_insertion_point(field:io.prometheus.client.Histogram.sample_count_float) + pub sample_count_float: f64, + // @@protoc_insertion_point(field:io.prometheus.client.Histogram.sample_sum) + pub sample_sum: f64, + // @@protoc_insertion_point(field:io.prometheus.client.Histogram.bucket) + pub bucket: ::std::vec::Vec, + // @@protoc_insertion_point(field:io.prometheus.client.Histogram.schema) + pub schema: i32, + // @@protoc_insertion_point(field:io.prometheus.client.Histogram.zero_threshold) + pub zero_threshold: f64, + // @@protoc_insertion_point(field:io.prometheus.client.Histogram.zero_count) + pub zero_count: u64, + // @@protoc_insertion_point(field:io.prometheus.client.Histogram.zero_count_float) + pub zero_count_float: f64, + // @@protoc_insertion_point(field:io.prometheus.client.Histogram.negative_span) + pub negative_span: ::std::vec::Vec, + // @@protoc_insertion_point(field:io.prometheus.client.Histogram.negative_delta) + pub negative_delta: ::std::vec::Vec, + // @@protoc_insertion_point(field:io.prometheus.client.Histogram.negative_count) + pub negative_count: ::std::vec::Vec, + // @@protoc_insertion_point(field:io.prometheus.client.Histogram.positive_span) + pub positive_span: ::std::vec::Vec, + // @@protoc_insertion_point(field:io.prometheus.client.Histogram.positive_delta) + pub positive_delta: ::std::vec::Vec, + // @@protoc_insertion_point(field:io.prometheus.client.Histogram.positive_count) + pub positive_count: ::std::vec::Vec, + // special fields + // @@protoc_insertion_point(special_field:io.prometheus.client.Histogram.special_fields) + pub special_fields: ::protobuf::SpecialFields, +} + +impl<'a> ::std::default::Default for &'a Histogram { + fn default() -> &'a Histogram { + ::default_instance() + } +} + +impl Histogram { + pub fn new() -> Histogram { + ::std::default::Default::default() + } + + fn generated_message_descriptor_data() -> ::protobuf::reflect::GeneratedMessageDescriptorData { + let mut fields = ::std::vec::Vec::with_capacity(14); + let mut oneofs = ::std::vec::Vec::with_capacity(0); + fields.push(::protobuf::reflect::rt::v2::make_simpler_field_accessor::<_, _>( + "sample_count", + |m: &Histogram| { &m.sample_count }, + |m: &mut Histogram| { &mut m.sample_count }, + )); + fields.push(::protobuf::reflect::rt::v2::make_simpler_field_accessor::<_, _>( + "sample_count_float", + |m: &Histogram| { &m.sample_count_float }, + |m: &mut Histogram| { &mut m.sample_count_float }, + )); + fields.push(::protobuf::reflect::rt::v2::make_simpler_field_accessor::<_, _>( + "sample_sum", + |m: &Histogram| { &m.sample_sum }, + |m: &mut Histogram| { &mut m.sample_sum }, + )); + fields.push(::protobuf::reflect::rt::v2::make_vec_simpler_accessor::<_, _>( + "bucket", + |m: &Histogram| { &m.bucket }, + |m: &mut Histogram| { &mut m.bucket }, + )); + fields.push(::protobuf::reflect::rt::v2::make_simpler_field_accessor::<_, _>( + "schema", + |m: &Histogram| { &m.schema }, + |m: &mut Histogram| { &mut m.schema }, + )); + fields.push(::protobuf::reflect::rt::v2::make_simpler_field_accessor::<_, _>( + "zero_threshold", + |m: &Histogram| { &m.zero_threshold }, + |m: &mut Histogram| { &mut m.zero_threshold }, + )); + fields.push(::protobuf::reflect::rt::v2::make_simpler_field_accessor::<_, _>( + "zero_count", + |m: &Histogram| { &m.zero_count }, + |m: &mut Histogram| { &mut m.zero_count }, + )); + fields.push(::protobuf::reflect::rt::v2::make_simpler_field_accessor::<_, _>( + "zero_count_float", + |m: &Histogram| { &m.zero_count_float }, + |m: &mut Histogram| { &mut m.zero_count_float }, + )); + fields.push(::protobuf::reflect::rt::v2::make_vec_simpler_accessor::<_, _>( + "negative_span", + |m: &Histogram| { &m.negative_span }, + |m: &mut Histogram| { &mut m.negative_span }, + )); + fields.push(::protobuf::reflect::rt::v2::make_vec_simpler_accessor::<_, _>( + "negative_delta", + |m: &Histogram| { &m.negative_delta }, + |m: &mut Histogram| { &mut m.negative_delta }, + )); + fields.push(::protobuf::reflect::rt::v2::make_vec_simpler_accessor::<_, _>( + "negative_count", + |m: &Histogram| { &m.negative_count }, + |m: &mut Histogram| { &mut m.negative_count }, + )); + fields.push(::protobuf::reflect::rt::v2::make_vec_simpler_accessor::<_, _>( + "positive_span", + |m: &Histogram| { &m.positive_span }, + |m: &mut Histogram| { &mut m.positive_span }, + )); + fields.push(::protobuf::reflect::rt::v2::make_vec_simpler_accessor::<_, _>( + "positive_delta", + |m: &Histogram| { &m.positive_delta }, + |m: &mut Histogram| { &mut m.positive_delta }, + )); + fields.push(::protobuf::reflect::rt::v2::make_vec_simpler_accessor::<_, _>( + "positive_count", + |m: &Histogram| { &m.positive_count }, + |m: &mut Histogram| { &mut m.positive_count }, + )); + ::protobuf::reflect::GeneratedMessageDescriptorData::new_2::( + "Histogram", + fields, + oneofs, + ) + } +} + +impl ::protobuf::Message for Histogram { + const NAME: &'static str = "Histogram"; + + fn is_initialized(&self) -> bool { + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::Result<()> { + while let Some(tag) = is.read_raw_tag_or_eof()? { + match tag { + 8 => { + self.sample_count = is.read_uint64()?; + }, + 33 => { + self.sample_count_float = is.read_double()?; + }, + 17 => { + self.sample_sum = is.read_double()?; + }, + 26 => { + self.bucket.push(is.read_message()?); + }, + 40 => { + self.schema = is.read_sint32()?; + }, + 49 => { + self.zero_threshold = is.read_double()?; + }, + 56 => { + self.zero_count = is.read_uint64()?; + }, + 65 => { + self.zero_count_float = is.read_double()?; + }, + 74 => { + self.negative_span.push(is.read_message()?); + }, + 82 => { + is.read_repeated_packed_sint64_into(&mut self.negative_delta)?; + }, + 80 => { + self.negative_delta.push(is.read_sint64()?); + }, + 90 => { + is.read_repeated_packed_double_into(&mut self.negative_count)?; + }, + 89 => { + self.negative_count.push(is.read_double()?); + }, + 98 => { + self.positive_span.push(is.read_message()?); + }, + 106 => { + is.read_repeated_packed_sint64_into(&mut self.positive_delta)?; + }, + 104 => { + self.positive_delta.push(is.read_sint64()?); + }, + 114 => { + is.read_repeated_packed_double_into(&mut self.positive_count)?; + }, + 113 => { + self.positive_count.push(is.read_double()?); + }, + tag => { + ::protobuf::rt::read_unknown_or_skip_group(tag, is, self.special_fields.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u64 { + let mut my_size = 0; + if self.sample_count != 0 { + my_size += ::protobuf::rt::uint64_size(1, self.sample_count); + } + if self.sample_count_float != 0. { + my_size += 1 + 8; + } + if self.sample_sum != 0. { + my_size += 1 + 8; + } + for value in &self.bucket { + let len = value.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint64_size(len) + len; + }; + if self.schema != 0 { + my_size += ::protobuf::rt::sint32_size(5, self.schema); + } + if self.zero_threshold != 0. { + my_size += 1 + 8; + } + if self.zero_count != 0 { + my_size += ::protobuf::rt::uint64_size(7, self.zero_count); + } + if self.zero_count_float != 0. { + my_size += 1 + 8; + } + for value in &self.negative_span { + let len = value.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint64_size(len) + len; + }; + for value in &self.negative_delta { + my_size += ::protobuf::rt::sint64_size(10, *value); + }; + my_size += 9 * self.negative_count.len() as u64; + for value in &self.positive_span { + let len = value.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint64_size(len) + len; + }; + for value in &self.positive_delta { + my_size += ::protobuf::rt::sint64_size(13, *value); + }; + my_size += 9 * self.positive_count.len() as u64; + my_size += ::protobuf::rt::unknown_fields_size(self.special_fields.unknown_fields()); + self.special_fields.cached_size().set(my_size as u32); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::Result<()> { + if self.sample_count != 0 { + os.write_uint64(1, self.sample_count)?; + } + if self.sample_count_float != 0. { + os.write_double(4, self.sample_count_float)?; + } + if self.sample_sum != 0. { + os.write_double(2, self.sample_sum)?; + } + for v in &self.bucket { + ::protobuf::rt::write_message_field_with_cached_size(3, v, os)?; + }; + if self.schema != 0 { + os.write_sint32(5, self.schema)?; + } + if self.zero_threshold != 0. { + os.write_double(6, self.zero_threshold)?; + } + if self.zero_count != 0 { + os.write_uint64(7, self.zero_count)?; + } + if self.zero_count_float != 0. { + os.write_double(8, self.zero_count_float)?; + } + for v in &self.negative_span { + ::protobuf::rt::write_message_field_with_cached_size(9, v, os)?; + }; + for v in &self.negative_delta { + os.write_sint64(10, *v)?; + }; + for v in &self.negative_count { + os.write_double(11, *v)?; + }; + for v in &self.positive_span { + ::protobuf::rt::write_message_field_with_cached_size(12, v, os)?; + }; + for v in &self.positive_delta { + os.write_sint64(13, *v)?; + }; + for v in &self.positive_count { + os.write_double(14, *v)?; + }; + os.write_unknown_fields(self.special_fields.unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn special_fields(&self) -> &::protobuf::SpecialFields { + &self.special_fields + } + + fn mut_special_fields(&mut self) -> &mut ::protobuf::SpecialFields { + &mut self.special_fields + } + + fn new() -> Histogram { + Histogram::new() + } + + fn clear(&mut self) { + self.sample_count = 0; + self.sample_count_float = 0.; + self.sample_sum = 0.; + self.bucket.clear(); + self.schema = 0; + self.zero_threshold = 0.; + self.zero_count = 0; + self.zero_count_float = 0.; + self.negative_span.clear(); + self.negative_delta.clear(); + self.negative_count.clear(); + self.positive_span.clear(); + self.positive_delta.clear(); + self.positive_count.clear(); + self.special_fields.clear(); + } + + fn default_instance() -> &'static Histogram { + static instance: Histogram = Histogram { + sample_count: 0, + sample_count_float: 0., + sample_sum: 0., + bucket: ::std::vec::Vec::new(), + schema: 0, + zero_threshold: 0., + zero_count: 0, + zero_count_float: 0., + negative_span: ::std::vec::Vec::new(), + negative_delta: ::std::vec::Vec::new(), + negative_count: ::std::vec::Vec::new(), + positive_span: ::std::vec::Vec::new(), + positive_delta: ::std::vec::Vec::new(), + positive_count: ::std::vec::Vec::new(), + special_fields: ::protobuf::SpecialFields::new(), + }; + &instance + } +} + +impl ::protobuf::MessageFull for Histogram { + fn descriptor() -> ::protobuf::reflect::MessageDescriptor { + static descriptor: ::protobuf::rt::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::rt::Lazy::new(); + descriptor.get(|| file_descriptor().message_by_package_relative_name("Histogram").unwrap()).clone() + } +} + +impl ::std::fmt::Display for Histogram { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for Histogram { + type RuntimeType = ::protobuf::reflect::rt::RuntimeTypeMessage; +} + +#[derive(PartialEq,Clone,Default,Debug)] +// @@protoc_insertion_point(message:io.prometheus.client.Bucket) +pub struct Bucket { + // message fields + // @@protoc_insertion_point(field:io.prometheus.client.Bucket.cumulative_count) + pub cumulative_count: u64, + // @@protoc_insertion_point(field:io.prometheus.client.Bucket.cumulative_count_float) + pub cumulative_count_float: f64, + // @@protoc_insertion_point(field:io.prometheus.client.Bucket.upper_bound) + pub upper_bound: f64, + // @@protoc_insertion_point(field:io.prometheus.client.Bucket.exemplar) + pub exemplar: ::protobuf::MessageField, + // special fields + // @@protoc_insertion_point(special_field:io.prometheus.client.Bucket.special_fields) + pub special_fields: ::protobuf::SpecialFields, +} + +impl<'a> ::std::default::Default for &'a Bucket { + fn default() -> &'a Bucket { + ::default_instance() + } +} + +impl Bucket { + pub fn new() -> Bucket { + ::std::default::Default::default() + } + + fn generated_message_descriptor_data() -> ::protobuf::reflect::GeneratedMessageDescriptorData { + let mut fields = ::std::vec::Vec::with_capacity(4); + let mut oneofs = ::std::vec::Vec::with_capacity(0); + fields.push(::protobuf::reflect::rt::v2::make_simpler_field_accessor::<_, _>( + "cumulative_count", + |m: &Bucket| { &m.cumulative_count }, + |m: &mut Bucket| { &mut m.cumulative_count }, + )); + fields.push(::protobuf::reflect::rt::v2::make_simpler_field_accessor::<_, _>( + "cumulative_count_float", + |m: &Bucket| { &m.cumulative_count_float }, + |m: &mut Bucket| { &mut m.cumulative_count_float }, + )); + fields.push(::protobuf::reflect::rt::v2::make_simpler_field_accessor::<_, _>( + "upper_bound", + |m: &Bucket| { &m.upper_bound }, + |m: &mut Bucket| { &mut m.upper_bound }, + )); + fields.push(::protobuf::reflect::rt::v2::make_message_field_accessor::<_, Exemplar>( + "exemplar", + |m: &Bucket| { &m.exemplar }, + |m: &mut Bucket| { &mut m.exemplar }, + )); + ::protobuf::reflect::GeneratedMessageDescriptorData::new_2::( + "Bucket", + fields, + oneofs, + ) + } +} + +impl ::protobuf::Message for Bucket { + const NAME: &'static str = "Bucket"; + + fn is_initialized(&self) -> bool { + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::Result<()> { + while let Some(tag) = is.read_raw_tag_or_eof()? { + match tag { + 8 => { + self.cumulative_count = is.read_uint64()?; + }, + 33 => { + self.cumulative_count_float = is.read_double()?; + }, + 17 => { + self.upper_bound = is.read_double()?; + }, + 26 => { + ::protobuf::rt::read_singular_message_into_field(is, &mut self.exemplar)?; + }, + tag => { + ::protobuf::rt::read_unknown_or_skip_group(tag, is, self.special_fields.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u64 { + let mut my_size = 0; + if self.cumulative_count != 0 { + my_size += ::protobuf::rt::uint64_size(1, self.cumulative_count); + } + if self.cumulative_count_float != 0. { + my_size += 1 + 8; + } + if self.upper_bound != 0. { + my_size += 1 + 8; + } + if let Some(v) = self.exemplar.as_ref() { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint64_size(len) + len; + } + my_size += ::protobuf::rt::unknown_fields_size(self.special_fields.unknown_fields()); + self.special_fields.cached_size().set(my_size as u32); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::Result<()> { + if self.cumulative_count != 0 { + os.write_uint64(1, self.cumulative_count)?; + } + if self.cumulative_count_float != 0. { + os.write_double(4, self.cumulative_count_float)?; + } + if self.upper_bound != 0. { + os.write_double(2, self.upper_bound)?; + } + if let Some(v) = self.exemplar.as_ref() { + ::protobuf::rt::write_message_field_with_cached_size(3, v, os)?; + } + os.write_unknown_fields(self.special_fields.unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn special_fields(&self) -> &::protobuf::SpecialFields { + &self.special_fields + } + + fn mut_special_fields(&mut self) -> &mut ::protobuf::SpecialFields { + &mut self.special_fields + } + + fn new() -> Bucket { + Bucket::new() + } + + fn clear(&mut self) { + self.cumulative_count = 0; + self.cumulative_count_float = 0.; + self.upper_bound = 0.; + self.exemplar.clear(); + self.special_fields.clear(); + } + + fn default_instance() -> &'static Bucket { + static instance: Bucket = Bucket { + cumulative_count: 0, + cumulative_count_float: 0., + upper_bound: 0., + exemplar: ::protobuf::MessageField::none(), + special_fields: ::protobuf::SpecialFields::new(), + }; + &instance + } +} + +impl ::protobuf::MessageFull for Bucket { + fn descriptor() -> ::protobuf::reflect::MessageDescriptor { + static descriptor: ::protobuf::rt::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::rt::Lazy::new(); + descriptor.get(|| file_descriptor().message_by_package_relative_name("Bucket").unwrap()).clone() + } +} + +impl ::std::fmt::Display for Bucket { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for Bucket { + type RuntimeType = ::protobuf::reflect::rt::RuntimeTypeMessage; +} + +#[derive(PartialEq,Clone,Default,Debug)] +// @@protoc_insertion_point(message:io.prometheus.client.BucketSpan) +pub struct BucketSpan { + // message fields + // @@protoc_insertion_point(field:io.prometheus.client.BucketSpan.offset) + pub offset: i32, + // @@protoc_insertion_point(field:io.prometheus.client.BucketSpan.length) + pub length: u32, + // special fields + // @@protoc_insertion_point(special_field:io.prometheus.client.BucketSpan.special_fields) + pub special_fields: ::protobuf::SpecialFields, +} + +impl<'a> ::std::default::Default for &'a BucketSpan { + fn default() -> &'a BucketSpan { + ::default_instance() + } +} + +impl BucketSpan { + pub fn new() -> BucketSpan { + ::std::default::Default::default() + } + + fn generated_message_descriptor_data() -> ::protobuf::reflect::GeneratedMessageDescriptorData { + let mut fields = ::std::vec::Vec::with_capacity(2); + let mut oneofs = ::std::vec::Vec::with_capacity(0); + fields.push(::protobuf::reflect::rt::v2::make_simpler_field_accessor::<_, _>( + "offset", + |m: &BucketSpan| { &m.offset }, + |m: &mut BucketSpan| { &mut m.offset }, + )); + fields.push(::protobuf::reflect::rt::v2::make_simpler_field_accessor::<_, _>( + "length", + |m: &BucketSpan| { &m.length }, + |m: &mut BucketSpan| { &mut m.length }, + )); + ::protobuf::reflect::GeneratedMessageDescriptorData::new_2::( + "BucketSpan", + fields, + oneofs, + ) + } +} + +impl ::protobuf::Message for BucketSpan { + const NAME: &'static str = "BucketSpan"; + + fn is_initialized(&self) -> bool { + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::Result<()> { + while let Some(tag) = is.read_raw_tag_or_eof()? { + match tag { + 8 => { + self.offset = is.read_sint32()?; + }, + 16 => { + self.length = is.read_uint32()?; + }, + tag => { + ::protobuf::rt::read_unknown_or_skip_group(tag, is, self.special_fields.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u64 { + let mut my_size = 0; + if self.offset != 0 { + my_size += ::protobuf::rt::sint32_size(1, self.offset); + } + if self.length != 0 { + my_size += ::protobuf::rt::uint32_size(2, self.length); + } + my_size += ::protobuf::rt::unknown_fields_size(self.special_fields.unknown_fields()); + self.special_fields.cached_size().set(my_size as u32); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::Result<()> { + if self.offset != 0 { + os.write_sint32(1, self.offset)?; + } + if self.length != 0 { + os.write_uint32(2, self.length)?; + } + os.write_unknown_fields(self.special_fields.unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn special_fields(&self) -> &::protobuf::SpecialFields { + &self.special_fields + } + + fn mut_special_fields(&mut self) -> &mut ::protobuf::SpecialFields { + &mut self.special_fields + } + + fn new() -> BucketSpan { + BucketSpan::new() + } + + fn clear(&mut self) { + self.offset = 0; + self.length = 0; + self.special_fields.clear(); + } + + fn default_instance() -> &'static BucketSpan { + static instance: BucketSpan = BucketSpan { + offset: 0, + length: 0, + special_fields: ::protobuf::SpecialFields::new(), + }; + &instance + } +} + +impl ::protobuf::MessageFull for BucketSpan { + fn descriptor() -> ::protobuf::reflect::MessageDescriptor { + static descriptor: ::protobuf::rt::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::rt::Lazy::new(); + descriptor.get(|| file_descriptor().message_by_package_relative_name("BucketSpan").unwrap()).clone() + } +} + +impl ::std::fmt::Display for BucketSpan { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for BucketSpan { + type RuntimeType = ::protobuf::reflect::rt::RuntimeTypeMessage; +} + +#[derive(PartialEq,Clone,Default,Debug)] +// @@protoc_insertion_point(message:io.prometheus.client.Exemplar) +pub struct Exemplar { + // message fields + // @@protoc_insertion_point(field:io.prometheus.client.Exemplar.label) + pub label: ::std::vec::Vec, + // @@protoc_insertion_point(field:io.prometheus.client.Exemplar.value) + pub value: f64, + // @@protoc_insertion_point(field:io.prometheus.client.Exemplar.timestamp) + pub timestamp: ::protobuf::MessageField<::protobuf::well_known_types::timestamp::Timestamp>, + // special fields + // @@protoc_insertion_point(special_field:io.prometheus.client.Exemplar.special_fields) + pub special_fields: ::protobuf::SpecialFields, +} + +impl<'a> ::std::default::Default for &'a Exemplar { + fn default() -> &'a Exemplar { + ::default_instance() + } +} + +impl Exemplar { + pub fn new() -> Exemplar { + ::std::default::Default::default() + } + + fn generated_message_descriptor_data() -> ::protobuf::reflect::GeneratedMessageDescriptorData { + let mut fields = ::std::vec::Vec::with_capacity(3); + let mut oneofs = ::std::vec::Vec::with_capacity(0); + fields.push(::protobuf::reflect::rt::v2::make_vec_simpler_accessor::<_, _>( + "label", + |m: &Exemplar| { &m.label }, + |m: &mut Exemplar| { &mut m.label }, + )); + fields.push(::protobuf::reflect::rt::v2::make_simpler_field_accessor::<_, _>( + "value", + |m: &Exemplar| { &m.value }, + |m: &mut Exemplar| { &mut m.value }, + )); + fields.push(::protobuf::reflect::rt::v2::make_message_field_accessor::<_, ::protobuf::well_known_types::timestamp::Timestamp>( + "timestamp", + |m: &Exemplar| { &m.timestamp }, + |m: &mut Exemplar| { &mut m.timestamp }, + )); + ::protobuf::reflect::GeneratedMessageDescriptorData::new_2::( + "Exemplar", + fields, + oneofs, + ) + } +} + +impl ::protobuf::Message for Exemplar { + const NAME: &'static str = "Exemplar"; + + fn is_initialized(&self) -> bool { + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::Result<()> { + while let Some(tag) = is.read_raw_tag_or_eof()? { + match tag { + 10 => { + self.label.push(is.read_message()?); + }, + 17 => { + self.value = is.read_double()?; + }, + 26 => { + ::protobuf::rt::read_singular_message_into_field(is, &mut self.timestamp)?; + }, + tag => { + ::protobuf::rt::read_unknown_or_skip_group(tag, is, self.special_fields.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u64 { + let mut my_size = 0; + for value in &self.label { + let len = value.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint64_size(len) + len; + }; + if self.value != 0. { + my_size += 1 + 8; + } + if let Some(v) = self.timestamp.as_ref() { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint64_size(len) + len; + } + my_size += ::protobuf::rt::unknown_fields_size(self.special_fields.unknown_fields()); + self.special_fields.cached_size().set(my_size as u32); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::Result<()> { + for v in &self.label { + ::protobuf::rt::write_message_field_with_cached_size(1, v, os)?; + }; + if self.value != 0. { + os.write_double(2, self.value)?; + } + if let Some(v) = self.timestamp.as_ref() { + ::protobuf::rt::write_message_field_with_cached_size(3, v, os)?; + } + os.write_unknown_fields(self.special_fields.unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn special_fields(&self) -> &::protobuf::SpecialFields { + &self.special_fields + } + + fn mut_special_fields(&mut self) -> &mut ::protobuf::SpecialFields { + &mut self.special_fields + } + + fn new() -> Exemplar { + Exemplar::new() + } + + fn clear(&mut self) { + self.label.clear(); + self.value = 0.; + self.timestamp.clear(); + self.special_fields.clear(); + } + + fn default_instance() -> &'static Exemplar { + static instance: Exemplar = Exemplar { + label: ::std::vec::Vec::new(), + value: 0., + timestamp: ::protobuf::MessageField::none(), + special_fields: ::protobuf::SpecialFields::new(), + }; + &instance + } +} + +impl ::protobuf::MessageFull for Exemplar { + fn descriptor() -> ::protobuf::reflect::MessageDescriptor { + static descriptor: ::protobuf::rt::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::rt::Lazy::new(); + descriptor.get(|| file_descriptor().message_by_package_relative_name("Exemplar").unwrap()).clone() + } +} + +impl ::std::fmt::Display for Exemplar { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for Exemplar { + type RuntimeType = ::protobuf::reflect::rt::RuntimeTypeMessage; +} + +#[derive(PartialEq,Clone,Default,Debug)] +// @@protoc_insertion_point(message:io.prometheus.client.Metric) +pub struct Metric { + // message fields + // @@protoc_insertion_point(field:io.prometheus.client.Metric.label) + pub label: ::std::vec::Vec, + // @@protoc_insertion_point(field:io.prometheus.client.Metric.gauge) + pub gauge: ::protobuf::MessageField, + // @@protoc_insertion_point(field:io.prometheus.client.Metric.counter) + pub counter: ::protobuf::MessageField, + // @@protoc_insertion_point(field:io.prometheus.client.Metric.summary) + pub summary: ::protobuf::MessageField, + // @@protoc_insertion_point(field:io.prometheus.client.Metric.untyped) + pub untyped: ::protobuf::MessageField, + // @@protoc_insertion_point(field:io.prometheus.client.Metric.histogram) + pub histogram: ::protobuf::MessageField, + // @@protoc_insertion_point(field:io.prometheus.client.Metric.timestamp_ms) + pub timestamp_ms: i64, + // special fields + // @@protoc_insertion_point(special_field:io.prometheus.client.Metric.special_fields) + pub special_fields: ::protobuf::SpecialFields, +} + +impl<'a> ::std::default::Default for &'a Metric { + fn default() -> &'a Metric { + ::default_instance() + } +} + +impl Metric { + pub fn new() -> Metric { + ::std::default::Default::default() + } + + fn generated_message_descriptor_data() -> ::protobuf::reflect::GeneratedMessageDescriptorData { + let mut fields = ::std::vec::Vec::with_capacity(7); + let mut oneofs = ::std::vec::Vec::with_capacity(0); + fields.push(::protobuf::reflect::rt::v2::make_vec_simpler_accessor::<_, _>( + "label", + |m: &Metric| { &m.label }, + |m: &mut Metric| { &mut m.label }, + )); + fields.push(::protobuf::reflect::rt::v2::make_message_field_accessor::<_, Gauge>( + "gauge", + |m: &Metric| { &m.gauge }, + |m: &mut Metric| { &mut m.gauge }, + )); + fields.push(::protobuf::reflect::rt::v2::make_message_field_accessor::<_, Counter>( + "counter", + |m: &Metric| { &m.counter }, + |m: &mut Metric| { &mut m.counter }, + )); + fields.push(::protobuf::reflect::rt::v2::make_message_field_accessor::<_, Summary>( + "summary", + |m: &Metric| { &m.summary }, + |m: &mut Metric| { &mut m.summary }, + )); + fields.push(::protobuf::reflect::rt::v2::make_message_field_accessor::<_, Untyped>( + "untyped", + |m: &Metric| { &m.untyped }, + |m: &mut Metric| { &mut m.untyped }, + )); + fields.push(::protobuf::reflect::rt::v2::make_message_field_accessor::<_, Histogram>( + "histogram", + |m: &Metric| { &m.histogram }, + |m: &mut Metric| { &mut m.histogram }, + )); + fields.push(::protobuf::reflect::rt::v2::make_simpler_field_accessor::<_, _>( + "timestamp_ms", + |m: &Metric| { &m.timestamp_ms }, + |m: &mut Metric| { &mut m.timestamp_ms }, + )); + ::protobuf::reflect::GeneratedMessageDescriptorData::new_2::( + "Metric", + fields, + oneofs, + ) + } +} + +impl ::protobuf::Message for Metric { + const NAME: &'static str = "Metric"; + + fn is_initialized(&self) -> bool { + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::Result<()> { + while let Some(tag) = is.read_raw_tag_or_eof()? { + match tag { + 10 => { + self.label.push(is.read_message()?); + }, + 18 => { + ::protobuf::rt::read_singular_message_into_field(is, &mut self.gauge)?; + }, + 26 => { + ::protobuf::rt::read_singular_message_into_field(is, &mut self.counter)?; + }, + 34 => { + ::protobuf::rt::read_singular_message_into_field(is, &mut self.summary)?; + }, + 42 => { + ::protobuf::rt::read_singular_message_into_field(is, &mut self.untyped)?; + }, + 58 => { + ::protobuf::rt::read_singular_message_into_field(is, &mut self.histogram)?; + }, + 48 => { + self.timestamp_ms = is.read_int64()?; + }, + tag => { + ::protobuf::rt::read_unknown_or_skip_group(tag, is, self.special_fields.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u64 { + let mut my_size = 0; + for value in &self.label { + let len = value.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint64_size(len) + len; + }; + if let Some(v) = self.gauge.as_ref() { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint64_size(len) + len; + } + if let Some(v) = self.counter.as_ref() { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint64_size(len) + len; + } + if let Some(v) = self.summary.as_ref() { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint64_size(len) + len; + } + if let Some(v) = self.untyped.as_ref() { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint64_size(len) + len; + } + if let Some(v) = self.histogram.as_ref() { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint64_size(len) + len; + } + if self.timestamp_ms != 0 { + my_size += ::protobuf::rt::int64_size(6, self.timestamp_ms); + } + my_size += ::protobuf::rt::unknown_fields_size(self.special_fields.unknown_fields()); + self.special_fields.cached_size().set(my_size as u32); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::Result<()> { + for v in &self.label { + ::protobuf::rt::write_message_field_with_cached_size(1, v, os)?; + }; + if let Some(v) = self.gauge.as_ref() { + ::protobuf::rt::write_message_field_with_cached_size(2, v, os)?; + } + if let Some(v) = self.counter.as_ref() { + ::protobuf::rt::write_message_field_with_cached_size(3, v, os)?; + } + if let Some(v) = self.summary.as_ref() { + ::protobuf::rt::write_message_field_with_cached_size(4, v, os)?; + } + if let Some(v) = self.untyped.as_ref() { + ::protobuf::rt::write_message_field_with_cached_size(5, v, os)?; + } + if let Some(v) = self.histogram.as_ref() { + ::protobuf::rt::write_message_field_with_cached_size(7, v, os)?; + } + if self.timestamp_ms != 0 { + os.write_int64(6, self.timestamp_ms)?; + } + os.write_unknown_fields(self.special_fields.unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn special_fields(&self) -> &::protobuf::SpecialFields { + &self.special_fields + } + + fn mut_special_fields(&mut self) -> &mut ::protobuf::SpecialFields { + &mut self.special_fields + } + + fn new() -> Metric { + Metric::new() + } + + fn clear(&mut self) { + self.label.clear(); + self.gauge.clear(); + self.counter.clear(); + self.summary.clear(); + self.untyped.clear(); + self.histogram.clear(); + self.timestamp_ms = 0; + self.special_fields.clear(); + } + + fn default_instance() -> &'static Metric { + static instance: Metric = Metric { + label: ::std::vec::Vec::new(), + gauge: ::protobuf::MessageField::none(), + counter: ::protobuf::MessageField::none(), + summary: ::protobuf::MessageField::none(), + untyped: ::protobuf::MessageField::none(), + histogram: ::protobuf::MessageField::none(), + timestamp_ms: 0, + special_fields: ::protobuf::SpecialFields::new(), + }; + &instance + } +} + +impl ::protobuf::MessageFull for Metric { + fn descriptor() -> ::protobuf::reflect::MessageDescriptor { + static descriptor: ::protobuf::rt::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::rt::Lazy::new(); + descriptor.get(|| file_descriptor().message_by_package_relative_name("Metric").unwrap()).clone() + } +} + +impl ::std::fmt::Display for Metric { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for Metric { + type RuntimeType = ::protobuf::reflect::rt::RuntimeTypeMessage; +} + +#[derive(PartialEq,Clone,Default,Debug)] +// @@protoc_insertion_point(message:io.prometheus.client.MetricFamily) +pub struct MetricFamily { + // message fields + // @@protoc_insertion_point(field:io.prometheus.client.MetricFamily.name) + pub name: ::std::string::String, + // @@protoc_insertion_point(field:io.prometheus.client.MetricFamily.help) + pub help: ::std::string::String, + // @@protoc_insertion_point(field:io.prometheus.client.MetricFamily.type) + pub type_: ::protobuf::EnumOrUnknown, + // @@protoc_insertion_point(field:io.prometheus.client.MetricFamily.metric) + pub metric: ::std::vec::Vec, + // special fields + // @@protoc_insertion_point(special_field:io.prometheus.client.MetricFamily.special_fields) + pub special_fields: ::protobuf::SpecialFields, +} + +impl<'a> ::std::default::Default for &'a MetricFamily { + fn default() -> &'a MetricFamily { + ::default_instance() + } +} + +impl MetricFamily { + pub fn new() -> MetricFamily { + ::std::default::Default::default() + } + + fn generated_message_descriptor_data() -> ::protobuf::reflect::GeneratedMessageDescriptorData { + let mut fields = ::std::vec::Vec::with_capacity(4); + let mut oneofs = ::std::vec::Vec::with_capacity(0); + fields.push(::protobuf::reflect::rt::v2::make_simpler_field_accessor::<_, _>( + "name", + |m: &MetricFamily| { &m.name }, + |m: &mut MetricFamily| { &mut m.name }, + )); + fields.push(::protobuf::reflect::rt::v2::make_simpler_field_accessor::<_, _>( + "help", + |m: &MetricFamily| { &m.help }, + |m: &mut MetricFamily| { &mut m.help }, + )); + fields.push(::protobuf::reflect::rt::v2::make_simpler_field_accessor::<_, _>( + "type", + |m: &MetricFamily| { &m.type_ }, + |m: &mut MetricFamily| { &mut m.type_ }, + )); + fields.push(::protobuf::reflect::rt::v2::make_vec_simpler_accessor::<_, _>( + "metric", + |m: &MetricFamily| { &m.metric }, + |m: &mut MetricFamily| { &mut m.metric }, + )); + ::protobuf::reflect::GeneratedMessageDescriptorData::new_2::( + "MetricFamily", + fields, + oneofs, + ) + } +} + +impl ::protobuf::Message for MetricFamily { + const NAME: &'static str = "MetricFamily"; + + fn is_initialized(&self) -> bool { + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::Result<()> { + while let Some(tag) = is.read_raw_tag_or_eof()? { + match tag { + 10 => { + self.name = is.read_string()?; + }, + 18 => { + self.help = is.read_string()?; + }, + 24 => { + self.type_ = is.read_enum_or_unknown()?; + }, + 34 => { + self.metric.push(is.read_message()?); + }, + tag => { + ::protobuf::rt::read_unknown_or_skip_group(tag, is, self.special_fields.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u64 { + let mut my_size = 0; + if !self.name.is_empty() { + my_size += ::protobuf::rt::string_size(1, &self.name); + } + if !self.help.is_empty() { + my_size += ::protobuf::rt::string_size(2, &self.help); + } + if self.type_ != ::protobuf::EnumOrUnknown::new(MetricType::COUNTER) { + my_size += ::protobuf::rt::int32_size(3, self.type_.value()); + } + for value in &self.metric { + let len = value.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint64_size(len) + len; + }; + my_size += ::protobuf::rt::unknown_fields_size(self.special_fields.unknown_fields()); + self.special_fields.cached_size().set(my_size as u32); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::Result<()> { + if !self.name.is_empty() { + os.write_string(1, &self.name)?; + } + if !self.help.is_empty() { + os.write_string(2, &self.help)?; + } + if self.type_ != ::protobuf::EnumOrUnknown::new(MetricType::COUNTER) { + os.write_enum(3, ::protobuf::EnumOrUnknown::value(&self.type_))?; + } + for v in &self.metric { + ::protobuf::rt::write_message_field_with_cached_size(4, v, os)?; + }; + os.write_unknown_fields(self.special_fields.unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn special_fields(&self) -> &::protobuf::SpecialFields { + &self.special_fields + } + + fn mut_special_fields(&mut self) -> &mut ::protobuf::SpecialFields { + &mut self.special_fields + } + + fn new() -> MetricFamily { + MetricFamily::new() + } + + fn clear(&mut self) { + self.name.clear(); + self.help.clear(); + self.type_ = ::protobuf::EnumOrUnknown::new(MetricType::COUNTER); + self.metric.clear(); + self.special_fields.clear(); + } + + fn default_instance() -> &'static MetricFamily { + static instance: MetricFamily = MetricFamily { + name: ::std::string::String::new(), + help: ::std::string::String::new(), + type_: ::protobuf::EnumOrUnknown::from_i32(0), + metric: ::std::vec::Vec::new(), + special_fields: ::protobuf::SpecialFields::new(), + }; + &instance + } +} + +impl ::protobuf::MessageFull for MetricFamily { + fn descriptor() -> ::protobuf::reflect::MessageDescriptor { + static descriptor: ::protobuf::rt::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::rt::Lazy::new(); + descriptor.get(|| file_descriptor().message_by_package_relative_name("MetricFamily").unwrap()).clone() + } +} + +impl ::std::fmt::Display for MetricFamily { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for MetricFamily { + type RuntimeType = ::protobuf::reflect::rt::RuntimeTypeMessage; +} + +#[derive(Clone,Copy,PartialEq,Eq,Debug,Hash)] +// @@protoc_insertion_point(enum:io.prometheus.client.MetricType) +pub enum MetricType { + // @@protoc_insertion_point(enum_value:io.prometheus.client.MetricType.COUNTER) + COUNTER = 0, + // @@protoc_insertion_point(enum_value:io.prometheus.client.MetricType.GAUGE) + GAUGE = 1, + // @@protoc_insertion_point(enum_value:io.prometheus.client.MetricType.SUMMARY) + SUMMARY = 2, + // @@protoc_insertion_point(enum_value:io.prometheus.client.MetricType.UNTYPED) + UNTYPED = 3, + // @@protoc_insertion_point(enum_value:io.prometheus.client.MetricType.HISTOGRAM) + HISTOGRAM = 4, + // @@protoc_insertion_point(enum_value:io.prometheus.client.MetricType.GAUGE_HISTOGRAM) + GAUGE_HISTOGRAM = 5, +} + +impl ::protobuf::Enum for MetricType { + const NAME: &'static str = "MetricType"; + + fn value(&self) -> i32 { + *self as i32 + } + + fn from_i32(value: i32) -> ::std::option::Option { + match value { + 0 => ::std::option::Option::Some(MetricType::COUNTER), + 1 => ::std::option::Option::Some(MetricType::GAUGE), + 2 => ::std::option::Option::Some(MetricType::SUMMARY), + 3 => ::std::option::Option::Some(MetricType::UNTYPED), + 4 => ::std::option::Option::Some(MetricType::HISTOGRAM), + 5 => ::std::option::Option::Some(MetricType::GAUGE_HISTOGRAM), + _ => ::std::option::Option::None + } + } + + const VALUES: &'static [MetricType] = &[ + MetricType::COUNTER, + MetricType::GAUGE, + MetricType::SUMMARY, + MetricType::UNTYPED, + MetricType::HISTOGRAM, + MetricType::GAUGE_HISTOGRAM, + ]; +} + +impl ::protobuf::EnumFull for MetricType { + fn enum_descriptor() -> ::protobuf::reflect::EnumDescriptor { + static descriptor: ::protobuf::rt::Lazy<::protobuf::reflect::EnumDescriptor> = ::protobuf::rt::Lazy::new(); + descriptor.get(|| file_descriptor().enum_by_package_relative_name("MetricType").unwrap()).clone() + } + + fn descriptor(&self) -> ::protobuf::reflect::EnumValueDescriptor { + let index = *self as usize; + Self::enum_descriptor().value_by_index(index) + } +} + +impl ::std::default::Default for MetricType { + fn default() -> Self { + MetricType::COUNTER + } +} + +impl MetricType { + fn generated_enum_descriptor_data() -> ::protobuf::reflect::GeneratedEnumDescriptorData { + ::protobuf::reflect::GeneratedEnumDescriptorData::new::("MetricType") + } +} + +static file_descriptor_proto_data: &'static [u8] = b"\ + \n\rmetrics.proto\x12\x14io.prometheus.client\x1a\ngogo.proto\x1a\x1fgoo\ + gle/protobuf/timestamp.proto\"5\n\tLabelPair\x12\x12\n\x04name\x18\x01\ + \x20\x01(\tR\x04name\x12\x14\n\x05value\x18\x02\x20\x01(\tR\x05value\"\ + \x1d\n\x05Gauge\x12\x14\n\x05value\x18\x01\x20\x01(\x01R\x05value\"[\n\ + \x07Counter\x12\x14\n\x05value\x18\x01\x20\x01(\x01R\x05value\x12:\n\x08\ + exemplar\x18\x02\x20\x01(\x0b2\x1e.io.prometheus.client.ExemplarR\x08exe\ + mplar\"<\n\x08Quantile\x12\x1a\n\x08quantile\x18\x01\x20\x01(\x01R\x08qu\ + antile\x12\x14\n\x05value\x18\x02\x20\x01(\x01R\x05value\"\x8d\x01\n\x07\ + Summary\x12!\n\x0csample_count\x18\x01\x20\x01(\x04R\x0bsampleCount\x12\ + \x1d\n\nsample_sum\x18\x02\x20\x01(\x01R\tsampleSum\x12@\n\x08quantile\ + \x18\x03\x20\x03(\x0b2\x1e.io.prometheus.client.QuantileR\x08quantileB\ + \x04\xc8\xde\x1f\0\"\x1f\n\x07Untyped\x12\x14\n\x05value\x18\x01\x20\x01\ + (\x01R\x05value\"\xf5\x04\n\tHistogram\x12!\n\x0csample_count\x18\x01\ + \x20\x01(\x04R\x0bsampleCount\x12,\n\x12sample_count_float\x18\x04\x20\ + \x01(\x01R\x10sampleCountFloat\x12\x1d\n\nsample_sum\x18\x02\x20\x01(\ + \x01R\tsampleSum\x12:\n\x06bucket\x18\x03\x20\x03(\x0b2\x1c.io.prometheu\ + s.client.BucketR\x06bucketB\x04\xc8\xde\x1f\0\x12\x16\n\x06schema\x18\ + \x05\x20\x01(\x11R\x06schema\x12%\n\x0ezero_threshold\x18\x06\x20\x01(\ + \x01R\rzeroThreshold\x12\x1d\n\nzero_count\x18\x07\x20\x01(\x04R\tzeroCo\ + unt\x12(\n\x10zero_count_float\x18\x08\x20\x01(\x01R\x0ezeroCountFloat\ + \x12K\n\rnegative_span\x18\t\x20\x03(\x0b2\x20.io.prometheus.client.Buck\ + etSpanR\x0cnegativeSpanB\x04\xc8\xde\x1f\0\x12%\n\x0enegative_delta\x18\ + \n\x20\x03(\x12R\rnegativeDelta\x12%\n\x0enegative_count\x18\x0b\x20\x03\ + (\x01R\rnegativeCount\x12K\n\rpositive_span\x18\x0c\x20\x03(\x0b2\x20.io\ + .prometheus.client.BucketSpanR\x0cpositiveSpanB\x04\xc8\xde\x1f\0\x12%\n\ + \x0epositive_delta\x18\r\x20\x03(\x12R\rpositiveDelta\x12%\n\x0epositive\ + _count\x18\x0e\x20\x03(\x01R\rpositiveCount\"\xc6\x01\n\x06Bucket\x12)\n\ + \x10cumulative_count\x18\x01\x20\x01(\x04R\x0fcumulativeCount\x124\n\x16\ + cumulative_count_float\x18\x04\x20\x01(\x01R\x14cumulativeCountFloat\x12\ + \x1f\n\x0bupper_bound\x18\x02\x20\x01(\x01R\nupperBound\x12:\n\x08exempl\ + ar\x18\x03\x20\x01(\x0b2\x1e.io.prometheus.client.ExemplarR\x08exemplar\ + \"<\n\nBucketSpan\x12\x16\n\x06offset\x18\x01\x20\x01(\x11R\x06offset\ + \x12\x16\n\x06length\x18\x02\x20\x01(\rR\x06length\"\x97\x01\n\x08Exempl\ + ar\x12;\n\x05label\x18\x01\x20\x03(\x0b2\x1f.io.prometheus.client.LabelP\ + airR\x05labelB\x04\xc8\xde\x1f\0\x12\x14\n\x05value\x18\x02\x20\x01(\x01\ + R\x05value\x128\n\ttimestamp\x18\x03\x20\x01(\x0b2\x1a.google.protobuf.T\ + imestampR\ttimestamp\"\x85\x03\n\x06Metric\x12;\n\x05label\x18\x01\x20\ + \x03(\x0b2\x1f.io.prometheus.client.LabelPairR\x05labelB\x04\xc8\xde\x1f\ + \0\x121\n\x05gauge\x18\x02\x20\x01(\x0b2\x1b.io.prometheus.client.GaugeR\ + \x05gauge\x127\n\x07counter\x18\x03\x20\x01(\x0b2\x1d.io.prometheus.clie\ + nt.CounterR\x07counter\x127\n\x07summary\x18\x04\x20\x01(\x0b2\x1d.io.pr\ + ometheus.client.SummaryR\x07summary\x127\n\x07untyped\x18\x05\x20\x01(\ + \x0b2\x1d.io.prometheus.client.UntypedR\x07untyped\x12=\n\thistogram\x18\ + \x07\x20\x01(\x0b2\x1f.io.prometheus.client.HistogramR\thistogram\x12!\n\ + \x0ctimestamp_ms\x18\x06\x20\x01(\x03R\x0btimestampMs\"\xa8\x01\n\x0cMet\ + ricFamily\x12\x12\n\x04name\x18\x01\x20\x01(\tR\x04name\x12\x12\n\x04hel\ + p\x18\x02\x20\x01(\tR\x04help\x124\n\x04type\x18\x03\x20\x01(\x0e2\x20.i\ + o.prometheus.client.MetricTypeR\x04type\x12:\n\x06metric\x18\x04\x20\x03\ + (\x0b2\x1c.io.prometheus.client.MetricR\x06metricB\x04\xc8\xde\x1f\0*b\n\ + \nMetricType\x12\x0b\n\x07COUNTER\x10\0\x12\t\n\x05GAUGE\x10\x01\x12\x0b\ + \n\x07SUMMARY\x10\x02\x12\x0b\n\x07UNTYPED\x10\x03\x12\r\n\tHISTOGRAM\ + \x10\x04\x12\x13\n\x0fGAUGE_HISTOGRAM\x10\x05B\x16Z\x14io_prometheus_cli\ + entb\x06proto3\ +"; + +/// `FileDescriptorProto` object which was a source for this generated file +fn file_descriptor_proto() -> &'static ::protobuf::descriptor::FileDescriptorProto { + static file_descriptor_proto_lazy: ::protobuf::rt::Lazy<::protobuf::descriptor::FileDescriptorProto> = ::protobuf::rt::Lazy::new(); + file_descriptor_proto_lazy.get(|| { + ::protobuf::Message::parse_from_bytes(file_descriptor_proto_data).unwrap() + }) +} + +/// `FileDescriptor` object which allows dynamic access to files +pub fn file_descriptor() -> &'static ::protobuf::reflect::FileDescriptor { + static generated_file_descriptor_lazy: ::protobuf::rt::Lazy<::protobuf::reflect::GeneratedFileDescriptor> = ::protobuf::rt::Lazy::new(); + static file_descriptor: ::protobuf::rt::Lazy<::protobuf::reflect::FileDescriptor> = ::protobuf::rt::Lazy::new(); + file_descriptor.get(|| { + let generated_file_descriptor = generated_file_descriptor_lazy.get(|| { + let mut deps = ::std::vec::Vec::with_capacity(2); + deps.push(super::gogo::file_descriptor().clone()); + deps.push(::protobuf::well_known_types::timestamp::file_descriptor().clone()); + let mut messages = ::std::vec::Vec::with_capacity(12); + messages.push(LabelPair::generated_message_descriptor_data()); + messages.push(Gauge::generated_message_descriptor_data()); + messages.push(Counter::generated_message_descriptor_data()); + messages.push(Quantile::generated_message_descriptor_data()); + messages.push(Summary::generated_message_descriptor_data()); + messages.push(Untyped::generated_message_descriptor_data()); + messages.push(Histogram::generated_message_descriptor_data()); + messages.push(Bucket::generated_message_descriptor_data()); + messages.push(BucketSpan::generated_message_descriptor_data()); + messages.push(Exemplar::generated_message_descriptor_data()); + messages.push(Metric::generated_message_descriptor_data()); + messages.push(MetricFamily::generated_message_descriptor_data()); + let mut enums = ::std::vec::Vec::with_capacity(1); + enums.push(MetricType::generated_enum_descriptor_data()); + ::protobuf::reflect::GeneratedFileDescriptor::new_generated( + file_descriptor_proto(), + deps, + messages, + enums, + ) + }); + ::protobuf::reflect::FileDescriptor::new_generated_2(generated_file_descriptor) + }) +} diff --git a/proto/mod.rs b/proto/mod.rs new file mode 100644 index 00000000..dbbffdaf --- /dev/null +++ b/proto/mod.rs @@ -0,0 +1,4 @@ +// @generated + +pub mod gogo; +pub mod metrics; diff --git a/proto/proto_model.proto b/proto/proto_model.proto deleted file mode 100644 index 0b84af92..00000000 --- a/proto/proto_model.proto +++ /dev/null @@ -1,81 +0,0 @@ -// Copyright 2013 Prometheus Team -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto2"; - -package io.prometheus.client; -option java_package = "io.prometheus.client"; - -message LabelPair { - optional string name = 1; - optional string value = 2; -} - -enum MetricType { - COUNTER = 0; - GAUGE = 1; - SUMMARY = 2; - UNTYPED = 3; - HISTOGRAM = 4; -} - -message Gauge { - optional double value = 1; -} - -message Counter { - optional double value = 1; -} - -message Quantile { - optional double quantile = 1; - optional double value = 2; -} - -message Summary { - optional uint64 sample_count = 1; - optional double sample_sum = 2; - repeated Quantile quantile = 3; -} - -message Untyped { - optional double value = 1; -} - -message Histogram { - optional uint64 sample_count = 1; - optional double sample_sum = 2; - repeated Bucket bucket = 3; // Ordered in increasing order of upper_bound, +Inf bucket is optional. -} - -message Bucket { - optional uint64 cumulative_count = 1; // Cumulative in increasing order. - optional double upper_bound = 2; // Inclusive. -} - -message Metric { - repeated LabelPair label = 1; - optional Gauge gauge = 2; - optional Counter counter = 3; - optional Summary summary = 4; - optional Untyped untyped = 5; - optional Histogram histogram = 7; - optional int64 timestamp_ms = 6; -} - -message MetricFamily { - optional string name = 1; - optional string help = 2; - optional MetricType type = 3; - repeated Metric metric = 4; -} diff --git a/proto/proto_model.rs b/proto/proto_model.rs deleted file mode 100644 index c67aa4af..00000000 --- a/proto/proto_model.rs +++ /dev/null @@ -1,2532 +0,0 @@ -// This file is generated by rust-protobuf 2.2.5. Do not edit -// @generated - -// https://github.com/Manishearth/rust-clippy/issues/702 -#![allow(unknown_lints)] -#![allow(clippy)] - -#![cfg_attr(rustfmt, rustfmt_skip)] - -#![allow(box_pointers)] -#![allow(dead_code)] -#![allow(missing_docs)] -#![allow(non_camel_case_types)] -#![allow(non_snake_case)] -#![allow(non_upper_case_globals)] -#![allow(trivial_casts)] -#![allow(unsafe_code)] -#![allow(unused_imports)] -#![allow(unused_results)] - -use protobuf::Message as Message_imported_for_functions; -use protobuf::ProtobufEnum as ProtobufEnum_imported_for_functions; - -#[derive(PartialEq,Clone,Default)] -pub struct LabelPair { - // message fields - name: ::protobuf::SingularField<::std::string::String>, - value: ::protobuf::SingularField<::std::string::String>, - // special fields - pub unknown_fields: ::protobuf::UnknownFields, - pub cached_size: ::protobuf::CachedSize, -} - -impl LabelPair { - pub fn new() -> LabelPair { - ::std::default::Default::default() - } - - // optional string name = 1; - - pub fn clear_name(&mut self) { - self.name.clear(); - } - - pub fn has_name(&self) -> bool { - self.name.is_some() - } - - // Param is passed by value, moved - pub fn set_name(&mut self, v: ::std::string::String) { - self.name = ::protobuf::SingularField::some(v); - } - - // Mutable pointer to the field. - // If field is not initialized, it is initialized with default value first. - pub fn mut_name(&mut self) -> &mut ::std::string::String { - if self.name.is_none() { - self.name.set_default(); - } - self.name.as_mut().unwrap() - } - - // Take field - pub fn take_name(&mut self) -> ::std::string::String { - self.name.take().unwrap_or_else(|| ::std::string::String::new()) - } - - pub fn get_name(&self) -> &str { - match self.name.as_ref() { - Some(v) => &v, - None => "", - } - } - - // optional string value = 2; - - pub fn clear_value(&mut self) { - self.value.clear(); - } - - pub fn has_value(&self) -> bool { - self.value.is_some() - } - - // Param is passed by value, moved - pub fn set_value(&mut self, v: ::std::string::String) { - self.value = ::protobuf::SingularField::some(v); - } - - // Mutable pointer to the field. - // If field is not initialized, it is initialized with default value first. - pub fn mut_value(&mut self) -> &mut ::std::string::String { - if self.value.is_none() { - self.value.set_default(); - } - self.value.as_mut().unwrap() - } - - // Take field - pub fn take_value(&mut self) -> ::std::string::String { - self.value.take().unwrap_or_else(|| ::std::string::String::new()) - } - - pub fn get_value(&self) -> &str { - match self.value.as_ref() { - Some(v) => &v, - None => "", - } - } -} - -impl ::protobuf::Message for LabelPair { - fn is_initialized(&self) -> bool { - true - } - - fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::ProtobufResult<()> { - while !is.eof()? { - let (field_number, wire_type) = is.read_tag_unpack()?; - match field_number { - 1 => { - ::protobuf::rt::read_singular_string_into(wire_type, is, &mut self.name)?; - }, - 2 => { - ::protobuf::rt::read_singular_string_into(wire_type, is, &mut self.value)?; - }, - _ => { - ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; - }, - }; - } - ::std::result::Result::Ok(()) - } - - // Compute sizes of nested messages - #[allow(unused_variables)] - fn compute_size(&self) -> u32 { - let mut my_size = 0; - if let Some(ref v) = self.name.as_ref() { - my_size += ::protobuf::rt::string_size(1, &v); - } - if let Some(ref v) = self.value.as_ref() { - my_size += ::protobuf::rt::string_size(2, &v); - } - my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); - self.cached_size.set(my_size); - my_size - } - - fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::ProtobufResult<()> { - if let Some(ref v) = self.name.as_ref() { - os.write_string(1, &v)?; - } - if let Some(ref v) = self.value.as_ref() { - os.write_string(2, &v)?; - } - os.write_unknown_fields(self.get_unknown_fields())?; - ::std::result::Result::Ok(()) - } - - fn get_cached_size(&self) -> u32 { - self.cached_size.get() - } - - fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { - &self.unknown_fields - } - - fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { - &mut self.unknown_fields - } - - fn as_any(&self) -> &::std::any::Any { - self as &::std::any::Any - } - fn as_any_mut(&mut self) -> &mut ::std::any::Any { - self as &mut ::std::any::Any - } - fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { - self - } - - fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { - Self::descriptor_static() - } - - fn new() -> LabelPair { - LabelPair::new() - } - - fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { - static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, - }; - unsafe { - descriptor.get(|| { - let mut fields = ::std::vec::Vec::new(); - fields.push(::protobuf::reflect::accessor::make_singular_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( - "name", - |m: &LabelPair| { &m.name }, - |m: &mut LabelPair| { &mut m.name }, - )); - fields.push(::protobuf::reflect::accessor::make_singular_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( - "value", - |m: &LabelPair| { &m.value }, - |m: &mut LabelPair| { &mut m.value }, - )); - ::protobuf::reflect::MessageDescriptor::new::( - "LabelPair", - fields, - file_descriptor_proto() - ) - }) - } - } - - fn default_instance() -> &'static LabelPair { - static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const LabelPair, - }; - unsafe { - instance.get(LabelPair::new) - } - } -} - -impl ::protobuf::Clear for LabelPair { - fn clear(&mut self) { - self.clear_name(); - self.clear_value(); - self.unknown_fields.clear(); - } -} - -impl ::std::fmt::Debug for LabelPair { - fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { - ::protobuf::text_format::fmt(self, f) - } -} - -impl ::protobuf::reflect::ProtobufValue for LabelPair { - fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef<'_> { - ::protobuf::reflect::ProtobufValueRef::Message(self) - } -} - -#[derive(PartialEq,Clone,Default)] -pub struct Gauge { - // message fields - value: ::std::option::Option, - // special fields - pub unknown_fields: ::protobuf::UnknownFields, - pub cached_size: ::protobuf::CachedSize, -} - -impl Gauge { - pub fn new() -> Gauge { - ::std::default::Default::default() - } - - // optional double value = 1; - - pub fn clear_value(&mut self) { - self.value = ::std::option::Option::None; - } - - pub fn has_value(&self) -> bool { - self.value.is_some() - } - - // Param is passed by value, moved - pub fn set_value(&mut self, v: f64) { - self.value = ::std::option::Option::Some(v); - } - - pub fn get_value(&self) -> f64 { - self.value.unwrap_or(0.) - } -} - -impl ::protobuf::Message for Gauge { - fn is_initialized(&self) -> bool { - true - } - - fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::ProtobufResult<()> { - while !is.eof()? { - let (field_number, wire_type) = is.read_tag_unpack()?; - match field_number { - 1 => { - if wire_type != ::protobuf::wire_format::WireTypeFixed64 { - return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); - } - let tmp = is.read_double()?; - self.value = ::std::option::Option::Some(tmp); - }, - _ => { - ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; - }, - }; - } - ::std::result::Result::Ok(()) - } - - // Compute sizes of nested messages - #[allow(unused_variables)] - fn compute_size(&self) -> u32 { - let mut my_size = 0; - if let Some(v) = self.value { - my_size += 9; - } - my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); - self.cached_size.set(my_size); - my_size - } - - fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::ProtobufResult<()> { - if let Some(v) = self.value { - os.write_double(1, v)?; - } - os.write_unknown_fields(self.get_unknown_fields())?; - ::std::result::Result::Ok(()) - } - - fn get_cached_size(&self) -> u32 { - self.cached_size.get() - } - - fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { - &self.unknown_fields - } - - fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { - &mut self.unknown_fields - } - - fn as_any(&self) -> &::std::any::Any { - self as &::std::any::Any - } - fn as_any_mut(&mut self) -> &mut ::std::any::Any { - self as &mut ::std::any::Any - } - fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { - self - } - - fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { - Self::descriptor_static() - } - - fn new() -> Gauge { - Gauge::new() - } - - fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { - static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, - }; - unsafe { - descriptor.get(|| { - let mut fields = ::std::vec::Vec::new(); - fields.push(::protobuf::reflect::accessor::make_option_accessor::<_, ::protobuf::types::ProtobufTypeDouble>( - "value", - |m: &Gauge| { &m.value }, - |m: &mut Gauge| { &mut m.value }, - )); - ::protobuf::reflect::MessageDescriptor::new::( - "Gauge", - fields, - file_descriptor_proto() - ) - }) - } - } - - fn default_instance() -> &'static Gauge { - static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const Gauge, - }; - unsafe { - instance.get(Gauge::new) - } - } -} - -impl ::protobuf::Clear for Gauge { - fn clear(&mut self) { - self.clear_value(); - self.unknown_fields.clear(); - } -} - -impl ::std::fmt::Debug for Gauge { - fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { - ::protobuf::text_format::fmt(self, f) - } -} - -impl ::protobuf::reflect::ProtobufValue for Gauge { - fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef<'_> { - ::protobuf::reflect::ProtobufValueRef::Message(self) - } -} - -#[derive(PartialEq,Clone,Default)] -pub struct Counter { - // message fields - value: ::std::option::Option, - // special fields - pub unknown_fields: ::protobuf::UnknownFields, - pub cached_size: ::protobuf::CachedSize, -} - -impl Counter { - pub fn new() -> Counter { - ::std::default::Default::default() - } - - // optional double value = 1; - - pub fn clear_value(&mut self) { - self.value = ::std::option::Option::None; - } - - pub fn has_value(&self) -> bool { - self.value.is_some() - } - - // Param is passed by value, moved - pub fn set_value(&mut self, v: f64) { - self.value = ::std::option::Option::Some(v); - } - - pub fn get_value(&self) -> f64 { - self.value.unwrap_or(0.) - } -} - -impl ::protobuf::Message for Counter { - fn is_initialized(&self) -> bool { - true - } - - fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::ProtobufResult<()> { - while !is.eof()? { - let (field_number, wire_type) = is.read_tag_unpack()?; - match field_number { - 1 => { - if wire_type != ::protobuf::wire_format::WireTypeFixed64 { - return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); - } - let tmp = is.read_double()?; - self.value = ::std::option::Option::Some(tmp); - }, - _ => { - ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; - }, - }; - } - ::std::result::Result::Ok(()) - } - - // Compute sizes of nested messages - #[allow(unused_variables)] - fn compute_size(&self) -> u32 { - let mut my_size = 0; - if let Some(v) = self.value { - my_size += 9; - } - my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); - self.cached_size.set(my_size); - my_size - } - - fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::ProtobufResult<()> { - if let Some(v) = self.value { - os.write_double(1, v)?; - } - os.write_unknown_fields(self.get_unknown_fields())?; - ::std::result::Result::Ok(()) - } - - fn get_cached_size(&self) -> u32 { - self.cached_size.get() - } - - fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { - &self.unknown_fields - } - - fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { - &mut self.unknown_fields - } - - fn as_any(&self) -> &::std::any::Any { - self as &::std::any::Any - } - fn as_any_mut(&mut self) -> &mut ::std::any::Any { - self as &mut ::std::any::Any - } - fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { - self - } - - fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { - Self::descriptor_static() - } - - fn new() -> Counter { - Counter::new() - } - - fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { - static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, - }; - unsafe { - descriptor.get(|| { - let mut fields = ::std::vec::Vec::new(); - fields.push(::protobuf::reflect::accessor::make_option_accessor::<_, ::protobuf::types::ProtobufTypeDouble>( - "value", - |m: &Counter| { &m.value }, - |m: &mut Counter| { &mut m.value }, - )); - ::protobuf::reflect::MessageDescriptor::new::( - "Counter", - fields, - file_descriptor_proto() - ) - }) - } - } - - fn default_instance() -> &'static Counter { - static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const Counter, - }; - unsafe { - instance.get(Counter::new) - } - } -} - -impl ::protobuf::Clear for Counter { - fn clear(&mut self) { - self.clear_value(); - self.unknown_fields.clear(); - } -} - -impl ::std::fmt::Debug for Counter { - fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { - ::protobuf::text_format::fmt(self, f) - } -} - -impl ::protobuf::reflect::ProtobufValue for Counter { - fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef<'_> { - ::protobuf::reflect::ProtobufValueRef::Message(self) - } -} - -#[derive(PartialEq,Clone,Default)] -pub struct Quantile { - // message fields - quantile: ::std::option::Option, - value: ::std::option::Option, - // special fields - pub unknown_fields: ::protobuf::UnknownFields, - pub cached_size: ::protobuf::CachedSize, -} - -impl Quantile { - pub fn new() -> Quantile { - ::std::default::Default::default() - } - - // optional double quantile = 1; - - pub fn clear_quantile(&mut self) { - self.quantile = ::std::option::Option::None; - } - - pub fn has_quantile(&self) -> bool { - self.quantile.is_some() - } - - // Param is passed by value, moved - pub fn set_quantile(&mut self, v: f64) { - self.quantile = ::std::option::Option::Some(v); - } - - pub fn get_quantile(&self) -> f64 { - self.quantile.unwrap_or(0.) - } - - // optional double value = 2; - - pub fn clear_value(&mut self) { - self.value = ::std::option::Option::None; - } - - pub fn has_value(&self) -> bool { - self.value.is_some() - } - - // Param is passed by value, moved - pub fn set_value(&mut self, v: f64) { - self.value = ::std::option::Option::Some(v); - } - - pub fn get_value(&self) -> f64 { - self.value.unwrap_or(0.) - } -} - -impl ::protobuf::Message for Quantile { - fn is_initialized(&self) -> bool { - true - } - - fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::ProtobufResult<()> { - while !is.eof()? { - let (field_number, wire_type) = is.read_tag_unpack()?; - match field_number { - 1 => { - if wire_type != ::protobuf::wire_format::WireTypeFixed64 { - return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); - } - let tmp = is.read_double()?; - self.quantile = ::std::option::Option::Some(tmp); - }, - 2 => { - if wire_type != ::protobuf::wire_format::WireTypeFixed64 { - return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); - } - let tmp = is.read_double()?; - self.value = ::std::option::Option::Some(tmp); - }, - _ => { - ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; - }, - }; - } - ::std::result::Result::Ok(()) - } - - // Compute sizes of nested messages - #[allow(unused_variables)] - fn compute_size(&self) -> u32 { - let mut my_size = 0; - if let Some(v) = self.quantile { - my_size += 9; - } - if let Some(v) = self.value { - my_size += 9; - } - my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); - self.cached_size.set(my_size); - my_size - } - - fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::ProtobufResult<()> { - if let Some(v) = self.quantile { - os.write_double(1, v)?; - } - if let Some(v) = self.value { - os.write_double(2, v)?; - } - os.write_unknown_fields(self.get_unknown_fields())?; - ::std::result::Result::Ok(()) - } - - fn get_cached_size(&self) -> u32 { - self.cached_size.get() - } - - fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { - &self.unknown_fields - } - - fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { - &mut self.unknown_fields - } - - fn as_any(&self) -> &::std::any::Any { - self as &::std::any::Any - } - fn as_any_mut(&mut self) -> &mut ::std::any::Any { - self as &mut ::std::any::Any - } - fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { - self - } - - fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { - Self::descriptor_static() - } - - fn new() -> Quantile { - Quantile::new() - } - - fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { - static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, - }; - unsafe { - descriptor.get(|| { - let mut fields = ::std::vec::Vec::new(); - fields.push(::protobuf::reflect::accessor::make_option_accessor::<_, ::protobuf::types::ProtobufTypeDouble>( - "quantile", - |m: &Quantile| { &m.quantile }, - |m: &mut Quantile| { &mut m.quantile }, - )); - fields.push(::protobuf::reflect::accessor::make_option_accessor::<_, ::protobuf::types::ProtobufTypeDouble>( - "value", - |m: &Quantile| { &m.value }, - |m: &mut Quantile| { &mut m.value }, - )); - ::protobuf::reflect::MessageDescriptor::new::( - "Quantile", - fields, - file_descriptor_proto() - ) - }) - } - } - - fn default_instance() -> &'static Quantile { - static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const Quantile, - }; - unsafe { - instance.get(Quantile::new) - } - } -} - -impl ::protobuf::Clear for Quantile { - fn clear(&mut self) { - self.clear_quantile(); - self.clear_value(); - self.unknown_fields.clear(); - } -} - -impl ::std::fmt::Debug for Quantile { - fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { - ::protobuf::text_format::fmt(self, f) - } -} - -impl ::protobuf::reflect::ProtobufValue for Quantile { - fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef<'_> { - ::protobuf::reflect::ProtobufValueRef::Message(self) - } -} - -#[derive(PartialEq,Clone,Default)] -pub struct Summary { - // message fields - sample_count: ::std::option::Option, - sample_sum: ::std::option::Option, - quantile: ::protobuf::RepeatedField, - // special fields - pub unknown_fields: ::protobuf::UnknownFields, - pub cached_size: ::protobuf::CachedSize, -} - -impl Summary { - pub fn new() -> Summary { - ::std::default::Default::default() - } - - // optional uint64 sample_count = 1; - - pub fn clear_sample_count(&mut self) { - self.sample_count = ::std::option::Option::None; - } - - pub fn has_sample_count(&self) -> bool { - self.sample_count.is_some() - } - - // Param is passed by value, moved - pub fn set_sample_count(&mut self, v: u64) { - self.sample_count = ::std::option::Option::Some(v); - } - - pub fn get_sample_count(&self) -> u64 { - self.sample_count.unwrap_or(0) - } - - // optional double sample_sum = 2; - - pub fn clear_sample_sum(&mut self) { - self.sample_sum = ::std::option::Option::None; - } - - pub fn has_sample_sum(&self) -> bool { - self.sample_sum.is_some() - } - - // Param is passed by value, moved - pub fn set_sample_sum(&mut self, v: f64) { - self.sample_sum = ::std::option::Option::Some(v); - } - - pub fn get_sample_sum(&self) -> f64 { - self.sample_sum.unwrap_or(0.) - } - - // repeated .io.prometheus.client.Quantile quantile = 3; - - pub fn clear_quantile(&mut self) { - self.quantile.clear(); - } - - // Param is passed by value, moved - pub fn set_quantile(&mut self, v: ::protobuf::RepeatedField) { - self.quantile = v; - } - - // Mutable pointer to the field. - pub fn mut_quantile(&mut self) -> &mut ::protobuf::RepeatedField { - &mut self.quantile - } - - // Take field - pub fn take_quantile(&mut self) -> ::protobuf::RepeatedField { - ::std::mem::replace(&mut self.quantile, ::protobuf::RepeatedField::new()) - } - - pub fn get_quantile(&self) -> &[Quantile] { - &self.quantile - } -} - -impl ::protobuf::Message for Summary { - fn is_initialized(&self) -> bool { - for v in &self.quantile { - if !v.is_initialized() { - return false; - } - }; - true - } - - fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::ProtobufResult<()> { - while !is.eof()? { - let (field_number, wire_type) = is.read_tag_unpack()?; - match field_number { - 1 => { - if wire_type != ::protobuf::wire_format::WireTypeVarint { - return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); - } - let tmp = is.read_uint64()?; - self.sample_count = ::std::option::Option::Some(tmp); - }, - 2 => { - if wire_type != ::protobuf::wire_format::WireTypeFixed64 { - return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); - } - let tmp = is.read_double()?; - self.sample_sum = ::std::option::Option::Some(tmp); - }, - 3 => { - ::protobuf::rt::read_repeated_message_into(wire_type, is, &mut self.quantile)?; - }, - _ => { - ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; - }, - }; - } - ::std::result::Result::Ok(()) - } - - // Compute sizes of nested messages - #[allow(unused_variables)] - fn compute_size(&self) -> u32 { - let mut my_size = 0; - if let Some(v) = self.sample_count { - my_size += ::protobuf::rt::value_size(1, v, ::protobuf::wire_format::WireTypeVarint); - } - if let Some(v) = self.sample_sum { - my_size += 9; - } - for value in &self.quantile { - let len = value.compute_size(); - my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; - }; - my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); - self.cached_size.set(my_size); - my_size - } - - fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::ProtobufResult<()> { - if let Some(v) = self.sample_count { - os.write_uint64(1, v)?; - } - if let Some(v) = self.sample_sum { - os.write_double(2, v)?; - } - for v in &self.quantile { - os.write_tag(3, ::protobuf::wire_format::WireTypeLengthDelimited)?; - os.write_raw_varint32(v.get_cached_size())?; - v.write_to_with_cached_sizes(os)?; - }; - os.write_unknown_fields(self.get_unknown_fields())?; - ::std::result::Result::Ok(()) - } - - fn get_cached_size(&self) -> u32 { - self.cached_size.get() - } - - fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { - &self.unknown_fields - } - - fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { - &mut self.unknown_fields - } - - fn as_any(&self) -> &::std::any::Any { - self as &::std::any::Any - } - fn as_any_mut(&mut self) -> &mut ::std::any::Any { - self as &mut ::std::any::Any - } - fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { - self - } - - fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { - Self::descriptor_static() - } - - fn new() -> Summary { - Summary::new() - } - - fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { - static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, - }; - unsafe { - descriptor.get(|| { - let mut fields = ::std::vec::Vec::new(); - fields.push(::protobuf::reflect::accessor::make_option_accessor::<_, ::protobuf::types::ProtobufTypeUint64>( - "sample_count", - |m: &Summary| { &m.sample_count }, - |m: &mut Summary| { &mut m.sample_count }, - )); - fields.push(::protobuf::reflect::accessor::make_option_accessor::<_, ::protobuf::types::ProtobufTypeDouble>( - "sample_sum", - |m: &Summary| { &m.sample_sum }, - |m: &mut Summary| { &mut m.sample_sum }, - )); - fields.push(::protobuf::reflect::accessor::make_repeated_field_accessor::<_, ::protobuf::types::ProtobufTypeMessage>( - "quantile", - |m: &Summary| { &m.quantile }, - |m: &mut Summary| { &mut m.quantile }, - )); - ::protobuf::reflect::MessageDescriptor::new::( - "Summary", - fields, - file_descriptor_proto() - ) - }) - } - } - - fn default_instance() -> &'static Summary { - static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const Summary, - }; - unsafe { - instance.get(Summary::new) - } - } -} - -impl ::protobuf::Clear for Summary { - fn clear(&mut self) { - self.clear_sample_count(); - self.clear_sample_sum(); - self.clear_quantile(); - self.unknown_fields.clear(); - } -} - -impl ::std::fmt::Debug for Summary { - fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { - ::protobuf::text_format::fmt(self, f) - } -} - -impl ::protobuf::reflect::ProtobufValue for Summary { - fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef<'_> { - ::protobuf::reflect::ProtobufValueRef::Message(self) - } -} - -#[derive(PartialEq,Clone,Default)] -pub struct Untyped { - // message fields - value: ::std::option::Option, - // special fields - pub unknown_fields: ::protobuf::UnknownFields, - pub cached_size: ::protobuf::CachedSize, -} - -impl Untyped { - pub fn new() -> Untyped { - ::std::default::Default::default() - } - - // optional double value = 1; - - pub fn clear_value(&mut self) { - self.value = ::std::option::Option::None; - } - - pub fn has_value(&self) -> bool { - self.value.is_some() - } - - // Param is passed by value, moved - pub fn set_value(&mut self, v: f64) { - self.value = ::std::option::Option::Some(v); - } - - pub fn get_value(&self) -> f64 { - self.value.unwrap_or(0.) - } -} - -impl ::protobuf::Message for Untyped { - fn is_initialized(&self) -> bool { - true - } - - fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::ProtobufResult<()> { - while !is.eof()? { - let (field_number, wire_type) = is.read_tag_unpack()?; - match field_number { - 1 => { - if wire_type != ::protobuf::wire_format::WireTypeFixed64 { - return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); - } - let tmp = is.read_double()?; - self.value = ::std::option::Option::Some(tmp); - }, - _ => { - ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; - }, - }; - } - ::std::result::Result::Ok(()) - } - - // Compute sizes of nested messages - #[allow(unused_variables)] - fn compute_size(&self) -> u32 { - let mut my_size = 0; - if let Some(v) = self.value { - my_size += 9; - } - my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); - self.cached_size.set(my_size); - my_size - } - - fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::ProtobufResult<()> { - if let Some(v) = self.value { - os.write_double(1, v)?; - } - os.write_unknown_fields(self.get_unknown_fields())?; - ::std::result::Result::Ok(()) - } - - fn get_cached_size(&self) -> u32 { - self.cached_size.get() - } - - fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { - &self.unknown_fields - } - - fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { - &mut self.unknown_fields - } - - fn as_any(&self) -> &::std::any::Any { - self as &::std::any::Any - } - fn as_any_mut(&mut self) -> &mut ::std::any::Any { - self as &mut ::std::any::Any - } - fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { - self - } - - fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { - Self::descriptor_static() - } - - fn new() -> Untyped { - Untyped::new() - } - - fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { - static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, - }; - unsafe { - descriptor.get(|| { - let mut fields = ::std::vec::Vec::new(); - fields.push(::protobuf::reflect::accessor::make_option_accessor::<_, ::protobuf::types::ProtobufTypeDouble>( - "value", - |m: &Untyped| { &m.value }, - |m: &mut Untyped| { &mut m.value }, - )); - ::protobuf::reflect::MessageDescriptor::new::( - "Untyped", - fields, - file_descriptor_proto() - ) - }) - } - } - - fn default_instance() -> &'static Untyped { - static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const Untyped, - }; - unsafe { - instance.get(Untyped::new) - } - } -} - -impl ::protobuf::Clear for Untyped { - fn clear(&mut self) { - self.clear_value(); - self.unknown_fields.clear(); - } -} - -impl ::std::fmt::Debug for Untyped { - fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { - ::protobuf::text_format::fmt(self, f) - } -} - -impl ::protobuf::reflect::ProtobufValue for Untyped { - fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef<'_> { - ::protobuf::reflect::ProtobufValueRef::Message(self) - } -} - -#[derive(PartialEq,Clone,Default)] -pub struct Histogram { - // message fields - sample_count: ::std::option::Option, - sample_sum: ::std::option::Option, - bucket: ::protobuf::RepeatedField, - // special fields - pub unknown_fields: ::protobuf::UnknownFields, - pub cached_size: ::protobuf::CachedSize, -} - -impl Histogram { - pub fn new() -> Histogram { - ::std::default::Default::default() - } - - // optional uint64 sample_count = 1; - - pub fn clear_sample_count(&mut self) { - self.sample_count = ::std::option::Option::None; - } - - pub fn has_sample_count(&self) -> bool { - self.sample_count.is_some() - } - - // Param is passed by value, moved - pub fn set_sample_count(&mut self, v: u64) { - self.sample_count = ::std::option::Option::Some(v); - } - - pub fn get_sample_count(&self) -> u64 { - self.sample_count.unwrap_or(0) - } - - // optional double sample_sum = 2; - - pub fn clear_sample_sum(&mut self) { - self.sample_sum = ::std::option::Option::None; - } - - pub fn has_sample_sum(&self) -> bool { - self.sample_sum.is_some() - } - - // Param is passed by value, moved - pub fn set_sample_sum(&mut self, v: f64) { - self.sample_sum = ::std::option::Option::Some(v); - } - - pub fn get_sample_sum(&self) -> f64 { - self.sample_sum.unwrap_or(0.) - } - - // repeated .io.prometheus.client.Bucket bucket = 3; - - pub fn clear_bucket(&mut self) { - self.bucket.clear(); - } - - // Param is passed by value, moved - pub fn set_bucket(&mut self, v: ::protobuf::RepeatedField) { - self.bucket = v; - } - - // Mutable pointer to the field. - pub fn mut_bucket(&mut self) -> &mut ::protobuf::RepeatedField { - &mut self.bucket - } - - // Take field - pub fn take_bucket(&mut self) -> ::protobuf::RepeatedField { - ::std::mem::replace(&mut self.bucket, ::protobuf::RepeatedField::new()) - } - - pub fn get_bucket(&self) -> &[Bucket] { - &self.bucket - } -} - -impl ::protobuf::Message for Histogram { - fn is_initialized(&self) -> bool { - for v in &self.bucket { - if !v.is_initialized() { - return false; - } - }; - true - } - - fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::ProtobufResult<()> { - while !is.eof()? { - let (field_number, wire_type) = is.read_tag_unpack()?; - match field_number { - 1 => { - if wire_type != ::protobuf::wire_format::WireTypeVarint { - return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); - } - let tmp = is.read_uint64()?; - self.sample_count = ::std::option::Option::Some(tmp); - }, - 2 => { - if wire_type != ::protobuf::wire_format::WireTypeFixed64 { - return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); - } - let tmp = is.read_double()?; - self.sample_sum = ::std::option::Option::Some(tmp); - }, - 3 => { - ::protobuf::rt::read_repeated_message_into(wire_type, is, &mut self.bucket)?; - }, - _ => { - ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; - }, - }; - } - ::std::result::Result::Ok(()) - } - - // Compute sizes of nested messages - #[allow(unused_variables)] - fn compute_size(&self) -> u32 { - let mut my_size = 0; - if let Some(v) = self.sample_count { - my_size += ::protobuf::rt::value_size(1, v, ::protobuf::wire_format::WireTypeVarint); - } - if let Some(v) = self.sample_sum { - my_size += 9; - } - for value in &self.bucket { - let len = value.compute_size(); - my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; - }; - my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); - self.cached_size.set(my_size); - my_size - } - - fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::ProtobufResult<()> { - if let Some(v) = self.sample_count { - os.write_uint64(1, v)?; - } - if let Some(v) = self.sample_sum { - os.write_double(2, v)?; - } - for v in &self.bucket { - os.write_tag(3, ::protobuf::wire_format::WireTypeLengthDelimited)?; - os.write_raw_varint32(v.get_cached_size())?; - v.write_to_with_cached_sizes(os)?; - }; - os.write_unknown_fields(self.get_unknown_fields())?; - ::std::result::Result::Ok(()) - } - - fn get_cached_size(&self) -> u32 { - self.cached_size.get() - } - - fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { - &self.unknown_fields - } - - fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { - &mut self.unknown_fields - } - - fn as_any(&self) -> &::std::any::Any { - self as &::std::any::Any - } - fn as_any_mut(&mut self) -> &mut ::std::any::Any { - self as &mut ::std::any::Any - } - fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { - self - } - - fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { - Self::descriptor_static() - } - - fn new() -> Histogram { - Histogram::new() - } - - fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { - static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, - }; - unsafe { - descriptor.get(|| { - let mut fields = ::std::vec::Vec::new(); - fields.push(::protobuf::reflect::accessor::make_option_accessor::<_, ::protobuf::types::ProtobufTypeUint64>( - "sample_count", - |m: &Histogram| { &m.sample_count }, - |m: &mut Histogram| { &mut m.sample_count }, - )); - fields.push(::protobuf::reflect::accessor::make_option_accessor::<_, ::protobuf::types::ProtobufTypeDouble>( - "sample_sum", - |m: &Histogram| { &m.sample_sum }, - |m: &mut Histogram| { &mut m.sample_sum }, - )); - fields.push(::protobuf::reflect::accessor::make_repeated_field_accessor::<_, ::protobuf::types::ProtobufTypeMessage>( - "bucket", - |m: &Histogram| { &m.bucket }, - |m: &mut Histogram| { &mut m.bucket }, - )); - ::protobuf::reflect::MessageDescriptor::new::( - "Histogram", - fields, - file_descriptor_proto() - ) - }) - } - } - - fn default_instance() -> &'static Histogram { - static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const Histogram, - }; - unsafe { - instance.get(Histogram::new) - } - } -} - -impl ::protobuf::Clear for Histogram { - fn clear(&mut self) { - self.clear_sample_count(); - self.clear_sample_sum(); - self.clear_bucket(); - self.unknown_fields.clear(); - } -} - -impl ::std::fmt::Debug for Histogram { - fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { - ::protobuf::text_format::fmt(self, f) - } -} - -impl ::protobuf::reflect::ProtobufValue for Histogram { - fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef<'_> { - ::protobuf::reflect::ProtobufValueRef::Message(self) - } -} - -#[derive(PartialEq,Clone,Default)] -pub struct Bucket { - // message fields - cumulative_count: ::std::option::Option, - upper_bound: ::std::option::Option, - // special fields - pub unknown_fields: ::protobuf::UnknownFields, - pub cached_size: ::protobuf::CachedSize, -} - -impl Bucket { - pub fn new() -> Bucket { - ::std::default::Default::default() - } - - // optional uint64 cumulative_count = 1; - - pub fn clear_cumulative_count(&mut self) { - self.cumulative_count = ::std::option::Option::None; - } - - pub fn has_cumulative_count(&self) -> bool { - self.cumulative_count.is_some() - } - - // Param is passed by value, moved - pub fn set_cumulative_count(&mut self, v: u64) { - self.cumulative_count = ::std::option::Option::Some(v); - } - - pub fn get_cumulative_count(&self) -> u64 { - self.cumulative_count.unwrap_or(0) - } - - // optional double upper_bound = 2; - - pub fn clear_upper_bound(&mut self) { - self.upper_bound = ::std::option::Option::None; - } - - pub fn has_upper_bound(&self) -> bool { - self.upper_bound.is_some() - } - - // Param is passed by value, moved - pub fn set_upper_bound(&mut self, v: f64) { - self.upper_bound = ::std::option::Option::Some(v); - } - - pub fn get_upper_bound(&self) -> f64 { - self.upper_bound.unwrap_or(0.) - } -} - -impl ::protobuf::Message for Bucket { - fn is_initialized(&self) -> bool { - true - } - - fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::ProtobufResult<()> { - while !is.eof()? { - let (field_number, wire_type) = is.read_tag_unpack()?; - match field_number { - 1 => { - if wire_type != ::protobuf::wire_format::WireTypeVarint { - return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); - } - let tmp = is.read_uint64()?; - self.cumulative_count = ::std::option::Option::Some(tmp); - }, - 2 => { - if wire_type != ::protobuf::wire_format::WireTypeFixed64 { - return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); - } - let tmp = is.read_double()?; - self.upper_bound = ::std::option::Option::Some(tmp); - }, - _ => { - ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; - }, - }; - } - ::std::result::Result::Ok(()) - } - - // Compute sizes of nested messages - #[allow(unused_variables)] - fn compute_size(&self) -> u32 { - let mut my_size = 0; - if let Some(v) = self.cumulative_count { - my_size += ::protobuf::rt::value_size(1, v, ::protobuf::wire_format::WireTypeVarint); - } - if let Some(v) = self.upper_bound { - my_size += 9; - } - my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); - self.cached_size.set(my_size); - my_size - } - - fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::ProtobufResult<()> { - if let Some(v) = self.cumulative_count { - os.write_uint64(1, v)?; - } - if let Some(v) = self.upper_bound { - os.write_double(2, v)?; - } - os.write_unknown_fields(self.get_unknown_fields())?; - ::std::result::Result::Ok(()) - } - - fn get_cached_size(&self) -> u32 { - self.cached_size.get() - } - - fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { - &self.unknown_fields - } - - fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { - &mut self.unknown_fields - } - - fn as_any(&self) -> &::std::any::Any { - self as &::std::any::Any - } - fn as_any_mut(&mut self) -> &mut ::std::any::Any { - self as &mut ::std::any::Any - } - fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { - self - } - - fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { - Self::descriptor_static() - } - - fn new() -> Bucket { - Bucket::new() - } - - fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { - static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, - }; - unsafe { - descriptor.get(|| { - let mut fields = ::std::vec::Vec::new(); - fields.push(::protobuf::reflect::accessor::make_option_accessor::<_, ::protobuf::types::ProtobufTypeUint64>( - "cumulative_count", - |m: &Bucket| { &m.cumulative_count }, - |m: &mut Bucket| { &mut m.cumulative_count }, - )); - fields.push(::protobuf::reflect::accessor::make_option_accessor::<_, ::protobuf::types::ProtobufTypeDouble>( - "upper_bound", - |m: &Bucket| { &m.upper_bound }, - |m: &mut Bucket| { &mut m.upper_bound }, - )); - ::protobuf::reflect::MessageDescriptor::new::( - "Bucket", - fields, - file_descriptor_proto() - ) - }) - } - } - - fn default_instance() -> &'static Bucket { - static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const Bucket, - }; - unsafe { - instance.get(Bucket::new) - } - } -} - -impl ::protobuf::Clear for Bucket { - fn clear(&mut self) { - self.clear_cumulative_count(); - self.clear_upper_bound(); - self.unknown_fields.clear(); - } -} - -impl ::std::fmt::Debug for Bucket { - fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { - ::protobuf::text_format::fmt(self, f) - } -} - -impl ::protobuf::reflect::ProtobufValue for Bucket { - fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef<'_> { - ::protobuf::reflect::ProtobufValueRef::Message(self) - } -} - -#[derive(PartialEq,Clone,Default)] -pub struct Metric { - // message fields - label: ::protobuf::RepeatedField, - gauge: ::protobuf::SingularPtrField, - counter: ::protobuf::SingularPtrField, - summary: ::protobuf::SingularPtrField, - untyped: ::protobuf::SingularPtrField, - histogram: ::protobuf::SingularPtrField, - timestamp_ms: ::std::option::Option, - // special fields - pub unknown_fields: ::protobuf::UnknownFields, - pub cached_size: ::protobuf::CachedSize, -} - -impl Metric { - pub fn new() -> Metric { - ::std::default::Default::default() - } - - // repeated .io.prometheus.client.LabelPair label = 1; - - pub fn clear_label(&mut self) { - self.label.clear(); - } - - // Param is passed by value, moved - pub fn set_label(&mut self, v: ::protobuf::RepeatedField) { - self.label = v; - } - - // Mutable pointer to the field. - pub fn mut_label(&mut self) -> &mut ::protobuf::RepeatedField { - &mut self.label - } - - // Take field - pub fn take_label(&mut self) -> ::protobuf::RepeatedField { - ::std::mem::replace(&mut self.label, ::protobuf::RepeatedField::new()) - } - - pub fn get_label(&self) -> &[LabelPair] { - &self.label - } - - // optional .io.prometheus.client.Gauge gauge = 2; - - pub fn clear_gauge(&mut self) { - self.gauge.clear(); - } - - pub fn has_gauge(&self) -> bool { - self.gauge.is_some() - } - - // Param is passed by value, moved - pub fn set_gauge(&mut self, v: Gauge) { - self.gauge = ::protobuf::SingularPtrField::some(v); - } - - // Mutable pointer to the field. - // If field is not initialized, it is initialized with default value first. - pub fn mut_gauge(&mut self) -> &mut Gauge { - if self.gauge.is_none() { - self.gauge.set_default(); - } - self.gauge.as_mut().unwrap() - } - - // Take field - pub fn take_gauge(&mut self) -> Gauge { - self.gauge.take().unwrap_or_else(|| Gauge::new()) - } - - pub fn get_gauge(&self) -> &Gauge { - self.gauge.as_ref().unwrap_or_else(|| Gauge::default_instance()) - } - - // optional .io.prometheus.client.Counter counter = 3; - - pub fn clear_counter(&mut self) { - self.counter.clear(); - } - - pub fn has_counter(&self) -> bool { - self.counter.is_some() - } - - // Param is passed by value, moved - pub fn set_counter(&mut self, v: Counter) { - self.counter = ::protobuf::SingularPtrField::some(v); - } - - // Mutable pointer to the field. - // If field is not initialized, it is initialized with default value first. - pub fn mut_counter(&mut self) -> &mut Counter { - if self.counter.is_none() { - self.counter.set_default(); - } - self.counter.as_mut().unwrap() - } - - // Take field - pub fn take_counter(&mut self) -> Counter { - self.counter.take().unwrap_or_else(|| Counter::new()) - } - - pub fn get_counter(&self) -> &Counter { - self.counter.as_ref().unwrap_or_else(|| Counter::default_instance()) - } - - // optional .io.prometheus.client.Summary summary = 4; - - pub fn clear_summary(&mut self) { - self.summary.clear(); - } - - pub fn has_summary(&self) -> bool { - self.summary.is_some() - } - - // Param is passed by value, moved - pub fn set_summary(&mut self, v: Summary) { - self.summary = ::protobuf::SingularPtrField::some(v); - } - - // Mutable pointer to the field. - // If field is not initialized, it is initialized with default value first. - pub fn mut_summary(&mut self) -> &mut Summary { - if self.summary.is_none() { - self.summary.set_default(); - } - self.summary.as_mut().unwrap() - } - - // Take field - pub fn take_summary(&mut self) -> Summary { - self.summary.take().unwrap_or_else(|| Summary::new()) - } - - pub fn get_summary(&self) -> &Summary { - self.summary.as_ref().unwrap_or_else(|| Summary::default_instance()) - } - - // optional .io.prometheus.client.Untyped untyped = 5; - - pub fn clear_untyped(&mut self) { - self.untyped.clear(); - } - - pub fn has_untyped(&self) -> bool { - self.untyped.is_some() - } - - // Param is passed by value, moved - pub fn set_untyped(&mut self, v: Untyped) { - self.untyped = ::protobuf::SingularPtrField::some(v); - } - - // Mutable pointer to the field. - // If field is not initialized, it is initialized with default value first. - pub fn mut_untyped(&mut self) -> &mut Untyped { - if self.untyped.is_none() { - self.untyped.set_default(); - } - self.untyped.as_mut().unwrap() - } - - // Take field - pub fn take_untyped(&mut self) -> Untyped { - self.untyped.take().unwrap_or_else(|| Untyped::new()) - } - - pub fn get_untyped(&self) -> &Untyped { - self.untyped.as_ref().unwrap_or_else(|| Untyped::default_instance()) - } - - // optional .io.prometheus.client.Histogram histogram = 7; - - pub fn clear_histogram(&mut self) { - self.histogram.clear(); - } - - pub fn has_histogram(&self) -> bool { - self.histogram.is_some() - } - - // Param is passed by value, moved - pub fn set_histogram(&mut self, v: Histogram) { - self.histogram = ::protobuf::SingularPtrField::some(v); - } - - // Mutable pointer to the field. - // If field is not initialized, it is initialized with default value first. - pub fn mut_histogram(&mut self) -> &mut Histogram { - if self.histogram.is_none() { - self.histogram.set_default(); - } - self.histogram.as_mut().unwrap() - } - - // Take field - pub fn take_histogram(&mut self) -> Histogram { - self.histogram.take().unwrap_or_else(|| Histogram::new()) - } - - pub fn get_histogram(&self) -> &Histogram { - self.histogram.as_ref().unwrap_or_else(|| Histogram::default_instance()) - } - - // optional int64 timestamp_ms = 6; - - pub fn clear_timestamp_ms(&mut self) { - self.timestamp_ms = ::std::option::Option::None; - } - - pub fn has_timestamp_ms(&self) -> bool { - self.timestamp_ms.is_some() - } - - // Param is passed by value, moved - pub fn set_timestamp_ms(&mut self, v: i64) { - self.timestamp_ms = ::std::option::Option::Some(v); - } - - pub fn get_timestamp_ms(&self) -> i64 { - self.timestamp_ms.unwrap_or(0) - } -} - -impl ::protobuf::Message for Metric { - fn is_initialized(&self) -> bool { - for v in &self.label { - if !v.is_initialized() { - return false; - } - }; - for v in &self.gauge { - if !v.is_initialized() { - return false; - } - }; - for v in &self.counter { - if !v.is_initialized() { - return false; - } - }; - for v in &self.summary { - if !v.is_initialized() { - return false; - } - }; - for v in &self.untyped { - if !v.is_initialized() { - return false; - } - }; - for v in &self.histogram { - if !v.is_initialized() { - return false; - } - }; - true - } - - fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::ProtobufResult<()> { - while !is.eof()? { - let (field_number, wire_type) = is.read_tag_unpack()?; - match field_number { - 1 => { - ::protobuf::rt::read_repeated_message_into(wire_type, is, &mut self.label)?; - }, - 2 => { - ::protobuf::rt::read_singular_message_into(wire_type, is, &mut self.gauge)?; - }, - 3 => { - ::protobuf::rt::read_singular_message_into(wire_type, is, &mut self.counter)?; - }, - 4 => { - ::protobuf::rt::read_singular_message_into(wire_type, is, &mut self.summary)?; - }, - 5 => { - ::protobuf::rt::read_singular_message_into(wire_type, is, &mut self.untyped)?; - }, - 7 => { - ::protobuf::rt::read_singular_message_into(wire_type, is, &mut self.histogram)?; - }, - 6 => { - if wire_type != ::protobuf::wire_format::WireTypeVarint { - return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); - } - let tmp = is.read_int64()?; - self.timestamp_ms = ::std::option::Option::Some(tmp); - }, - _ => { - ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; - }, - }; - } - ::std::result::Result::Ok(()) - } - - // Compute sizes of nested messages - #[allow(unused_variables)] - fn compute_size(&self) -> u32 { - let mut my_size = 0; - for value in &self.label { - let len = value.compute_size(); - my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; - }; - if let Some(ref v) = self.gauge.as_ref() { - let len = v.compute_size(); - my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; - } - if let Some(ref v) = self.counter.as_ref() { - let len = v.compute_size(); - my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; - } - if let Some(ref v) = self.summary.as_ref() { - let len = v.compute_size(); - my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; - } - if let Some(ref v) = self.untyped.as_ref() { - let len = v.compute_size(); - my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; - } - if let Some(ref v) = self.histogram.as_ref() { - let len = v.compute_size(); - my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; - } - if let Some(v) = self.timestamp_ms { - my_size += ::protobuf::rt::value_size(6, v, ::protobuf::wire_format::WireTypeVarint); - } - my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); - self.cached_size.set(my_size); - my_size - } - - fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::ProtobufResult<()> { - for v in &self.label { - os.write_tag(1, ::protobuf::wire_format::WireTypeLengthDelimited)?; - os.write_raw_varint32(v.get_cached_size())?; - v.write_to_with_cached_sizes(os)?; - }; - if let Some(ref v) = self.gauge.as_ref() { - os.write_tag(2, ::protobuf::wire_format::WireTypeLengthDelimited)?; - os.write_raw_varint32(v.get_cached_size())?; - v.write_to_with_cached_sizes(os)?; - } - if let Some(ref v) = self.counter.as_ref() { - os.write_tag(3, ::protobuf::wire_format::WireTypeLengthDelimited)?; - os.write_raw_varint32(v.get_cached_size())?; - v.write_to_with_cached_sizes(os)?; - } - if let Some(ref v) = self.summary.as_ref() { - os.write_tag(4, ::protobuf::wire_format::WireTypeLengthDelimited)?; - os.write_raw_varint32(v.get_cached_size())?; - v.write_to_with_cached_sizes(os)?; - } - if let Some(ref v) = self.untyped.as_ref() { - os.write_tag(5, ::protobuf::wire_format::WireTypeLengthDelimited)?; - os.write_raw_varint32(v.get_cached_size())?; - v.write_to_with_cached_sizes(os)?; - } - if let Some(ref v) = self.histogram.as_ref() { - os.write_tag(7, ::protobuf::wire_format::WireTypeLengthDelimited)?; - os.write_raw_varint32(v.get_cached_size())?; - v.write_to_with_cached_sizes(os)?; - } - if let Some(v) = self.timestamp_ms { - os.write_int64(6, v)?; - } - os.write_unknown_fields(self.get_unknown_fields())?; - ::std::result::Result::Ok(()) - } - - fn get_cached_size(&self) -> u32 { - self.cached_size.get() - } - - fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { - &self.unknown_fields - } - - fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { - &mut self.unknown_fields - } - - fn as_any(&self) -> &::std::any::Any { - self as &::std::any::Any - } - fn as_any_mut(&mut self) -> &mut ::std::any::Any { - self as &mut ::std::any::Any - } - fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { - self - } - - fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { - Self::descriptor_static() - } - - fn new() -> Metric { - Metric::new() - } - - fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { - static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, - }; - unsafe { - descriptor.get(|| { - let mut fields = ::std::vec::Vec::new(); - fields.push(::protobuf::reflect::accessor::make_repeated_field_accessor::<_, ::protobuf::types::ProtobufTypeMessage>( - "label", - |m: &Metric| { &m.label }, - |m: &mut Metric| { &mut m.label }, - )); - fields.push(::protobuf::reflect::accessor::make_singular_ptr_field_accessor::<_, ::protobuf::types::ProtobufTypeMessage>( - "gauge", - |m: &Metric| { &m.gauge }, - |m: &mut Metric| { &mut m.gauge }, - )); - fields.push(::protobuf::reflect::accessor::make_singular_ptr_field_accessor::<_, ::protobuf::types::ProtobufTypeMessage>( - "counter", - |m: &Metric| { &m.counter }, - |m: &mut Metric| { &mut m.counter }, - )); - fields.push(::protobuf::reflect::accessor::make_singular_ptr_field_accessor::<_, ::protobuf::types::ProtobufTypeMessage>( - "summary", - |m: &Metric| { &m.summary }, - |m: &mut Metric| { &mut m.summary }, - )); - fields.push(::protobuf::reflect::accessor::make_singular_ptr_field_accessor::<_, ::protobuf::types::ProtobufTypeMessage>( - "untyped", - |m: &Metric| { &m.untyped }, - |m: &mut Metric| { &mut m.untyped }, - )); - fields.push(::protobuf::reflect::accessor::make_singular_ptr_field_accessor::<_, ::protobuf::types::ProtobufTypeMessage>( - "histogram", - |m: &Metric| { &m.histogram }, - |m: &mut Metric| { &mut m.histogram }, - )); - fields.push(::protobuf::reflect::accessor::make_option_accessor::<_, ::protobuf::types::ProtobufTypeInt64>( - "timestamp_ms", - |m: &Metric| { &m.timestamp_ms }, - |m: &mut Metric| { &mut m.timestamp_ms }, - )); - ::protobuf::reflect::MessageDescriptor::new::( - "Metric", - fields, - file_descriptor_proto() - ) - }) - } - } - - fn default_instance() -> &'static Metric { - static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const Metric, - }; - unsafe { - instance.get(Metric::new) - } - } -} - -impl ::protobuf::Clear for Metric { - fn clear(&mut self) { - self.clear_label(); - self.clear_gauge(); - self.clear_counter(); - self.clear_summary(); - self.clear_untyped(); - self.clear_histogram(); - self.clear_timestamp_ms(); - self.unknown_fields.clear(); - } -} - -impl ::std::fmt::Debug for Metric { - fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { - ::protobuf::text_format::fmt(self, f) - } -} - -impl ::protobuf::reflect::ProtobufValue for Metric { - fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef<'_> { - ::protobuf::reflect::ProtobufValueRef::Message(self) - } -} - -#[derive(PartialEq,Clone,Default)] -pub struct MetricFamily { - // message fields - name: ::protobuf::SingularField<::std::string::String>, - help: ::protobuf::SingularField<::std::string::String>, - field_type: ::std::option::Option, - metric: ::protobuf::RepeatedField, - // special fields - pub unknown_fields: ::protobuf::UnknownFields, - pub cached_size: ::protobuf::CachedSize, -} - -impl MetricFamily { - pub fn new() -> MetricFamily { - ::std::default::Default::default() - } - - // optional string name = 1; - - pub fn clear_name(&mut self) { - self.name.clear(); - } - - pub fn has_name(&self) -> bool { - self.name.is_some() - } - - // Param is passed by value, moved - pub fn set_name(&mut self, v: ::std::string::String) { - self.name = ::protobuf::SingularField::some(v); - } - - // Mutable pointer to the field. - // If field is not initialized, it is initialized with default value first. - pub fn mut_name(&mut self) -> &mut ::std::string::String { - if self.name.is_none() { - self.name.set_default(); - } - self.name.as_mut().unwrap() - } - - // Take field - pub fn take_name(&mut self) -> ::std::string::String { - self.name.take().unwrap_or_else(|| ::std::string::String::new()) - } - - pub fn get_name(&self) -> &str { - match self.name.as_ref() { - Some(v) => &v, - None => "", - } - } - - // optional string help = 2; - - pub fn clear_help(&mut self) { - self.help.clear(); - } - - pub fn has_help(&self) -> bool { - self.help.is_some() - } - - // Param is passed by value, moved - pub fn set_help(&mut self, v: ::std::string::String) { - self.help = ::protobuf::SingularField::some(v); - } - - // Mutable pointer to the field. - // If field is not initialized, it is initialized with default value first. - pub fn mut_help(&mut self) -> &mut ::std::string::String { - if self.help.is_none() { - self.help.set_default(); - } - self.help.as_mut().unwrap() - } - - // Take field - pub fn take_help(&mut self) -> ::std::string::String { - self.help.take().unwrap_or_else(|| ::std::string::String::new()) - } - - pub fn get_help(&self) -> &str { - match self.help.as_ref() { - Some(v) => &v, - None => "", - } - } - - // optional .io.prometheus.client.MetricType type = 3; - - pub fn clear_field_type(&mut self) { - self.field_type = ::std::option::Option::None; - } - - pub fn has_field_type(&self) -> bool { - self.field_type.is_some() - } - - // Param is passed by value, moved - pub fn set_field_type(&mut self, v: MetricType) { - self.field_type = ::std::option::Option::Some(v); - } - - pub fn get_field_type(&self) -> MetricType { - self.field_type.unwrap_or(MetricType::COUNTER) - } - - // repeated .io.prometheus.client.Metric metric = 4; - - pub fn clear_metric(&mut self) { - self.metric.clear(); - } - - // Param is passed by value, moved - pub fn set_metric(&mut self, v: ::protobuf::RepeatedField) { - self.metric = v; - } - - // Mutable pointer to the field. - pub fn mut_metric(&mut self) -> &mut ::protobuf::RepeatedField { - &mut self.metric - } - - // Take field - pub fn take_metric(&mut self) -> ::protobuf::RepeatedField { - ::std::mem::replace(&mut self.metric, ::protobuf::RepeatedField::new()) - } - - pub fn get_metric(&self) -> &[Metric] { - &self.metric - } -} - -impl ::protobuf::Message for MetricFamily { - fn is_initialized(&self) -> bool { - for v in &self.metric { - if !v.is_initialized() { - return false; - } - }; - true - } - - fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::ProtobufResult<()> { - while !is.eof()? { - let (field_number, wire_type) = is.read_tag_unpack()?; - match field_number { - 1 => { - ::protobuf::rt::read_singular_string_into(wire_type, is, &mut self.name)?; - }, - 2 => { - ::protobuf::rt::read_singular_string_into(wire_type, is, &mut self.help)?; - }, - 3 => { - ::protobuf::rt::read_proto2_enum_with_unknown_fields_into(wire_type, is, &mut self.field_type, 3, &mut self.unknown_fields)? - }, - 4 => { - ::protobuf::rt::read_repeated_message_into(wire_type, is, &mut self.metric)?; - }, - _ => { - ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; - }, - }; - } - ::std::result::Result::Ok(()) - } - - // Compute sizes of nested messages - #[allow(unused_variables)] - fn compute_size(&self) -> u32 { - let mut my_size = 0; - if let Some(ref v) = self.name.as_ref() { - my_size += ::protobuf::rt::string_size(1, &v); - } - if let Some(ref v) = self.help.as_ref() { - my_size += ::protobuf::rt::string_size(2, &v); - } - if let Some(v) = self.field_type { - my_size += ::protobuf::rt::enum_size(3, v); - } - for value in &self.metric { - let len = value.compute_size(); - my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; - }; - my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); - self.cached_size.set(my_size); - my_size - } - - fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::ProtobufResult<()> { - if let Some(ref v) = self.name.as_ref() { - os.write_string(1, &v)?; - } - if let Some(ref v) = self.help.as_ref() { - os.write_string(2, &v)?; - } - if let Some(v) = self.field_type { - os.write_enum(3, v.value())?; - } - for v in &self.metric { - os.write_tag(4, ::protobuf::wire_format::WireTypeLengthDelimited)?; - os.write_raw_varint32(v.get_cached_size())?; - v.write_to_with_cached_sizes(os)?; - }; - os.write_unknown_fields(self.get_unknown_fields())?; - ::std::result::Result::Ok(()) - } - - fn get_cached_size(&self) -> u32 { - self.cached_size.get() - } - - fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { - &self.unknown_fields - } - - fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { - &mut self.unknown_fields - } - - fn as_any(&self) -> &::std::any::Any { - self as &::std::any::Any - } - fn as_any_mut(&mut self) -> &mut ::std::any::Any { - self as &mut ::std::any::Any - } - fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { - self - } - - fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { - Self::descriptor_static() - } - - fn new() -> MetricFamily { - MetricFamily::new() - } - - fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { - static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, - }; - unsafe { - descriptor.get(|| { - let mut fields = ::std::vec::Vec::new(); - fields.push(::protobuf::reflect::accessor::make_singular_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( - "name", - |m: &MetricFamily| { &m.name }, - |m: &mut MetricFamily| { &mut m.name }, - )); - fields.push(::protobuf::reflect::accessor::make_singular_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( - "help", - |m: &MetricFamily| { &m.help }, - |m: &mut MetricFamily| { &mut m.help }, - )); - fields.push(::protobuf::reflect::accessor::make_option_accessor::<_, ::protobuf::types::ProtobufTypeEnum>( - "type", - |m: &MetricFamily| { &m.field_type }, - |m: &mut MetricFamily| { &mut m.field_type }, - )); - fields.push(::protobuf::reflect::accessor::make_repeated_field_accessor::<_, ::protobuf::types::ProtobufTypeMessage>( - "metric", - |m: &MetricFamily| { &m.metric }, - |m: &mut MetricFamily| { &mut m.metric }, - )); - ::protobuf::reflect::MessageDescriptor::new::( - "MetricFamily", - fields, - file_descriptor_proto() - ) - }) - } - } - - fn default_instance() -> &'static MetricFamily { - static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const MetricFamily, - }; - unsafe { - instance.get(MetricFamily::new) - } - } -} - -impl ::protobuf::Clear for MetricFamily { - fn clear(&mut self) { - self.clear_name(); - self.clear_help(); - self.clear_field_type(); - self.clear_metric(); - self.unknown_fields.clear(); - } -} - -impl ::std::fmt::Debug for MetricFamily { - fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { - ::protobuf::text_format::fmt(self, f) - } -} - -impl ::protobuf::reflect::ProtobufValue for MetricFamily { - fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef<'_> { - ::protobuf::reflect::ProtobufValueRef::Message(self) - } -} - -#[derive(Clone,PartialEq,Eq,Debug,Hash)] -pub enum MetricType { - COUNTER = 0, - GAUGE = 1, - SUMMARY = 2, - UNTYPED = 3, - HISTOGRAM = 4, -} - -impl ::protobuf::ProtobufEnum for MetricType { - fn value(&self) -> i32 { - *self as i32 - } - - fn from_i32(value: i32) -> ::std::option::Option { - match value { - 0 => ::std::option::Option::Some(MetricType::COUNTER), - 1 => ::std::option::Option::Some(MetricType::GAUGE), - 2 => ::std::option::Option::Some(MetricType::SUMMARY), - 3 => ::std::option::Option::Some(MetricType::UNTYPED), - 4 => ::std::option::Option::Some(MetricType::HISTOGRAM), - _ => ::std::option::Option::None - } - } - - fn values() -> &'static [Self] { - static values: &'static [MetricType] = &[ - MetricType::COUNTER, - MetricType::GAUGE, - MetricType::SUMMARY, - MetricType::UNTYPED, - MetricType::HISTOGRAM, - ]; - values - } - - fn enum_descriptor_static() -> &'static ::protobuf::reflect::EnumDescriptor { - static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::EnumDescriptor> = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const ::protobuf::reflect::EnumDescriptor, - }; - unsafe { - descriptor.get(|| { - ::protobuf::reflect::EnumDescriptor::new("MetricType", file_descriptor_proto()) - }) - } - } -} - -impl ::std::marker::Copy for MetricType { -} - -impl ::protobuf::reflect::ProtobufValue for MetricType { - fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef<'_> { - ::protobuf::reflect::ProtobufValueRef::Enum(self.descriptor()) - } -} - -static file_descriptor_proto_data: &'static [u8] = b"\ - \n\x11proto_model.proto\x12\x14io.prometheus.client\"0\n\tLabelPair\x12\ - \x10\n\x04name\x18\x01\x20\x01(\tB\x02\x18\0\x12\x11\n\x05value\x18\x02\ - \x20\x01(\tB\x02\x18\0\"\x1a\n\x05Gauge\x12\x11\n\x05value\x18\x01\x20\ - \x01(\x01B\x02\x18\0\"\x1c\n\x07Counter\x12\x11\n\x05value\x18\x01\x20\ - \x01(\x01B\x02\x18\0\"3\n\x08Quantile\x12\x14\n\x08quantile\x18\x01\x20\ - \x01(\x01B\x02\x18\0\x12\x11\n\x05value\x18\x02\x20\x01(\x01B\x02\x18\0\ - \"q\n\x07Summary\x12\x18\n\x0csample_count\x18\x01\x20\x01(\x04B\x02\x18\ - \0\x12\x16\n\nsample_sum\x18\x02\x20\x01(\x01B\x02\x18\0\x124\n\x08quant\ - ile\x18\x03\x20\x03(\x0b2\x1e.io.prometheus.client.QuantileB\x02\x18\0\"\ - \x1c\n\x07Untyped\x12\x11\n\x05value\x18\x01\x20\x01(\x01B\x02\x18\0\"o\ - \n\tHistogram\x12\x18\n\x0csample_count\x18\x01\x20\x01(\x04B\x02\x18\0\ - \x12\x16\n\nsample_sum\x18\x02\x20\x01(\x01B\x02\x18\0\x120\n\x06bucket\ - \x18\x03\x20\x03(\x0b2\x1c.io.prometheus.client.BucketB\x02\x18\0\"?\n\ - \x06Bucket\x12\x1c\n\x10cumulative_count\x18\x01\x20\x01(\x04B\x02\x18\0\ - \x12\x17\n\x0bupper_bound\x18\x02\x20\x01(\x01B\x02\x18\0\"\xda\x02\n\ - \x06Metric\x122\n\x05label\x18\x01\x20\x03(\x0b2\x1f.io.prometheus.clien\ - t.LabelPairB\x02\x18\0\x12.\n\x05gauge\x18\x02\x20\x01(\x0b2\x1b.io.prom\ - etheus.client.GaugeB\x02\x18\0\x122\n\x07counter\x18\x03\x20\x01(\x0b2\ - \x1d.io.prometheus.client.CounterB\x02\x18\0\x122\n\x07summary\x18\x04\ - \x20\x01(\x0b2\x1d.io.prometheus.client.SummaryB\x02\x18\0\x122\n\x07unt\ - yped\x18\x05\x20\x01(\x0b2\x1d.io.prometheus.client.UntypedB\x02\x18\0\ - \x126\n\thistogram\x18\x07\x20\x01(\x0b2\x1f.io.prometheus.client.Histog\ - ramB\x02\x18\0\x12\x18\n\x0ctimestamp_ms\x18\x06\x20\x01(\x03B\x02\x18\0\ - \"\x98\x01\n\x0cMetricFamily\x12\x10\n\x04name\x18\x01\x20\x01(\tB\x02\ - \x18\0\x12\x10\n\x04help\x18\x02\x20\x01(\tB\x02\x18\0\x122\n\x04type\ - \x18\x03\x20\x01(\x0e2\x20.io.prometheus.client.MetricTypeB\x02\x18\0\ - \x120\n\x06metric\x18\x04\x20\x03(\x0b2\x1c.io.prometheus.client.MetricB\ - \x02\x18\0*Q\n\nMetricType\x12\x0b\n\x07COUNTER\x10\0\x12\t\n\x05GAUGE\ - \x10\x01\x12\x0b\n\x07SUMMARY\x10\x02\x12\x0b\n\x07UNTYPED\x10\x03\x12\r\ - \n\tHISTOGRAM\x10\x04\x1a\x02\x10\0B\0b\x06proto2\ -"; - -static mut file_descriptor_proto_lazy: ::protobuf::lazy::Lazy<::protobuf::descriptor::FileDescriptorProto> = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const ::protobuf::descriptor::FileDescriptorProto, -}; - -fn parse_descriptor_proto() -> ::protobuf::descriptor::FileDescriptorProto { - ::protobuf::parse_from_bytes(file_descriptor_proto_data).unwrap() -} - -pub fn file_descriptor_proto() -> &'static ::protobuf::descriptor::FileDescriptorProto { - unsafe { - file_descriptor_proto_lazy.get(|| { - parse_descriptor_proto() - }) - } -} diff --git a/src/counter.rs b/src/counter.rs index 239e2982..681cfded 100644 --- a/src/counter.rs +++ b/src/counter.rs @@ -326,7 +326,7 @@ mod tests { use std::f64::EPSILON; use super::*; - use crate::metrics::{Collector, Opts}; + use crate::{metrics::{Collector, Opts}, GetType}; #[test] fn test_counter() { @@ -343,9 +343,9 @@ mod tests { assert_eq!(mfs.len(), 1); let mf = mfs.pop().unwrap(); - let m = mf.get_metric().get(0).unwrap(); - assert_eq!(m.get_label().len(), 2); - assert_eq!(m.get_counter().get_value() as u64, 43); + let m = mf.metric.get(0).unwrap(); + assert_eq!(m.label.len(), 2); + assert_eq!(m.get_counter().value as u64, 43); counter.reset(); assert_eq!(counter.get() as u64, 0); @@ -363,9 +363,9 @@ mod tests { assert_eq!(mfs.len(), 1); let mf = mfs.pop().unwrap(); - let m = mf.get_metric().get(0).unwrap(); - assert_eq!(m.get_label().len(), 0); - assert_eq!(m.get_counter().get_value() as u64, 12); + let m = mf.metric.get(0).unwrap(); + assert_eq!(m.label.len(), 0); + assert_eq!(m.get_counter().value as u64, 12); counter.reset(); assert_eq!(counter.get() as u64, 0); diff --git a/src/desc.rs b/src/desc.rs index f97b123d..e12916f9 100644 --- a/src/desc.rs +++ b/src/desc.rs @@ -175,8 +175,8 @@ impl Desc { for (key, value) in const_labels { let mut label_pair = LabelPair::default(); - label_pair.set_name(key); - label_pair.set_value(value); + label_pair.name = key; + label_pair.value = value; desc.const_label_pairs.push(label_pair); } diff --git a/src/encoder/mod.rs b/src/encoder/mod.rs index 47cacd5d..f120ad51 100644 --- a/src/encoder/mod.rs +++ b/src/encoder/mod.rs @@ -27,10 +27,10 @@ pub trait Encoder { } fn check_metric_family(mf: &MetricFamily) -> Result<()> { - if mf.get_metric().is_empty() { + if mf.metric.is_empty() { return Err(Error::Msg(format!("MetricFamily has no metrics: {:?}", mf))); } - if mf.get_name().is_empty() { + if mf.name.is_empty() { return Err(Error::Msg(format!("MetricFamily has no name: {:?}", mf))); } Ok(()) @@ -66,7 +66,7 @@ mod tests { let mut mfs = cv.collect(); // Empty name - (&mut mfs[0]).clear_name(); + (&mut mfs[0]).name = <_>::default(); check_metric_family(&mfs[0]).unwrap_err(); pb_encoder.encode(&mfs, &mut writer).unwrap_err(); assert_eq!(writer.len(), 0); @@ -93,7 +93,7 @@ mod tests { let mut mfs = cv.collect(); // Empty name - (&mut mfs[0]).clear_name(); + (&mut mfs[0]).name = <_>::default(); check_metric_family(&mfs[0]).unwrap_err(); text_encoder.encode(&mfs, &mut writer).unwrap_err(); assert_eq!(writer.len(), 0); diff --git a/src/encoder/text.rs b/src/encoder/text.rs index cd30ea74..b6bc652b 100644 --- a/src/encoder/text.rs +++ b/src/encoder/text.rs @@ -3,6 +3,7 @@ use std::borrow::Cow; use std::io::{self, Write}; +use crate::GetType; use crate::errors::Result; use crate::histogram::BUCKET_LABEL; use crate::proto::{self, MetricFamily, MetricType}; @@ -20,6 +21,7 @@ const QUANTILE: &str = "quantile"; #[derive(Debug, Default)] pub struct TextEncoder; + impl TextEncoder { /// Create a new text encoder. pub fn new() -> TextEncoder { @@ -55,46 +57,46 @@ impl TextEncoder { check_metric_family(mf)?; // Write `# HELP` header. - let name = mf.get_name(); - let help = mf.get_help(); + let name = &mf.name; + let help = &mf.help; if !help.is_empty() { writer.write_all("# HELP ")?; - writer.write_all(name)?; + writer.write_all(&name)?; writer.write_all(" ")?; - writer.write_all(&escape_string(help, false))?; + writer.write_all(&escape_string(&help, false))?; writer.write_all("\n")?; } // Write `# TYPE` header. - let metric_type = mf.get_field_type(); + let metric_type = mf.type_; let lowercase_type = format!("{:?}", metric_type).to_lowercase(); writer.write_all("# TYPE ")?; - writer.write_all(name)?; + writer.write_all(&name)?; writer.write_all(" ")?; writer.write_all(&lowercase_type)?; writer.write_all("\n")?; - for m in mf.get_metric() { - match metric_type { + for m in &mf.metric { + match metric_type.enum_value_or(MetricType::UNTYPED) { MetricType::COUNTER => { - write_sample(writer, name, None, m, None, m.get_counter().get_value())?; + write_sample(writer, &name, None, &m, None, m.get_counter().value)?; } MetricType::GAUGE => { - write_sample(writer, name, None, m, None, m.get_gauge().get_value())?; + write_sample(writer, &name, None, &m, None, m.get_gauge().value)?; } MetricType::HISTOGRAM => { let h = m.get_histogram(); let mut inf_seen = false; - for b in h.get_bucket() { - let upper_bound = b.get_upper_bound(); + for b in h.bucket { + let upper_bound = b.upper_bound; write_sample( writer, - name, + &name, Some("_bucket"), - m, + &m, Some((BUCKET_LABEL, &upper_bound.to_string())), - b.get_cumulative_count() as f64, + b.cumulative_count as f64, )?; if upper_bound.is_sign_positive() && upper_bound.is_infinite() { inf_seen = true; @@ -103,50 +105,53 @@ impl TextEncoder { if !inf_seen { write_sample( writer, - name, + &name, Some("_bucket"), - m, + &m, Some((BUCKET_LABEL, POSITIVE_INF)), - h.get_sample_count() as f64, + h.sample_count as f64, )?; } - write_sample(writer, name, Some("_sum"), m, None, h.get_sample_sum())?; + write_sample(writer, &name, Some("_sum"), &m, None, h.sample_sum)?; write_sample( writer, - name, + &name, Some("_count"), - m, + &m, None, - h.get_sample_count() as f64, + h.sample_count as f64, )?; } MetricType::SUMMARY => { let s = m.get_summary(); - for q in s.get_quantile() { + for q in s.quantile { write_sample( writer, - name, + &name, None, - m, - Some((QUANTILE, &q.get_quantile().to_string())), - q.get_value(), + &m, + Some((QUANTILE, &q.quantile.to_string())), + q.value, )?; } - write_sample(writer, name, Some("_sum"), m, None, s.get_sample_sum())?; + write_sample(writer, &name, Some("_sum"), &m, None, s.sample_sum)?; write_sample( writer, - name, + &name, Some("_count"), - m, + &m, None, - s.get_sample_count() as f64, + s.sample_count as f64, )?; } + MetricType::GAUGE_HISTOGRAM => { + unimplemented!(); + } MetricType::UNTYPED => { unimplemented!(); } @@ -186,12 +191,12 @@ fn write_sample( writer.write_all(postfix)?; } - label_pairs_to_text(mc.get_label(), additional_label, writer)?; + label_pairs_to_text(&mc.label, additional_label, writer)?; writer.write_all(" ")?; writer.write_all(&value.to_string())?; - let timestamp = mc.get_timestamp_ms(); + let timestamp = mc.timestamp_ms; if timestamp != 0 { writer.write_all(" ")?; writer.write_all(×tamp.to_string())?; @@ -221,9 +226,9 @@ fn label_pairs_to_text( let mut separator = "{"; for lp in pairs { writer.write_all(separator)?; - writer.write_all(lp.get_name())?; + writer.write_all(&lp.name)?; writer.write_all("=\"")?; - writer.write_all(&escape_string(lp.get_value(), true))?; + writer.write_all(&escape_string(&lp.value, true))?; writer.write_all("\"")?; separator = ","; @@ -310,6 +315,8 @@ impl WriteUtf8 for StringBuf<'_> { #[cfg(test)] mod tests { + use protobuf::MessageField; + use super::*; use crate::counter::Counter; use crate::gauge::Gauge; @@ -407,27 +414,27 @@ test_histogram_count{a="1"} 1 use std::str; let mut metric_family = MetricFamily::default(); - metric_family.set_name("test_summary".to_string()); - metric_family.set_help("This is a test summary statistic".to_string()); - metric_family.set_field_type(MetricType::SUMMARY); + metric_family.name = "test_summary".to_string(); + metric_family.help = "This is a test summary statistic".to_string(); + metric_family.type_ = MetricType::SUMMARY.into(); let mut summary = Summary::default(); - summary.set_sample_count(5.0 as u64); - summary.set_sample_sum(15.0); + summary.sample_count = 5.0 as u64; + summary.sample_sum = 15.0; let mut quantile1 = Quantile::default(); - quantile1.set_quantile(50.0); - quantile1.set_value(3.0); + quantile1.quantile = 50.0; + quantile1.value = 3.0; let mut quantile2 = Quantile::default(); - quantile2.set_quantile(100.0); - quantile2.set_value(5.0); + quantile2.quantile = 100.0; + quantile2.value = 5.0; - summary.set_quantile(from_vec!(vec!(quantile1, quantile2))); + summary.quantile = from_vec!(vec!(quantile1, quantile2)); let mut metric = Metric::default(); - metric.set_summary(summary); - metric_family.set_metric(from_vec!(vec!(metric))); + metric.summary = MessageField::some(summary); + metric_family.metric = from_vec!(vec!(metric)); let mut writer = Vec::::new(); let encoder = TextEncoder::new(); diff --git a/src/errors.rs b/src/errors.rs index d7298dd9..d55fdbad 100644 --- a/src/errors.rs +++ b/src/errors.rs @@ -25,7 +25,7 @@ pub enum Error { /// An error containing a [`protobuf::error::ProtobufError`]. #[cfg(feature = "protobuf")] #[error("Protobuf error: {0}")] - Protobuf(#[from] protobuf::error::ProtobufError), + Protobuf(#[from] protobuf::Error), } /// A specialized Result type for prometheus. diff --git a/src/gauge.rs b/src/gauge.rs index 83eba2b1..4df90344 100644 --- a/src/gauge.rs +++ b/src/gauge.rs @@ -165,7 +165,7 @@ mod tests { use std::collections::HashMap; use super::*; - use crate::metrics::{Collector, Opts}; + use crate::{metrics::{Collector, Opts}, GetType}; #[test] fn test_gauge() { @@ -188,9 +188,9 @@ mod tests { assert_eq!(mfs.len(), 1); let mf = mfs.pop().unwrap(); - let m = mf.get_metric().get(0).unwrap(); - assert_eq!(m.get_label().len(), 2); - assert_eq!(m.get_gauge().get_value() as u64, 42); + let m = mf.metric.get(0).unwrap(); + assert_eq!(m.label.len(), 2); + assert_eq!(m.get_gauge().value as u64, 42); } #[test] diff --git a/src/histogram.rs b/src/histogram.rs index 78480541..f74b330c 100644 --- a/src/histogram.rs +++ b/src/histogram.rs @@ -334,7 +334,7 @@ impl HistogramCore { check_bucket_label(name)?; } for pair in &desc.const_label_pairs { - check_bucket_label(pair.get_name())?; + check_bucket_label(&pair.name)?; } let label_pairs = make_label_pairs(&desc, label_values)?; @@ -434,8 +434,8 @@ impl HistogramCore { let cold_shard_sum = cold_shard.sum.swap(0.0, Ordering::AcqRel); let mut h = proto::Histogram::default(); - h.set_sample_sum(cold_shard_sum); - h.set_sample_count(overall_count); + h.sample_sum = cold_shard_sum; + h.sample_count = overall_count; let mut cumulative_count = 0; let mut buckets = Vec::with_capacity(self.upper_bounds.len()); @@ -449,11 +449,11 @@ impl HistogramCore { cumulative_count += cold_bucket_count; let mut b = proto::Bucket::default(); - b.set_cumulative_count(cumulative_count); - b.set_upper_bound(*upper_bound); + b.cumulative_count = cumulative_count; + b.upper_bound = *upper_bound; buckets.push(b); } - h.set_bucket(from_vec!(buckets)); + h.bucket = from_vec!(buckets); // Update the hot shard. hot_shard.count.inc_by(overall_count); @@ -751,10 +751,10 @@ impl Histogram { impl Metric for Histogram { fn metric(&self) -> proto::Metric { let mut m = proto::Metric::default(); - m.set_label(from_vec!(self.core.label_pairs.clone())); + m.label = from_vec!(self.core.label_pairs.clone()); let h = self.core.proto(); - m.set_histogram(h); + m.histogram = protobuf::MessageField::some(h); m } @@ -767,10 +767,10 @@ impl Collector for Histogram { fn collect(&self) -> Vec { let mut m = proto::MetricFamily::default(); - m.set_name(self.core.desc.fq_name.clone()); - m.set_help(self.core.desc.help.clone()); - m.set_field_type(proto::MetricType::HISTOGRAM); - m.set_metric(from_vec!(vec![self.metric()])); + m.name = self.core.desc.fq_name.clone(); + m.help = self.core.desc.help.clone(); + m.type_ = proto::MetricType::HISTOGRAM.into(); + m.metric = from_vec!(vec![self.metric()]); vec![m] } @@ -1212,6 +1212,7 @@ mod tests { use std::time::Duration; use super::*; + use crate::GetType; use crate::metrics::{Collector, Metric}; #[test] @@ -1237,12 +1238,12 @@ mod tests { assert_eq!(mfs.len(), 1); let mf = mfs.pop().unwrap(); - let m = mf.get_metric().get(0).unwrap(); - assert_eq!(m.get_label().len(), 2); + let m = mf.metric.get(0).unwrap(); + assert_eq!(m.label.len(), 2); let proto_histogram = m.get_histogram(); - assert_eq!(proto_histogram.get_sample_count(), 3); - assert!(proto_histogram.get_sample_sum() >= 1.5); - assert_eq!(proto_histogram.get_bucket().len(), DEFAULT_BUCKETS.len()); + assert_eq!(proto_histogram.sample_count, 3); + assert!(proto_histogram.sample_sum >= 1.5); + assert_eq!(proto_histogram.bucket.len(), DEFAULT_BUCKETS.len()); let buckets = vec![1.0, 2.0, 3.0]; let opts = HistogramOpts::new("test2", "test help").buckets(buckets.clone()); @@ -1251,17 +1252,19 @@ mod tests { assert_eq!(mfs.len(), 1); let mf = mfs.pop().unwrap(); - let m = mf.get_metric().get(0).unwrap(); - assert_eq!(m.get_label().len(), 0); + let m = mf.metric.get(0).unwrap(); + assert_eq!(m.label.len(), 0); let proto_histogram = m.get_histogram(); - assert_eq!(proto_histogram.get_sample_count(), 0); - assert!((proto_histogram.get_sample_sum() - 0.0) < EPSILON); - assert_eq!(proto_histogram.get_bucket().len(), buckets.len()) + assert_eq!(proto_histogram.sample_count, 0); + assert!((proto_histogram.sample_sum - 0.0) < EPSILON); + assert_eq!(proto_histogram.bucket.len(), buckets.len()) } #[test] #[cfg(feature = "nightly")] fn test_histogram_coarse_timer() { + use crate::GetType; + let opts = HistogramOpts::new("test1", "test help"); let histogram = Histogram::with_opts(opts).unwrap(); @@ -1284,10 +1287,10 @@ mod tests { assert_eq!(mfs.len(), 1); let mf = mfs.pop().unwrap(); - let m = mf.get_metric().get(0).unwrap(); + let m = mf.metric.get(0).unwrap(); let proto_histogram = m.get_histogram(); - assert_eq!(proto_histogram.get_sample_count(), 3); - assert!((proto_histogram.get_sample_sum() - 0.0) > EPSILON); + assert_eq!(proto_histogram.sample_count, 3); + assert!((proto_histogram.sample_sum - 0.0) > EPSILON); } #[test] @@ -1401,12 +1404,12 @@ mod tests { histogram.observe(1.0); let m = histogram.metric(); - assert_eq!(m.get_label().len(), labels.len()); + assert_eq!(m.label.len(), labels.len()); let proto_histogram = m.get_histogram(); - assert_eq!(proto_histogram.get_sample_count(), 1); - assert!((proto_histogram.get_sample_sum() - 1.0) < EPSILON); - assert_eq!(proto_histogram.get_bucket().len(), buckets.len()) + assert_eq!(proto_histogram.sample_count, 1); + assert!((proto_histogram.sample_sum - 1.0) < EPSILON); + assert_eq!(proto_histogram.bucket.len(), buckets.len()) } #[test] @@ -1420,8 +1423,8 @@ mod tests { let check = |count, sum| { let m = histogram.metric(); let proto_histogram = m.get_histogram(); - assert_eq!(proto_histogram.get_sample_count(), count); - assert!((proto_histogram.get_sample_sum() - sum) < EPSILON); + assert_eq!(proto_histogram.sample_count, count); + assert!((proto_histogram.sample_sum - sum) < EPSILON); }; local.observe(1.0); @@ -1453,10 +1456,10 @@ mod tests { local_vec.remove_label_values(&["v1", "v2"]).unwrap_err(); let check = |count, sum| { - let ms = vec.collect()[0].take_metric(); + let ms = vec.collect()[0].metric.clone(); let proto_histogram = ms[0].get_histogram(); - assert_eq!(proto_histogram.get_sample_count(), count); - assert!((proto_histogram.get_sample_sum() - sum) < EPSILON); + assert_eq!(proto_histogram.sample_count, count); + assert!((proto_histogram.sample_sum - sum) < EPSILON); }; { @@ -1510,13 +1513,13 @@ mod tests { let mut cumulative_count = 0; let mut sample_sum = 0; for _ in 0..1_000_000 { - let metric = &histogram.collect()[0].take_metric()[0]; + let metric = &histogram.collect()[0].metric[0]; let proto = metric.get_histogram(); - sample_count = proto.get_sample_count(); - sample_sum = proto.get_sample_sum() as u64; + sample_count = proto.sample_count; + sample_sum = proto.sample_sum as u64; // There is only one bucket thus the `[0]`. - cumulative_count = proto.get_bucket()[0].get_cumulative_count(); + cumulative_count = proto.bucket[0].cumulative_count; if sample_count != cumulative_count { break; diff --git a/src/lib.rs b/src/lib.rs index 23465bca..b4d407a3 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -126,16 +126,62 @@ This library supports four features: #[cfg(feature = "protobuf")] #[allow(warnings)] #[rustfmt::skip] -#[path = "../proto/proto_model.rs"] +#[path = "../proto/metrics.rs"] pub mod proto; +#[cfg(feature = "protobuf")] +#[allow(warnings)] +#[rustfmt::skip] +#[path = "../proto/gogo.rs"] +pub mod gogo; + #[cfg(feature = "protobuf")] macro_rules! from_vec { ($e: expr) => { - ::protobuf::RepeatedField::from_vec($e) + $e }; } +#[cfg(feature = "protobuf")] +trait GetType { + fn get_counter(&self) -> Box; + fn get_gauge(&self) -> Box; + fn get_histogram(&self) -> Box; + fn get_summary(&self) -> Box; +} + +#[cfg(feature = "protobuf")] +impl GetType for crate::proto::MetricFamily { + fn get_counter(&self) -> Box { + self.metric[0].get_counter() + } + fn get_gauge(&self) -> Box { + self.metric[0].get_gauge() + } + fn get_histogram(&self) -> Box { + self.metric[0].get_histogram() + } + fn get_summary(&self) -> Box { + self.metric[0].get_summary() + } +} + +#[cfg(feature = "protobuf")] +impl GetType for crate::proto::Metric { + fn get_counter(&self) -> Box { + self.counter.clone().0.expect("checked before call") + } + fn get_gauge(&self) -> Box { + self.gauge.clone().0.expect("checked before call") + } + fn get_histogram(&self) -> Box { + self.histogram.clone().0.expect("checked before call") + } + fn get_summary(&self) -> Box { + self.summary.clone().0.expect("checked before call") + } +} + #[cfg(not(feature = "protobuf"))] #[path = "plain_model.rs"] pub mod proto; diff --git a/src/metrics.rs b/src/metrics.rs index e3337b81..5ebcc801 100644 --- a/src/metrics.rs +++ b/src/metrics.rs @@ -177,7 +177,7 @@ impl Describer for Opts { impl Ord for LabelPair { fn cmp(&self, other: &LabelPair) -> Ordering { - self.get_name().cmp(other.get_name()) + self.name.cmp(&other.name) } } @@ -221,8 +221,8 @@ mod tests { fn new_label_pair(name: &str, value: &str) -> LabelPair { let mut l = LabelPair::default(); - l.set_name(name.to_owned()); - l.set_value(value.to_owned()); + l.name = name.to_owned(); + l.value = value.to_owned(); l } diff --git a/src/pulling_gauge.rs b/src/pulling_gauge.rs index feadac20..ab21a381 100644 --- a/src/pulling_gauge.rs +++ b/src/pulling_gauge.rs @@ -1,5 +1,7 @@ use std::{collections::HashMap, fmt, sync::Arc}; +use protobuf::MessageField; + use crate::{ core::Collector, proto::{Gauge, Metric, MetricFamily, MetricType}, @@ -56,10 +58,10 @@ impl PullingGauge { fn metric(&self) -> Metric { let mut gauge = Gauge::default(); let getter = &self.value; - gauge.set_value(getter()); + gauge.value = getter(); let mut metric = Metric::default(); - metric.set_gauge(gauge); + metric.gauge = MessageField::some(gauge); metric } @@ -72,10 +74,10 @@ impl Collector for PullingGauge { fn collect(&self) -> Vec { let mut m = MetricFamily::default(); - m.set_name(self.desc.fq_name.clone()); - m.set_help(self.desc.help.clone()); - m.set_field_type(MetricType::GAUGE); - m.set_metric(from_vec!(vec![self.metric()])); + m.name = self.desc.fq_name.clone(); + m.help = self.desc.help.clone(); + m.type_ = MetricType::GAUGE.into(); + m.metric = from_vec!(vec![self.metric()]); vec![m] } } @@ -83,7 +85,7 @@ impl Collector for PullingGauge { #[cfg(test)] mod tests { use super::*; - use crate::metrics::Collector; + use crate::{metrics::Collector, GetType}; #[test] fn test_pulling_gauge() { @@ -95,6 +97,6 @@ mod tests { let metrics = gauge.collect(); assert_eq!(metrics.len(), 1); - assert_eq!(VALUE, metrics[0].get_metric()[0].get_gauge().get_value()); + assert_eq!(VALUE, metrics[0].metric[0].get_gauge().value); } } diff --git a/src/push.rs b/src/push.rs index 5594aa7c..7f004cb7 100644 --- a/src/push.rs +++ b/src/push.rs @@ -125,21 +125,21 @@ fn push( for mf in mfs { // Check for pre-existing grouping labels: - for m in mf.get_metric() { - for lp in m.get_label() { - if lp.get_name() == LABEL_NAME_JOB { + for m in mf.metric.clone() { + for lp in m.label { + if lp.name == LABEL_NAME_JOB { return Err(Error::Msg(format!( "pushed metric {} already contains a \ job label", - mf.get_name() + mf.name ))); } - if grouping.contains_key(lp.get_name()) { + if grouping.contains_key(&lp.name) { return Err(Error::Msg(format!( "pushed metric {} already contains \ grouping label {}", - mf.get_name(), - lp.get_name() + mf.name, + lp.name ))); } } @@ -331,11 +331,11 @@ mod tests { for case in table { let mut l = proto::LabelPair::new(); - l.set_name(case.0.to_owned()); + l.name = case.0.to_owned(); let mut m = proto::Metric::new(); - m.set_label(from_vec!(vec![l])); + m.label = from_vec!(vec![l]); let mut mf = proto::MetricFamily::new(); - mf.set_metric(from_vec!(vec![m])); + mf.metric = from_vec!(vec![m]); let res = push_metrics("test", hostname_grouping_key(), "mockurl", vec![mf], None); assert!(format!("{}", res.unwrap_err()).contains(case.1)); } diff --git a/src/registry.rs b/src/registry.rs index a4be61f1..93d81b9a 100644 --- a/src/registry.rs +++ b/src/registry.rs @@ -121,24 +121,24 @@ impl RegistryCore { for c in self.collectors_by_id.values() { let mfs = c.collect(); - for mut mf in mfs { + for mf in mfs { // Prune empty MetricFamilies. - if mf.get_metric().is_empty() { + if mf.metric.is_empty() { continue; } - let name = mf.get_name().to_owned(); + let name = mf.name.to_owned(); match mf_by_name.entry(name) { BEntry::Vacant(entry) => { entry.insert(mf); } BEntry::Occupied(mut entry) => { let existent_mf = entry.get_mut(); - let existent_metrics = existent_mf.mut_metric(); + let existent_metrics = &mut existent_mf.metric; // TODO: check type. // TODO: check consistency. - for metric in mf.take_metric().into_iter() { + for metric in mf.metric.into_iter() { existent_metrics.push(metric); } } @@ -151,9 +151,9 @@ impl RegistryCore { // Now that MetricFamilies are all set, sort their Metrics // lexicographically by their label values. for mf in mf_by_name.values_mut() { - mf.mut_metric().sort_by(|m1, m2| { - let lps1 = m1.get_label(); - let lps2 = m2.get_label(); + (&mut mf.metric).sort_by(|m1, m2| { + let lps1 = &m1.label; + let lps2 = &m2.label; if lps1.len() != lps2.len() { // This should not happen. The metrics are @@ -166,8 +166,8 @@ impl RegistryCore { } for (lp1, lp2) in lps1.iter().zip(lps2.iter()) { - if lp1.get_value() != lp2.get_value() { - return lp1.get_value().cmp(lp2.get_value()); + if lp1.value != lp2.value { + return lp1.value.cmp(&lp2.value); } } @@ -177,7 +177,7 @@ impl RegistryCore { // here, even for inconsistent metrics. So sort equal metrics // by their timestamp, with missing timestamps (implying "now") // coming last. - m1.get_timestamp_ms().cmp(&m2.get_timestamp_ms()) + m1.timestamp_ms.cmp(&m2.timestamp_ms) }); } @@ -187,8 +187,8 @@ impl RegistryCore { .map(|(_, mut m)| { // Add registry namespace prefix, if any. if let Some(ref namespace) = self.prefix { - let prefixed = format!("{}_{}", namespace, m.get_name()); - m.set_name(prefixed); + let prefixed = format!("{}_{}", namespace, &m.name); + m.name = prefixed; } // Add registry common labels, if any. @@ -197,16 +197,16 @@ impl RegistryCore { .iter() .map(|(k, v)| { let mut label = proto::LabelPair::default(); - label.set_name(k.to_string()); - label.set_value(v.to_string()); + label.name = k.to_string(); + label.value = v.to_string(); label }) .collect(); - for metric in m.mut_metric().iter_mut() { - let mut labels: Vec<_> = metric.take_label().into(); + for metric in (&mut m.metric).iter_mut() { + let mut labels: Vec<_> = metric.label.clone().into(); labels.append(&mut pairs.clone()); - metric.set_label(labels.into()); + metric.label = labels.into(); } } m @@ -401,9 +401,9 @@ mod tests { let mfs = r.gather(); assert_eq!(mfs.len(), 3); - assert_eq!(mfs[0].get_name(), "test_2_counter"); - assert_eq!(mfs[1].get_name(), "test_a_counter"); - assert_eq!(mfs[2].get_name(), "test_b_counter"); + assert_eq!(mfs[0].name, "test_2_counter"); + assert_eq!(mfs[1].name, "test_a_counter"); + assert_eq!(mfs[2].name, "test_b_counter"); let r = Registry::new(); let opts = Opts::new("test", "test help") @@ -455,12 +455,13 @@ mod tests { let mfs = r.gather(); assert_eq!(mfs.len(), 1); - let ms = mfs[0].get_metric(); + let ms = mfs[0].metric.clone(); assert_eq!(ms.len(), 4); - assert_eq!(ms[0].get_counter().get_value() as u64, 2); - assert_eq!(ms[1].get_counter().get_value() as u64, 1); - assert_eq!(ms[2].get_counter().get_value() as u64, 3); - assert_eq!(ms[3].get_counter().get_value() as u64, 4); + use crate::GetType; + assert_eq!(ms[0].get_counter().value as u64, 2); + assert_eq!(ms[1].get_counter().value as u64, 1); + assert_eq!(ms[2].get_counter().value as u64, 3); + assert_eq!(ms[3].get_counter().value as u64, 4); } #[test] @@ -473,7 +474,7 @@ mod tests { let mfs = r.gather(); assert_eq!(mfs.len(), 1); - assert_eq!(mfs[0].get_name(), "common_prefix_test_a_counter"); + assert_eq!(mfs[0].name, "common_prefix_test_a_counter"); } #[test] @@ -493,19 +494,19 @@ mod tests { let mfs = r.gather(); assert_eq!(mfs.len(), 2); - assert_eq!(mfs[0].get_name(), "test_a_counter"); - assert_eq!(mfs[1].get_name(), "test_vec"); + assert_eq!(mfs[0].name, "test_a_counter"); + assert_eq!(mfs[1].name, "test_vec"); let mut needle = proto::LabelPair::default(); - needle.set_name("tkey".to_string()); - needle.set_value("tvalue".to_string()); - let metrics = mfs[0].get_metric(); + needle.name = "tkey".to_string(); + needle.value = "tvalue".to_string(); + let metrics = mfs[0].metric.clone(); for m in metrics { - assert!(m.get_label().contains(&needle)); + assert!(m.label.contains(&needle)); } - let metrics = mfs[1].get_metric(); + let metrics = mfs[1].metric.clone(); for m in metrics { - assert!(m.get_label().contains(&needle)); + assert!(m.label.contains(&needle)); } } diff --git a/src/value.rs b/src/value.rs index 87b2ede2..bf2fff05 100644 --- a/src/value.rs +++ b/src/value.rs @@ -1,6 +1,8 @@ // Copyright 2014 The Prometheus Authors // Copyright 2019 TiKV Project Authors. Licensed under Apache-2.0. +use protobuf::MessageField; + use crate::atomic64::{Atomic, Number}; use crate::desc::{Desc, Describer}; use crate::errors::{Error, Result}; @@ -86,19 +88,19 @@ impl Value

{ pub fn metric(&self) -> Metric { let mut m = Metric::default(); - m.set_label(from_vec!(self.label_pairs.clone())); + m.label = from_vec!(self.label_pairs.clone()); let val = self.get(); match self.val_type { ValueType::Counter => { let mut counter = Counter::default(); - counter.set_value(val.into_f64()); - m.set_counter(counter); + counter.value = val.into_f64(); + m.counter = MessageField::some(counter); } ValueType::Gauge => { let mut gauge = Gauge::default(); - gauge.set_value(val.into_f64()); - m.set_gauge(gauge); + gauge.value = val.into_f64(); + m.gauge = MessageField::some(gauge); } } @@ -107,10 +109,10 @@ impl Value

{ pub fn collect(&self) -> MetricFamily { let mut m = MetricFamily::default(); - m.set_name(self.desc.fq_name.clone()); - m.set_help(self.desc.help.clone()); - m.set_field_type(self.val_type.metric_type()); - m.set_metric(from_vec!(vec![self.metric()])); + m.name = self.desc.fq_name.clone(); + m.help = self.desc.help.clone(); + m.type_ = self.val_type.metric_type().into(); + m.metric = from_vec!(vec![self.metric()]); m } } @@ -135,8 +137,8 @@ pub fn make_label_pairs(desc: &Desc, label_values: &[&str]) -> Result { impl MetricVecCore { pub fn collect(&self) -> MetricFamily { let mut m = MetricFamily::default(); - m.set_name(self.desc.fq_name.clone()); - m.set_help(self.desc.help.clone()); - m.set_field_type(self.metric_type); + m.name = self.desc.fq_name.clone(); + m.help = self.desc.help.clone(); + m.type_ = self.metric_type.into(); let children = self.children.read(); let mut metrics = Vec::with_capacity(children.len()); for child in children.values() { metrics.push(child.metric()); } - m.set_metric(from_vec!(metrics)); + m.metric = from_vec!(metrics); m } @@ -425,10 +425,10 @@ mod tests { labels.insert("c", "a"); let c = vec.get_metric_with(&labels).unwrap(); let m = c.metric(); - let label_pairs = m.get_label(); + let label_pairs = m.label; assert_eq!(label_pairs.len(), labels.len()); for lp in label_pairs.iter() { - assert_eq!(lp.get_value(), labels[lp.get_name()]); + assert_eq!(lp.value, labels[lp.name.as_str()]); } } }