refactor(trace): share first-record header diagnostics (#17323)

This commit is contained in:
Vincent Koc
2026-12-06 08:49:19 +08:00
committed by GitHub
parent 693e8956d7
commit b564b5e601
@@ -202,26 +202,17 @@ class TraceStreamRead {
this.#headerSeen = true;
return;
}
const raw = parsed.kind === "skipped" ? undefined : parsed.value;
if (this.stream.role === "trace" && !this.#headerSeen) {
this.header(raw, line.line);
return;
}
if (parsed.kind === "skipped") {
if (this.stream.role === "trace" && !this.#headerSeen) {
this.#headerSeen = true;
this.diagnostic(
line.line,
"missing-context-header",
"A trace member has no initial context-options record; its event version stays unknown.",
);
return;
}
if (!this.omitted.has(parsed.type))
inventory.reserve(512 + parsed.type.length * 12);
this.omitted.set(parsed.type, (this.omitted.get(parsed.type) ?? 0) + 1);
return;
}
const raw = parsed.value;
if (this.stream.role === "trace" && !this.#headerSeen) {
this.header(raw, line.line);
return;
}
if (!captureObject(raw) || typeof raw.type !== "string") {
this.diagnostic(
line.line,