Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 12 additions & 30 deletions openapi/nexus.json
Original file line number Diff line number Diff line change
Expand Up @@ -18226,27 +18226,18 @@
},
"p50": {
"nullable": true,
"allOf": [
{
"$ref": "#/components/schemas/Quantile"
}
]
"type": "number",
"format": "double"
},
"p90": {
"nullable": true,
"allOf": [
{
"$ref": "#/components/schemas/Quantile"
}
]
"type": "number",
"format": "double"
},
"p99": {
"nullable": true,
"allOf": [
{
"$ref": "#/components/schemas/Quantile"
}
]
"type": "number",
"format": "double"
},
"squared_mean": {
"type": "number",
Expand Down Expand Up @@ -18295,27 +18286,18 @@
},
"p50": {
"nullable": true,
"allOf": [
{
"$ref": "#/components/schemas/Quantile"
}
]
"type": "number",
"format": "double"
},
"p90": {
"nullable": true,
"allOf": [
{
"$ref": "#/components/schemas/Quantile"
}
]
"type": "number",
"format": "double"
},
"p99": {
"nullable": true,
"allOf": [
{
"$ref": "#/components/schemas/Quantile"
}
]
"type": "number",
"format": "double"
},
"squared_mean": {
"type": "number",
Expand Down
17 changes: 17 additions & 0 deletions oximeter/oxql-types/src/point.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1670,11 +1670,28 @@ pub struct Distribution<T: DistributionSupport> {
max: Option<T>,
sum_of_samples: T,
squared_mean: f64,
#[serde(serialize_with = "serialize_quantile")]
#[schemars(with = "Option<f64>")]
p50: Option<Quantile>,
#[serde(serialize_with = "serialize_quantile")]
#[schemars(with = "Option<f64>")]
p90: Option<Quantile>,
#[serde(serialize_with = "serialize_quantile")]
#[schemars(with = "Option<f64>")]
p99: Option<Quantile>,
}

/// Simplify quantiles to an estimate to abstract the details of the algorithm from the user.
fn serialize_quantile<S>(
q: &Option<Quantile>,
serializer: S,
) -> Result<S::Ok, S::Error>
where
S: serde::Serializer,
{
q.and_then(|quantile| quantile.estimate().ok()).serialize(serializer)
}

impl<T> fmt::Display for Distribution<T>
where
T: DistributionSupport + HistogramSupport + Sub<Output = T>,
Expand Down
Loading