惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

I
InfoQ
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Apple Machine Learning Research
Apple Machine Learning Research
月光博客
月光博客
B
Blog
罗磊的独立博客
GbyAI
GbyAI
博客园 - 三生石上(FineUI控件)
雷峰网
雷峰网
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Microsoft Security Blog
Microsoft Security Blog
宝玉的分享
宝玉的分享
The GitHub Blog
The GitHub Blog
人人都是产品经理
人人都是产品经理
博客园 - Franky
有赞技术团队
有赞技术团队
WordPress大学
WordPress大学
博客园 - 聂微东
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
V
Visual Studio Blog
MyScale Blog
MyScale Blog
Google DeepMind News
Google DeepMind News
G
Google Developers Blog
aimingoo的专栏
aimingoo的专栏

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
fix(diagnostics): trust internal trace parents (#71574) ·...
vincentkoc · 2026-04-26 · via Recent Commits to openclaw:main

@@ -111,6 +111,10 @@ vi.mock("@opentelemetry/semantic-conventions", () => ({

111111

ATTR_SERVICE_NAME: "service.name",

112112

}));

113113114+

import {

115+

emitTrustedDiagnosticEvent,

116+

onInternalDiagnosticEvent,

117+

} from "../../../src/infra/diagnostic-events.js";

114118

import type { OpenClawPluginServiceContext } from "../api.js";

115119

import { emitDiagnosticEvent } from "../api.js";

116120

import { createDiagnosticsOtelService } from "./service.js";

@@ -122,6 +126,7 @@ const TRACE_ID = "4bf92f3577b34da6a3ce929d0e0e4736";

122126

const SPAN_ID = "00f067aa0ba902b7";

123127

const CHILD_SPAN_ID = "1111111111111111";

124128

const GRANDCHILD_SPAN_ID = "2222222222222222";

129+

const TOOL_SPAN_ID = "3333333333333333";

125130

const PROTO_KEY = "__proto__";

126131

const MAX_TEST_OTEL_CONTENT_ATTRIBUTE_CHARS = 4096;

127132

const OTEL_TRUNCATED_SUFFIX_MAX_CHARS = 20;

@@ -165,6 +170,7 @@ function createOtelContext(

165170

},

166171

logger: createLogger(),

167172

stateDir: OTEL_TEST_STATE_DIR,

173+

internalDiagnostics: { onEvent: onInternalDiagnosticEvent },

168174

};

169175

}

170176

@@ -174,11 +180,13 @@ function createTraceOnlyContext(endpoint: string): OpenClawPluginServiceContext

174180175181

async function emitAndCaptureLog(

176182

event: Omit<Extract<Parameters<typeof emitDiagnosticEvent>[0], { type: "log.record" }>, "type">,

183+

options: { trusted?: boolean } = {},

177184

) {

178185

const service = createDiagnosticsOtelService();

179186

const ctx = createOtelContext(OTEL_TEST_ENDPOINT, { logs: true });

180187

await service.start(ctx);

181-

emitDiagnosticEvent({

188+

const emit = options.trusted ? emitTrustedDiagnosticEvent : emitDiagnosticEvent;

189+

emit({

182190

type: "log.record",

183191

...event,

184192

});

@@ -499,7 +507,7 @@ describe("diagnostics-otel service", () => {

499507

}

500508

});

501509502-

test("attaches diagnostic trace context to exported logs", async () => {

510+

test("does not attach untrusted diagnostic trace context to exported logs", async () => {

503511

const emitCall = await emitAndCaptureLog({

504512

level: "INFO",

505513

message: "traceable log",

@@ -513,15 +521,31 @@ describe("diagnostics-otel service", () => {

513521

},

514522

});

515523516-

expect(emitCall?.attributes).toMatchObject({

517-

"openclaw.traceFlags": "01",

518-

});

519524

expect(emitCall?.attributes).toEqual(

520525

expect.not.objectContaining({

521526

"openclaw.traceId": expect.anything(),

522527

"openclaw.spanId": expect.anything(),

528+

"openclaw.traceFlags": expect.anything(),

523529

}),

524530

);

531+

expect(telemetryState.tracer.setSpanContext).not.toHaveBeenCalled();

532+

expect(emitCall?.context).toBeUndefined();

533+

});

534+535+

test("attaches trusted diagnostic trace context to exported logs", async () => {

536+

const emitCall = await emitAndCaptureLog(

537+

{

538+

level: "INFO",

539+

message: "traceable log",

540+

trace: {

541+

traceId: TRACE_ID,

542+

spanId: SPAN_ID,

543+

traceFlags: "01",

544+

},

545+

},

546+

{ trusted: true },

547+

);

548+525549

expect(telemetryState.tracer.setSpanContext).toHaveBeenCalledWith(

526550

expect.anything(),

527551

expect.objectContaining({

@@ -817,6 +841,75 @@ describe("diagnostics-otel service", () => {

817841

await service.stop?.(ctx);

818842

});

819843844+

test("parents trusted diagnostic lifecycle spans from explicit parent ids", async () => {

845+

const service = createDiagnosticsOtelService();

846+

const ctx = createOtelContext(OTEL_TEST_ENDPOINT, { traces: true, metrics: true });

847+

await service.start(ctx);

848+849+

emitTrustedDiagnosticEvent({

850+

type: "run.completed",

851+

runId: "run-1",

852+

provider: "openai",

853+

model: "gpt-5.4",

854+

outcome: "completed",

855+

durationMs: 100,

856+

trace: {

857+

traceId: TRACE_ID,

858+

spanId: CHILD_SPAN_ID,

859+

parentSpanId: SPAN_ID,

860+

traceFlags: "01",

861+

},

862+

});

863+

emitTrustedDiagnosticEvent({

864+

type: "model.call.completed",

865+

runId: "run-1",

866+

callId: "call-1",

867+

provider: "openai",

868+

model: "gpt-5.4",

869+

durationMs: 80,

870+

trace: {

871+

traceId: TRACE_ID,

872+

spanId: GRANDCHILD_SPAN_ID,

873+

parentSpanId: CHILD_SPAN_ID,

874+

traceFlags: "01",

875+

},

876+

});

877+

emitTrustedDiagnosticEvent({

878+

type: "tool.execution.error",

879+

runId: "run-1",

880+

toolName: "read",

881+

durationMs: 20,

882+

errorCategory: "TypeError",

883+

trace: {

884+

traceId: TRACE_ID,

885+

spanId: TOOL_SPAN_ID,

886+

parentSpanId: GRANDCHILD_SPAN_ID,

887+

traceFlags: "01",

888+

},

889+

});

890+

await flushDiagnosticEvents();

891+892+

expect(telemetryState.tracer.setSpanContext).toHaveBeenCalledTimes(3);

893+

expect(telemetryState.tracer.setSpanContext.mock.calls.map((call) => call[1])).toEqual([

894+

expect.objectContaining({ traceId: TRACE_ID, spanId: SPAN_ID }),

895+

expect.objectContaining({ traceId: TRACE_ID, spanId: CHILD_SPAN_ID }),

896+

expect.objectContaining({ traceId: TRACE_ID, spanId: GRANDCHILD_SPAN_ID }),

897+

]);

898+899+

const parentBySpanName = Object.fromEntries(

900+

telemetryState.tracer.startSpan.mock.calls.map((call) => [

901+

call[0],

902+

(call[2] as { spanContext?: { spanId?: string } } | undefined)?.spanContext?.spanId,

903+

]),

904+

);

905+

expect(parentBySpanName).toMatchObject({

906+

"openclaw.run": SPAN_ID,

907+

"openclaw.model.call": CHILD_SPAN_ID,

908+

"openclaw.tool.execution": GRANDCHILD_SPAN_ID,

909+

});

910+

await service.stop?.(ctx);

911+

});

912+820913

test("exports exec process spans without command text", async () => {

821914

const service = createDiagnosticsOtelService();

822915

const ctx = createOtelContext(OTEL_TEST_ENDPOINT, { traces: true, metrics: true });