Skip to content

Commit cc8b868

Browse files
authored
oximeter: simplify histogram response. (#9366)
Simplify oximeter histogram responses to show the estimates for each quantile, rather than details of the P² algorithm. Part of #9345. Notes: * If we're only showing the quantile estimates and not other details of the algorithm, we could also simplify our clickhouse queries for histograms. We can add this here, or get to it separately later on. * This is technically a breaking change, in the event that customers are using quantile fields in histograms—although I'm inclined to doubt they are, because I don't think we document how to use those fields. Not sure if this is a problem, but wanted to note it.
1 parent b7eb043 commit cc8b868

File tree

2 files changed

+29
-30
lines changed

2 files changed

+29
-30
lines changed

openapi/nexus.json

Lines changed: 12 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -18226,27 +18226,18 @@
1822618226
},
1822718227
"p50": {
1822818228
"nullable": true,
18229-
"allOf": [
18230-
{
18231-
"$ref": "#/components/schemas/Quantile"
18232-
}
18233-
]
18229+
"type": "number",
18230+
"format": "double"
1823418231
},
1823518232
"p90": {
1823618233
"nullable": true,
18237-
"allOf": [
18238-
{
18239-
"$ref": "#/components/schemas/Quantile"
18240-
}
18241-
]
18234+
"type": "number",
18235+
"format": "double"
1824218236
},
1824318237
"p99": {
1824418238
"nullable": true,
18245-
"allOf": [
18246-
{
18247-
"$ref": "#/components/schemas/Quantile"
18248-
}
18249-
]
18239+
"type": "number",
18240+
"format": "double"
1825018241
},
1825118242
"squared_mean": {
1825218243
"type": "number",
@@ -18295,27 +18286,18 @@
1829518286
},
1829618287
"p50": {
1829718288
"nullable": true,
18298-
"allOf": [
18299-
{
18300-
"$ref": "#/components/schemas/Quantile"
18301-
}
18302-
]
18289+
"type": "number",
18290+
"format": "double"
1830318291
},
1830418292
"p90": {
1830518293
"nullable": true,
18306-
"allOf": [
18307-
{
18308-
"$ref": "#/components/schemas/Quantile"
18309-
}
18310-
]
18294+
"type": "number",
18295+
"format": "double"
1831118296
},
1831218297
"p99": {
1831318298
"nullable": true,
18314-
"allOf": [
18315-
{
18316-
"$ref": "#/components/schemas/Quantile"
18317-
}
18318-
]
18299+
"type": "number",
18300+
"format": "double"
1831918301
},
1832018302
"squared_mean": {
1832118303
"type": "number",

oximeter/oxql-types/src/point.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1670,11 +1670,28 @@ pub struct Distribution<T: DistributionSupport> {
16701670
max: Option<T>,
16711671
sum_of_samples: T,
16721672
squared_mean: f64,
1673+
#[serde(serialize_with = "serialize_quantile")]
1674+
#[schemars(with = "Option<f64>")]
16731675
p50: Option<Quantile>,
1676+
#[serde(serialize_with = "serialize_quantile")]
1677+
#[schemars(with = "Option<f64>")]
16741678
p90: Option<Quantile>,
1679+
#[serde(serialize_with = "serialize_quantile")]
1680+
#[schemars(with = "Option<f64>")]
16751681
p99: Option<Quantile>,
16761682
}
16771683

1684+
/// Simplify quantiles to an estimate to abstract the details of the algorithm from the user.
1685+
fn serialize_quantile<S>(
1686+
q: &Option<Quantile>,
1687+
serializer: S,
1688+
) -> Result<S::Ok, S::Error>
1689+
where
1690+
S: serde::Serializer,
1691+
{
1692+
q.and_then(|quantile| quantile.estimate().ok()).serialize(serializer)
1693+
}
1694+
16781695
impl<T> fmt::Display for Distribution<T>
16791696
where
16801697
T: DistributionSupport + HistogramSupport + Sub<Output = T>,

0 commit comments

Comments
 (0)