























@@ -50,18 +50,20 @@ describe("diagnostic log events", () => {
5050unsubscribe();
51515252expect(received).toHaveLength(1);
53-expect(received[0]).toMatchObject({
54-type: "log.record",
55-level: "INFO",
56-message: "hello diagnostic logs",
57-attributes: {
58-subsystem: "diagnostic",
59-runId: "run-1",
60-},
61-trace: {
62-traceId: TRACE_ID,
63-spanId: SPAN_ID,
64-},
53+const [event] = received;
54+if (!event) {
55+throw new Error("missing diagnostic log event");
56+}
57+expect(event.type).toBe("log.record");
58+expect(event.level).toBe("INFO");
59+expect(event.message).toBe("hello diagnostic logs");
60+expect(event.attributes).toStrictEqual({
61+subsystem: "diagnostic",
62+runId: "run-1",
63+});
64+expect(event.trace).toStrictEqual({
65+traceId: TRACE_ID,
66+spanId: SPAN_ID,
6567});
6668});
6769@@ -121,17 +123,9 @@ describe("diagnostic log events", () => {
121123expect(event.attributes?.token).not.toBe(secret);
122124expect(String(event.attributes?.token)).toContain("…");
123125expect(String(event.attributes?.longValue).length).toBeLessThanOrEqual(2100);
124-expect(event.attributes).toEqual(
125-expect.not.objectContaining({
126-nested: expect.anything(),
127-"bad key": expect.anything(),
128-}),
129-);
130-expect(event).toEqual(
131-expect.not.objectContaining({
132-argsJson: expect.anything(),
133-}),
134-);
126+expect(Object.hasOwn(event.attributes ?? {}, "nested")).toBe(false);
127+expect(Object.hasOwn(event.attributes ?? {}, "bad key")).toBe(false);
128+expect(Object.hasOwn(event, "argsJson")).toBe(false);
135129});
136130137131it("drops sensitive, blocked, and excess log attribute keys without copying large objects", async () => {
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。