rendererActionTraceExporter.test.ts 1.0 KB

123456789101112131415161718192021222324252627282930
  1. import { describe, expect, it } from "vitest";
  2. import {
  3. parseRendererActionTraceHeaders,
  4. resolveRendererActionTraceEndpoint,
  5. } from "../src/main/rendererActionTraceExporter.js";
  6. describe("renderer action trace exporter config", () => {
  7. it("uses the traces endpoint directly and appends v1/traces to the common endpoint", () => {
  8. expect(
  9. resolveRendererActionTraceEndpoint({
  10. OTEL_EXPORTER_OTLP_TRACES_ENDPOINT: "https://arms.example/custom",
  11. }),
  12. ).toBe("https://arms.example/custom");
  13. expect(
  14. resolveRendererActionTraceEndpoint({
  15. OTEL_EXPORTER_OTLP_ENDPOINT: "https://arms.example/otlp/",
  16. }),
  17. ).toBe("https://arms.example/otlp/v1/traces");
  18. });
  19. it("rejects non-http endpoints and parses percent-encoded headers", () => {
  20. expect(
  21. resolveRendererActionTraceEndpoint({ OTEL_EXPORTER_OTLP_ENDPOINT: "file:///tmp/x" }),
  22. ).toBeUndefined();
  23. expect(parseRendererActionTraceHeaders("x-key=hello%20world,ignored,x-two=2")).toEqual({
  24. "x-key": "hello world",
  25. "x-two": "2",
  26. });
  27. });
  28. });