





















@@ -852,6 +852,31 @@ export function createDiagnosticsOtelService(): OpenClawPluginService {
852852unit: "1",
853853description: "Messages queued for processing",
854854});
855+const messageReceivedCounter = meter.createCounter("openclaw.message.received", {
856+unit: "1",
857+description: "Inbound messages received",
858+});
859+const messageDispatchStartedCounter = meter.createCounter(
860+"openclaw.message.dispatch.started",
861+{
862+unit: "1",
863+description: "Inbound message dispatch attempts started",
864+},
865+);
866+const messageDispatchCompletedCounter = meter.createCounter(
867+"openclaw.message.dispatch.completed",
868+{
869+unit: "1",
870+description: "Inbound message dispatch attempts completed",
871+},
872+);
873+const messageDispatchDurationHistogram = meter.createHistogram(
874+"openclaw.message.dispatch.duration_ms",
875+{
876+unit: "ms",
877+description: "Inbound message dispatch duration",
878+},
879+);
855880const messageProcessedCounter = meter.createCounter("openclaw.message.processed", {
856881unit: "1",
857882description: "Messages processed by outcome",
@@ -894,6 +919,10 @@ export function createDiagnosticsOtelService(): OpenClawPluginService {
894919unit: "1",
895920description: "Session state transitions",
896921});
922+const sessionTurnCreatedCounter = meter.createCounter("openclaw.session.turn.created", {
923+unit: "1",
924+description: "Agent session turns created",
925+});
897926const sessionStuckCounter = meter.createCounter("openclaw.session.stuck", {
898927unit: "1",
899928description: "Sessions stuck in processing",
@@ -1430,6 +1459,37 @@ export function createDiagnosticsOtelService(): OpenClawPluginService {
14301459}
14311460};
143214611462+const recordMessageReceived = (
1463+evt: Extract<DiagnosticEventPayload, { type: "message.received" }>,
1464+) => {
1465+messageReceivedCounter.add(1, {
1466+"openclaw.channel": lowCardinalityAttr(evt.channel),
1467+"openclaw.source": lowCardinalityAttr(evt.source),
1468+});
1469+};
1470+1471+const recordMessageDispatchStarted = (
1472+evt: Extract<DiagnosticEventPayload, { type: "message.dispatch.started" }>,
1473+) => {
1474+messageDispatchStartedCounter.add(1, {
1475+"openclaw.channel": lowCardinalityAttr(evt.channel),
1476+"openclaw.source": lowCardinalityAttr(evt.source),
1477+});
1478+};
1479+1480+const recordMessageDispatchCompleted = (
1481+evt: Extract<DiagnosticEventPayload, { type: "message.dispatch.completed" }>,
1482+) => {
1483+const attrs = {
1484+"openclaw.channel": lowCardinalityAttr(evt.channel),
1485+"openclaw.outcome": evt.outcome,
1486+"openclaw.reason": lowCardinalityAttr(evt.reason, "none"),
1487+"openclaw.source": lowCardinalityAttr(evt.source),
1488+};
1489+messageDispatchCompletedCounter.add(1, attrs);
1490+messageDispatchDurationHistogram.record(evt.durationMs, attrs);
1491+};
1492+14331493const recordMessageProcessed = (
14341494evt: Extract<DiagnosticEventPayload, { type: "message.processed" }>,
14351495) => {
@@ -1565,6 +1625,16 @@ export function createDiagnosticsOtelService(): OpenClawPluginService {
15651625sessionStateCounter.add(1, attrs);
15661626};
156716271628+const recordSessionTurnCreated = (
1629+evt: Extract<DiagnosticEventPayload, { type: "session.turn.created" }>,
1630+) => {
1631+sessionTurnCreatedCounter.add(1, {
1632+"openclaw.agent": lowCardinalityAttr(evt.agentId, "unknown"),
1633+"openclaw.channel": lowCardinalityAttr(evt.channel, "unknown"),
1634+"openclaw.trigger": evt.trigger,
1635+});
1636+};
1637+15681638const recordSessionStuck = (
15691639evt: Extract<DiagnosticEventPayload, { type: "session.stuck" }>,
15701640) => {
@@ -2428,6 +2498,15 @@ export function createDiagnosticsOtelService(): OpenClawPluginService {
24282498case "message.queued":
24292499recordMessageQueued(evt);
24302500return;
2501+case "message.received":
2502+recordMessageReceived(evt);
2503+return;
2504+case "message.dispatch.started":
2505+recordMessageDispatchStarted(evt);
2506+return;
2507+case "message.dispatch.completed":
2508+recordMessageDispatchCompleted(evt);
2509+return;
24312510case "message.processed":
24322511recordMessageProcessed(evt);
24332512return;
@@ -2455,6 +2534,9 @@ export function createDiagnosticsOtelService(): OpenClawPluginService {
24552534case "session.long_running":
24562535case "session.stalled":
24572536return;
2537+case "session.turn.created":
2538+recordSessionTurnCreated(evt);
2539+return;
24582540case "session.stuck":
24592541recordSessionStuck(evt);
24602542return;
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。