feat: disable prometheus protobuf (#2578)
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>pull/24376/head
parent
f62d0eab3c
commit
e96aa49390
metric_exporters
|
@ -3189,7 +3189,6 @@ dependencies = [
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
"memchr",
|
"memchr",
|
||||||
"parking_lot",
|
"parking_lot",
|
||||||
"protobuf",
|
|
||||||
"thiserror",
|
"thiserror",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -3244,12 +3243,6 @@ dependencies = [
|
||||||
"prost",
|
"prost",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "protobuf"
|
|
||||||
version = "2.25.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "23129d50f2c9355ced935fce8a08bd706ee2e7ce2b3b33bf61dace0e379ac63a"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "query"
|
name = "query"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
|
|
|
@ -8,7 +8,7 @@ edition = "2018"
|
||||||
|
|
||||||
observability_deps = { path = "../observability_deps" }
|
observability_deps = { path = "../observability_deps" }
|
||||||
metric = { path = "../metric" }
|
metric = { path = "../metric" }
|
||||||
prometheus = "0.12"
|
prometheus = { version = "0.12", default-features = false }
|
||||||
|
|
||||||
[dev-dependencies] # In alphabetical order
|
[dev-dependencies] # In alphabetical order
|
||||||
test_helpers = { path = "../test_helpers" }
|
test_helpers = { path = "../test_helpers" }
|
||||||
|
|
|
@ -69,7 +69,7 @@ impl<'a, W: Write> metric::Reporter for PrometheusTextEncoder<'a, W> {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut metric = MetricFamily::new();
|
let mut metric = MetricFamily::default();
|
||||||
metric.set_name(name);
|
metric.set_name(name);
|
||||||
metric.set_help(description.to_string());
|
metric.set_help(description.to_string());
|
||||||
metric.set_field_type(metric_type);
|
metric.set_field_type(metric_type);
|
||||||
|
@ -82,75 +82,90 @@ impl<'a, W: Write> metric::Reporter for PrometheusTextEncoder<'a, W> {
|
||||||
|
|
||||||
let metrics = metrics.mut_metric();
|
let metrics = metrics.mut_metric();
|
||||||
|
|
||||||
let mut metric = Metric::new();
|
let mut metric = Metric::default();
|
||||||
|
|
||||||
for (name, value) in attributes.iter() {
|
metric.set_label(
|
||||||
let mut pair = LabelPair::new();
|
attributes
|
||||||
pair.set_name(name.to_string());
|
.iter()
|
||||||
pair.set_value(value.to_string());
|
.map(|(name, value)| {
|
||||||
metric.mut_label().push(pair)
|
let mut pair = LabelPair::default();
|
||||||
}
|
pair.set_name(name.to_string());
|
||||||
|
pair.set_value(value.to_string());
|
||||||
|
pair
|
||||||
|
})
|
||||||
|
.collect(),
|
||||||
|
);
|
||||||
|
|
||||||
match observation {
|
match observation {
|
||||||
Observation::U64Counter(v) => {
|
Observation::U64Counter(v) => {
|
||||||
let mut counter = Counter::new();
|
let mut counter = Counter::default();
|
||||||
counter.set_value(v as f64);
|
counter.set_value(v as f64);
|
||||||
metric.set_counter(counter)
|
metric.set_counter(counter)
|
||||||
}
|
}
|
||||||
Observation::U64Gauge(v) => {
|
Observation::U64Gauge(v) => {
|
||||||
let mut gauge = Gauge::new();
|
let mut gauge = Gauge::default();
|
||||||
gauge.set_value(v as f64);
|
gauge.set_value(v as f64);
|
||||||
metric.set_gauge(gauge)
|
metric.set_gauge(gauge)
|
||||||
}
|
}
|
||||||
Observation::DurationCounter(v) => {
|
Observation::DurationCounter(v) => {
|
||||||
let mut counter = Counter::new();
|
let mut counter = Counter::default();
|
||||||
counter.set_value(v.as_secs_f64());
|
counter.set_value(v.as_secs_f64());
|
||||||
metric.set_counter(counter)
|
metric.set_counter(counter)
|
||||||
}
|
}
|
||||||
Observation::DurationGauge(v) => {
|
Observation::DurationGauge(v) => {
|
||||||
let mut gauge = Gauge::new();
|
let mut gauge = Gauge::default();
|
||||||
gauge.set_value(v.as_secs_f64());
|
gauge.set_value(v.as_secs_f64());
|
||||||
metric.set_gauge(gauge)
|
metric.set_gauge(gauge)
|
||||||
}
|
}
|
||||||
Observation::U64Histogram(v) => {
|
Observation::U64Histogram(v) => {
|
||||||
let mut histogram = Histogram::new();
|
let mut histogram = Histogram::default();
|
||||||
let mut cumulative_count = 0;
|
let mut cumulative_count = 0;
|
||||||
|
|
||||||
for observation in v.buckets {
|
histogram.set_bucket(
|
||||||
cumulative_count += observation.count;
|
v.buckets
|
||||||
|
.into_iter()
|
||||||
|
.map(|observation| {
|
||||||
|
cumulative_count += observation.count;
|
||||||
|
|
||||||
let mut bucket = Bucket::new();
|
let mut bucket = Bucket::default();
|
||||||
let le = match observation.le {
|
let le = match observation.le {
|
||||||
u64::MAX => f64::INFINITY,
|
u64::MAX => f64::INFINITY,
|
||||||
v => v as f64,
|
v => v as f64,
|
||||||
};
|
};
|
||||||
|
|
||||||
bucket.set_upper_bound(le);
|
bucket.set_upper_bound(le);
|
||||||
bucket.set_cumulative_count(cumulative_count);
|
bucket.set_cumulative_count(cumulative_count);
|
||||||
histogram.mut_bucket().push(bucket)
|
bucket
|
||||||
}
|
})
|
||||||
|
.collect(),
|
||||||
|
);
|
||||||
|
|
||||||
histogram.set_sample_count(cumulative_count);
|
histogram.set_sample_count(cumulative_count);
|
||||||
histogram.set_sample_sum(v.total as f64);
|
histogram.set_sample_sum(v.total as f64);
|
||||||
metric.set_histogram(histogram)
|
metric.set_histogram(histogram)
|
||||||
}
|
}
|
||||||
Observation::DurationHistogram(v) => {
|
Observation::DurationHistogram(v) => {
|
||||||
let mut histogram = Histogram::new();
|
let mut histogram = Histogram::default();
|
||||||
let mut cumulative_count = 0;
|
let mut cumulative_count = 0;
|
||||||
|
|
||||||
for observation in v.buckets {
|
histogram.set_bucket(
|
||||||
cumulative_count += observation.count;
|
v.buckets
|
||||||
|
.into_iter()
|
||||||
|
.map(|observation| {
|
||||||
|
cumulative_count += observation.count;
|
||||||
|
|
||||||
let mut bucket = Bucket::new();
|
let mut bucket = Bucket::default();
|
||||||
let le = match observation.le {
|
let le = match observation.le {
|
||||||
metric::DURATION_MAX => f64::INFINITY,
|
metric::DURATION_MAX => f64::INFINITY,
|
||||||
v => v.as_secs_f64(),
|
v => v.as_secs_f64(),
|
||||||
};
|
};
|
||||||
|
|
||||||
bucket.set_upper_bound(le);
|
bucket.set_upper_bound(le);
|
||||||
bucket.set_cumulative_count(cumulative_count);
|
bucket.set_cumulative_count(cumulative_count);
|
||||||
histogram.mut_bucket().push(bucket)
|
bucket
|
||||||
}
|
})
|
||||||
|
.collect(),
|
||||||
|
);
|
||||||
|
|
||||||
histogram.set_sample_count(cumulative_count);
|
histogram.set_sample_count(cumulative_count);
|
||||||
histogram.set_sample_sum(v.total.as_secs_f64());
|
histogram.set_sample_sum(v.total.as_secs_f64());
|
||||||
|
|
Loading…
Reference in New Issue