Skip to content

armgit / sie

Public Imported from GitHub
0

Open-source inference server and production cluster for all the models your agent needs.

fix(telemetry): raise the sidecar NATS series budget for the deadline reason (#428)

svonavadb02e2196760
diff --git a/packages/sie_server_sidecar/src/observability/metrics.rs b/packages/sie_server_sidecar/src/observability/metrics.rs
index 61ae7d760..4e85a6d6f 100644
--- a/packages/sie_server_sidecar/src/observability/metrics.rs
+++ b/packages/sie_server_sidecar/src/observability/metrics.rs
@@ -86,7 +86,7 @@ const CONFIG_OPERATION_SERIES: usize = 6;
const CONFIG_OUTCOME_SERIES: usize = 18;
const NATS_OPERATION_SERIES: usize = 7;
const BINARY_OUTCOME_SERIES: usize = 3;
-const NATS_REASON_SERIES: usize = 11;
+const NATS_REASON_SERIES: usize = 12;
const DELIVERY_REDELIVERED_SERIES: usize = 2;
const RESULT_TRANSPORT_MODE_SERIES: usize = 4;
const RESULT_TRANSPORT_OUTCOME_SERIES: usize = 4;
@@ -2687,6 +2687,8 @@ mod tests {
assert_eq!(SIDECAR_WORK_ITEM_AGE_CARDINALITY_LIMIT, 7);
assert_eq!(SIDECAR_WORK_ITEM_DEADLINE_CARDINALITY_LIMIT, 7 * 3);
assert_eq!(SIDECAR_BATCH_FILL_CARDINALITY_LIMIT, 7 * 257 * 8);
+ // Operation, outcome and reason; `deadline_exceeded` is the twelfth reason.
+ assert_eq!(SIDECAR_NATS_CARDINALITY_LIMIT, 7 * 3 * 12);
assert_eq!(SIDECAR_IPC_RESPONSE_CHUNK_CARDINALITY_LIMIT, 3);
assert_eq!(SIDECAR_RESULT_TRANSPORT_CARDINALITY_LIMIT, 4 * 4);
assert_eq!(SIDECAR_GENERATION_LOADING_CARDINALITY_LIMIT, 257 * 4 * 4);
@@ -2737,6 +2739,37 @@ mod tests {
"unknown-state",
];
let loading_outcomes = ["success", "ack_error", "publish_error", "unknown-outcome"];
+ let nats_operations = [
+ "receive",
+ "ack",
+ "nak",
+ "progress",
+ "fetch",
+ "stream",
+ "unknown-operation",
+ ];
+ let nats_outcomes = ["success", "error", "unknown-outcome"];
+ let nats_reasons = [
+ "none",
+ "completed",
+ "retry",
+ "pool_not_assigned",
+ "model_unsupported",
+ "first_delivery",
+ "redelivery",
+ "metadata_unavailable",
+ "transport",
+ "stream_ended",
+ "deadline_exceeded",
+ "unknown-reason",
+ ];
+ for operation in nats_operations {
+ for outcome in nats_outcomes {
+ for reason in nats_reasons {
+ telemetry.nats_operation(operation, outcome, reason, 1);
+ }
+ }
+ }
for model in models.iter().map(String::as_str).chain(["unknown/model"]) {
for operation in operations {
for flush_reason in flush_reasons {
@@ -2787,6 +2820,18 @@ mod tests {
assert!(sum.data_points().all(|point| point
.attributes()
.all(|attribute| attribute.key.as_str() != "otel.metric.overflow")));
+
+ let nats = exported
+ .iter()
+ .find(|metric| metric.name() == NATS_OPERATIONS_METRIC_NAME)
+ .expect("nats operations");
+ let AggregatedMetrics::U64(MetricData::Sum(sum)) = nats.data() else {
+ panic!("nats operations must be a u64 sum")
+ };
+ assert_eq!(sum.data_points().count(), SIDECAR_NATS_CARDINALITY_LIMIT);
+ assert!(sum.data_points().all(|point| point
+ .attributes()
+ .all(|attribute| attribute.key.as_str() != "otel.metric.overflow")));
}
#[test]
diff --git a/telemetry/contract.yaml b/telemetry/contract.yaml
index 9d64df8ae..d5e6c77a7 100644
--- a/telemetry/contract.yaml
+++ b/telemetry/contract.yaml
@@ -304,7 +304,7 @@ cardinality_budgets:
nats:
metrics: [sie.worker.nats.operations]
formula: nats_operation * binary_outcome * nats_reason
- limit: 231
+ limit: 252
nats_delivery:
metrics: [sie.worker.nats.delivery.attempts]
formula: delivery_redelivered
diff --git a/tools/ci/tests/test_telemetry_cardinality_budgets.py b/tools/ci/tests/test_telemetry_cardinality_budgets.py
new file mode 100644
index 000000000..05ae8e78c
--- /dev/null
+++ b/tools/ci/tests/test_telemetry_cardinality_budgets.py
@@ -0,0 +1,50 @@
+"""Every telemetry cardinality budget's limit equals the product of its formula's factors."""
+
+from __future__ import annotations
+
+import math
+from pathlib import Path
+
+import pytest
+import yaml
+
+ROOT = Path(__file__).resolve().parents[3]
+CONTRACT = yaml.safe_load((ROOT / "telemetry/contract.yaml").read_text())
+BUDGETS = CONTRACT["cardinality_budgets"]
+LIMITS = [
+ pytest.param(budget_name, group, id=f"{budget_name}.{group}")
+ for budget_name, budget in BUDGETS.items()
+ for group in budget.get("instrument_limits") or {}
+]
+
+
+def factor(budget: dict, token: str) -> int:
+ """Resolve one formula factor to its series count.
+
+ ``<name>_series_pairs`` is the ``total_series_pairs`` of the budget's
+ ``<name>_model_profile_pairs`` block. Any other factor is a fixed domain:
+ an integer, or the name of a contract enum whose size is the factor.
+ """
+ if token.endswith("_series_pairs"):
+ pairs = budget.get(token.removesuffix("_series_pairs") + "_model_profile_pairs")
+ assert pairs is not None, f"formula factor {token!r} has no model/profile pair block"
+ return pairs["total_series_pairs"]
+ domains = budget.get("fixed_domains") or {}
+ assert token in domains, f"formula factor {token!r} is not a fixed domain"
+ domain = domains[token]
+ if isinstance(domain, int):
+ return domain
+ assert domain in CONTRACT["enums"], f"fixed domain {token!r} names unknown enum {domain!r}"
+ return len(CONTRACT["enums"][domain])
+
+
+def test_budgets_declare_instrument_limits() -> None:
+ assert LIMITS
+
+
[email protected](("budget_name", "group"), LIMITS)
+def test_instrument_limit_equals_its_formula(budget_name: str, group: str) -> None:
+ budget = BUDGETS[budget_name]
+ declared = budget["instrument_limits"][group]
+ tokens = [token.strip() for token in declared["formula"].split("*")]
+ assert declared["limit"] == math.prod(factor(budget, token) for token in tokens), declared["formula"]