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): preserve long finite lifecycle durations (#407)

Attila László Nagy0edcfb373eaa
diff --git a/deploy/helm/sie-cluster/templates/_otel-collector-config.tpl b/deploy/helm/sie-cluster/templates/_otel-collector-config.tpl
index b7fc83619..db65316d8 100644
--- a/deploy/helm/sie-cluster/templates/_otel-collector-config.tpl
+++ b/deploy/helm/sie-cluster/templates/_otel-collector-config.tpl
@@ -595,7 +595,8 @@ processors:
- 'attributes["outcome"] != "success" and attributes["outcome"] != "rejected" and attributes["outcome"] != "error" and attributes["outcome"] != "cancelled"'
- 'attributes["error_class"] != "none" and attributes["error_class"] != "client_error" and attributes["error_class"] != "server_error" and attributes["error_class"] != "transport" and attributes["error_class"] != "timeout" and attributes["error_class"] != "worker" and attributes["error_class"] != "cancelled" and attributes["error_class"] != "protocol" and attributes["error_class"] != "other"'
- 'not IsDouble(attributes["duration_ms"]) and not IsInt(attributes["duration_ms"])'
- - 'attributes["duration_ms"] != attributes["duration_ms"] or attributes["duration_ms"] < 0 or attributes["duration_ms"] > 86400000'
+ # Collector 0.119 has no IsFinite: x - x is zero only for finite numeric values.
+ - 'attributes["duration_ms"] != attributes["duration_ms"] or attributes["duration_ms"] < 0 or attributes["duration_ms"] - attributes["duration_ms"] != 0'
- 'attributes["first_token_ms"] != nil and not IsDouble(attributes["first_token_ms"]) and not IsInt(attributes["first_token_ms"])'
- 'attributes["first_token_ms"] != nil and (attributes["first_token_ms"] != attributes["first_token_ms"] or attributes["first_token_ms"] < 0 or attributes["first_token_ms"] > attributes["duration_ms"])'
filter/gateway_lifecycle_logs:
diff --git a/telemetry/README.md b/telemetry/README.md
index c648fce18..93483f9d0 100644
--- a/telemetry/README.md
+++ b/telemetry/README.md
@@ -109,8 +109,10 @@ classified without exporting their text or automatic exception events.
phase, operation, outcome, bounded error class, duration, optional first-content
timing, and structural trace/span IDs. Each phase emits once; no raw stdout or
logging bridge is enabled. Service/phase pairs and exact numeric/string types
-are rechecked by the collector. Cancellation and rejection leave structural
-status UNSET; their safe record carries the distinction.
+are rechecked by the collector. Durations must be finite and nonnegative; they
+have no 24-hour ceiling. First-content timing must not exceed phase duration.
+Cancellation and rejection leave structural status UNSET; their safe record
+carries the distinction.
**Retention is sampled and best effort.** Lifecycle logs require a valid sampled
span context and the enabled safe-log exporter. They follow the enclosing head
diff --git a/telemetry/contract.yaml b/telemetry/contract.yaml
index b18a1d7df..e01e7b5e2 100644
--- a/telemetry/contract.yaml
+++ b/telemetry/contract.yaml
@@ -2657,7 +2657,7 @@ logs:
operation: operation
outcome: lifecycle_outcome
error_class: lifecycle_error_class
- duration_ms: nonnegative_phase_duration_ms
+ duration_ms: finite_nonnegative_phase_duration_ms
first_token_ms: optional_nonnegative_first_content_delta_ms_from_phase_start
correlation: [trace_id, span_id]
export: [otlp]
diff --git a/tools/ci/tests/test_collector_lifecycle_privacy.py b/tools/ci/tests/test_collector_lifecycle_privacy.py
index 24ba0af20..058520b05 100644
--- a/tools/ci/tests/test_collector_lifecycle_privacy.py
+++ b/tools/ci/tests/test_collector_lifecycle_privacy.py
@@ -179,6 +179,20 @@ def test_lifecycle_allowlist_in_real_collector(tmp_path):
send("untrusted-claimed-name", "response_body")
send("sie-worker", "worker_generation", application=True)
send("sie-dispatcher", "dispatch_attempt", application=True)
+ # Valid elapsed times have no daily ceiling. Preserve both numeric
+ # types, very large finite doubles, and zero at each receiver boundary.
+ long_timings = [(86400001, 86400000), (86400001.5, 86400000.5), (1e300, 1e299), (0.0, 0.0)]
+ for duration, first_token in long_timings:
+ for service, phase, application in [
+ ("sie-gateway", "response_body", False),
+ ("sie-worker", "worker_generation", True),
+ ]:
+ send(
+ service,
+ phase,
+ application=application,
+ changes={"duration_ms": duration, "first_token_ms": first_token},
+ )
# Malformed protobuf can repeat a key: filters read the first value,
# while keep_keys alone retains both. Rebuild the validated scalars.
duplicate = ExportLogsServiceRequest()
@@ -264,7 +278,11 @@ def test_lifecycle_allowlist_in_real_collector(tmp_path):
{"duration_ms": "payload-secret"},
{"duration_ms": -1},
{"duration_ms": float("nan")},
+ {"duration_ms": float("inf")},
+ {"duration_ms": float("-inf")},
{"first_token_ms": float("nan")},
+ {"first_token_ms": float("inf")},
+ {"first_token_ms": float("-inf")},
{"first_token_ms": "payload-secret"},
{"first_token_ms": 100},
{"event.schema.version": "2"},
@@ -305,10 +323,19 @@ def test_lifecycle_allowlist_in_real_collector(tmp_path):
completions.append(attrs)
else:
records.append((resource["service.name"], attrs))
- if len(records) + len(completions) >= 6:
+ if len(records) + len(completions) >= 6 + 2 * len(long_timings):
deadline = min(deadline, time.monotonic() + 1)
assert {service for service, _attrs in records} == {"sie-gateway", "sie-worker", "sie-dispatcher"}
- assert len(records) == 4
+ assert len(records) == 4 + 2 * len(long_timings)
+ timings = []
+ for _, attrs in records:
+ values = [attrs[key] for key in ("duration_ms", "first_token_ms")]
+ assert all(value.WhichOneof("value") in {"double_value", "int_value"} for value in values)
+ timings.append(
+ tuple(value.double_value if value.HasField("double_value") else value.int_value for value in values)
+ )
+ for timing in long_timings:
+ assert timings.count(timing) == 2
assert len(completions) == 2
assert {attrs["event.schema.version"].string_value for attrs in completions} == {"1", "2"}
allowed = {