From 4c650568560536e1d1d9cf6645b578274573d403 Mon Sep 17 00:00:00 2001 From: Olivier 'reivilibre Date: Thu, 25 Nov 2021 09:08:43 +0000 Subject: [PATCH] Some structure changes --- bare-metrics-core/src/structures.rs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/bare-metrics-core/src/structures.rs b/bare-metrics-core/src/structures.rs index 1b699dd..0ae07a8 100644 --- a/bare-metrics-core/src/structures.rs +++ b/bare-metrics-core/src/structures.rs @@ -5,19 +5,24 @@ use hdrhistogram::Histogram; use serde::de::Error; use serde::{Deserialize, Deserializer, Serialize, Serializer}; use serde_bare::Uint; -use std::collections::HashMap; +use std::collections::{BTreeMap, HashMap}; pub fn get_supported_version() -> String { format!("bare-metrics:{}", env!("CARGO_PKG_VERSION")) } +#[derive( + Copy, Clone, Debug, Ord, PartialOrd, Eq, PartialEq, Hash, Serialize, Deserialize, Default, +)] +pub struct UnixTimestampMilliseconds(pub u64); + /// Header for a metric log file. #[derive(Serialize, Deserialize, Clone, Debug, Default)] pub struct LogHeader { /// String describing the version of this metrics log file. pub bare_metrics_version: String, /// Unix timestamp (milliseconds) describing the start of the metrics. - pub start_time_ms: u64, + pub start_time: UnixTimestampMilliseconds, } /// A single frame of metrics. @@ -26,7 +31,7 @@ pub struct LogHeader { #[derive(Serialize, Deserialize, Clone, Debug, Default)] pub struct Frame { /// Unix timestamp (milliseconds) describing the end of this frame of metrics. - pub end_time_ms: u64, + pub end_time: UnixTimestampMilliseconds, /// Absolute values of updated gauges. pub gauge_updates: HashMap, /// Absolute values of updated counters. @@ -53,6 +58,8 @@ pub struct MetricDescriptor { pub kind: MetricKind, pub unit: Option, pub description: String, + pub name: String, + pub labels: BTreeMap, } #[derive(Clone, Debug)]