





















@@ -7,9 +7,14 @@ import os from "node:os";
77import path from "node:path";
88import { setTimeout as delay } from "node:timers/promises";
99import { gzipSync } from "node:zlib";
10-import { beforeAll, describe, expect, it, vi } from "vitest";
10+import { afterEach, beforeAll, describe, expect, it, vi } from "vitest";
1111import { testing } from "./qa-otel-smoke-runtime.js";
121213+afterEach(() => {
14+vi.unstubAllEnvs();
15+vi.restoreAllMocks();
16+});
17+1318describe("qa-otel-smoke receiver bounds", () => {
1419let configuredBodyLimitLoad: ReturnType<typeof spawnSync>;
1520@@ -171,6 +176,40 @@ describe("qa-otel-smoke receiver bounds", () => {
171176expect(configuredBodyLimitLoad.stderr).not.toContain("ReferenceError");
172177});
173178179+it("scrubs inherited OpenTelemetry exporter env before running the QA suite", () => {
180+vi.stubEnv("OTEL_SDK_DISABLED", "true");
181+vi.stubEnv("OTEL_TRACES_EXPORTER", "none");
182+vi.stubEnv("OTEL_METRICS_EXPORTER", "none");
183+vi.stubEnv("OTEL_LOGS_EXPORTER", "none");
184+vi.stubEnv("OTEL_EXPORTER_OTLP_ENDPOINT", "http://collector.example.test:4318");
185+vi.stubEnv("OTEL_EXPORTER_OTLP_PROTOCOL", "grpc");
186+vi.stubEnv("OTEL_EXPORTER_OTLP_TRACES_PROTOCOL", "grpc");
187+vi.stubEnv("OTEL_EXPORTER_OTLP_METRICS_PROTOCOL", "grpc");
188+vi.stubEnv("OTEL_EXPORTER_OTLP_LOGS_PROTOCOL", "grpc");
189+vi.stubEnv("OTEL_EXPORTER_OTLP_HEADERS", "authorization=secret");
190+vi.stubEnv("OTEL_EXPORTER_OTLP_LOGS_HEADERS", "authorization=logs-secret");
191+vi.stubEnv("OTEL_RESOURCE_ATTRIBUTES", "deployment.environment=developer-laptop");
192+193+const env = testing.buildQaEnv(4318);
194+195+expect(env.OTEL_SDK_DISABLED).toBeUndefined();
196+expect(env.OTEL_TRACES_EXPORTER).toBeUndefined();
197+expect(env.OTEL_METRICS_EXPORTER).toBeUndefined();
198+expect(env.OTEL_LOGS_EXPORTER).toBeUndefined();
199+expect(env.OTEL_EXPORTER_OTLP_ENDPOINT).toBeUndefined();
200+expect(env.OTEL_EXPORTER_OTLP_PROTOCOL).toBeUndefined();
201+expect(env.OTEL_EXPORTER_OTLP_TRACES_PROTOCOL).toBeUndefined();
202+expect(env.OTEL_EXPORTER_OTLP_METRICS_PROTOCOL).toBeUndefined();
203+expect(env.OTEL_EXPORTER_OTLP_LOGS_PROTOCOL).toBeUndefined();
204+expect(env.OTEL_EXPORTER_OTLP_HEADERS).toBeUndefined();
205+expect(env.OTEL_EXPORTER_OTLP_LOGS_HEADERS).toBeUndefined();
206+expect(env.OTEL_RESOURCE_ATTRIBUTES).toBeUndefined();
207+expect(env.OTEL_EXPORTER_OTLP_TRACES_ENDPOINT).toBe("http://127.0.0.1:4318/v1/traces");
208+expect(env.OTEL_EXPORTER_OTLP_METRICS_ENDPOINT).toBe("http://127.0.0.1:4318/v1/metrics");
209+expect(env.OTEL_EXPORTER_OTLP_LOGS_ENDPOINT).toBe("http://127.0.0.1:4318/v1/logs");
210+expect(env.OTEL_SERVICE_NAME).toBe("openclaw-qa-lab-otel-smoke");
211+});
212+174213it("rejects identity OTLP bodies above the decoded byte ceiling", () => {
175214expect(() => testing.decodeRequestBody(Buffer.alloc(65), undefined, 64)).toThrow(
176215"OTLP request body exceeded 64 bytes: 65 bytes",
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。