


























@@ -888,6 +888,38 @@ export function createDiagnosticsOtelService(): OpenClawPluginService {
888888unit: "1",
889889description: "Diagnostic memory pressure events",
890890});
891+const livenessWarningCounter = meter.createCounter("openclaw.liveness.warning", {
892+unit: "1",
893+description: "Diagnostic liveness warning events",
894+});
895+const livenessEventLoopDelayP99Histogram = meter.createHistogram(
896+"openclaw.liveness.event_loop_delay_p99_ms",
897+{
898+unit: "ms",
899+description: "P99 event-loop delay reported by diagnostic liveness warnings",
900+},
901+);
902+const livenessEventLoopDelayMaxHistogram = meter.createHistogram(
903+"openclaw.liveness.event_loop_delay_max_ms",
904+{
905+unit: "ms",
906+description: "Maximum event-loop delay reported by diagnostic liveness warnings",
907+},
908+);
909+const livenessEventLoopUtilizationHistogram = meter.createHistogram(
910+"openclaw.liveness.event_loop_utilization",
911+{
912+unit: "1",
913+description: "Event-loop utilization reported by diagnostic liveness warnings",
914+},
915+);
916+const livenessCpuCoreRatioHistogram = meter.createHistogram(
917+"openclaw.liveness.cpu_core_ratio",
918+{
919+unit: "1",
920+description: "CPU core ratio reported by diagnostic liveness warnings",
921+},
922+);
891923const telemetryExporterCounter = meter.createCounter("openclaw.telemetry.exporter.events", {
892924unit: "1",
893925description: "Diagnostic telemetry exporter lifecycle and failure events",
@@ -2058,6 +2090,68 @@ export function createDiagnosticsOtelService(): OpenClawPluginService {
20582090queueDepthHistogram.record(evt.queued, { "openclaw.channel": "heartbeat" });
20592091};
206020922093+const recordLivenessWarning = (
2094+evt: Extract<DiagnosticEventPayload, { type: "diagnostic.liveness.warning" }>,
2095+) => {
2096+const reason = evt.reasons.join(":");
2097+const attrs = {
2098+"openclaw.liveness.reason": lowCardinalityAttr(reason, "unknown"),
2099+};
2100+livenessWarningCounter.add(1, attrs);
2101+queueDepthHistogram.record(evt.queued, { "openclaw.channel": "liveness" });
2102+if (evt.eventLoopDelayP99Ms !== undefined) {
2103+livenessEventLoopDelayP99Histogram.record(evt.eventLoopDelayP99Ms, attrs);
2104+}
2105+if (evt.eventLoopDelayMaxMs !== undefined) {
2106+livenessEventLoopDelayMaxHistogram.record(evt.eventLoopDelayMaxMs, attrs);
2107+}
2108+if (evt.eventLoopUtilization !== undefined) {
2109+livenessEventLoopUtilizationHistogram.record(evt.eventLoopUtilization, attrs);
2110+}
2111+if (evt.cpuCoreRatio !== undefined) {
2112+livenessCpuCoreRatioHistogram.record(evt.cpuCoreRatio, attrs);
2113+}
2114+if (!tracesEnabled) {
2115+return;
2116+}
2117+const spanAttrs: Record<string, string | number> = {
2118+ ...attrs,
2119+"openclaw.liveness.active": evt.active,
2120+"openclaw.liveness.waiting": evt.waiting,
2121+"openclaw.liveness.queued": evt.queued,
2122+"openclaw.liveness.interval_ms": evt.intervalMs,
2123+ ...(evt.eventLoopDelayP99Ms !== undefined
2124+ ? { "openclaw.liveness.event_loop_delay_p99_ms": evt.eventLoopDelayP99Ms }
2125+ : {}),
2126+ ...(evt.eventLoopDelayMaxMs !== undefined
2127+ ? { "openclaw.liveness.event_loop_delay_max_ms": evt.eventLoopDelayMaxMs }
2128+ : {}),
2129+ ...(evt.eventLoopUtilization !== undefined
2130+ ? { "openclaw.liveness.event_loop_utilization": evt.eventLoopUtilization }
2131+ : {}),
2132+ ...(evt.cpuUserMs !== undefined
2133+ ? { "openclaw.liveness.cpu_user_ms": evt.cpuUserMs }
2134+ : {}),
2135+ ...(evt.cpuSystemMs !== undefined
2136+ ? { "openclaw.liveness.cpu_system_ms": evt.cpuSystemMs }
2137+ : {}),
2138+ ...(evt.cpuTotalMs !== undefined
2139+ ? { "openclaw.liveness.cpu_total_ms": evt.cpuTotalMs }
2140+ : {}),
2141+ ...(evt.cpuCoreRatio !== undefined
2142+ ? { "openclaw.liveness.cpu_core_ratio": evt.cpuCoreRatio }
2143+ : {}),
2144+};
2145+const span = spanWithDuration("openclaw.liveness.warning", spanAttrs, 0, {
2146+endTimeMs: evt.ts,
2147+});
2148+span.setStatus({
2149+code: SpanStatusCode.ERROR,
2150+message: reason,
2151+});
2152+span.end(evt.ts);
2153+};
2154+20612155const recordTelemetryExporter = (
20622156evt: TelemetryExporterDiagnosticEvent,
20632157metadata: DiagnosticEventMetadata,
@@ -2130,6 +2224,9 @@ export function createDiagnosticsOtelService(): OpenClawPluginService {
21302224case "diagnostic.heartbeat":
21312225recordHeartbeat(evt);
21322226return;
2227+case "diagnostic.liveness.warning":
2228+recordLivenessWarning(evt);
2229+return;
21332230case "run.started":
21342231recordRunStarted(evt, metadata);
21352232return;
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。