UNPKG

@fiberplane/hono-otel

Version:

Hono middleware to forward OpenTelemetry traces to a local instance of @fiberplane/studio

44 lines (43 loc) 1.85 kB
import { describe, expect, it } from "vitest"; import { DEFAULT_CONFIG, DEFAULT_REDACTED_QUERY_PARAMS } from "../config.js"; import { getRedactedQueryParams } from "./redacted-query-params.js"; const baseConfig = { enabled: true, mode: "production", redactedHeaders: new Set(...DEFAULT_CONFIG.redactedHeaders), redactedQueryParams: new Set(...DEFAULT_CONFIG.redactedQueryParams), otelEndpoint: "http://localhost:4318", otelToken: "", logLevel: "debug", serviceName: "test-service", libraryDebugMode: false, monitor: { fetch: true, logging: true, cfBindings: true, }, }; describe("redacted query params context", () => { it("should return custom redacted query params when provided in config", () => { const config = { ...baseConfig, redactedQueryParams: new Set(["token", "apiKey", "secret"]), }; const result = getRedactedQueryParams(config); expect(result).toEqual(new Set(["token", "apiKey", "secret"])); }); it("should return default redacted query params when config is undefined", () => { const result = getRedactedQueryParams(undefined); expect(result).toEqual(new Set(DEFAULT_REDACTED_QUERY_PARAMS)); }); it("should return default redacted query params when no config is provided", () => { const result = getRedactedQueryParams(); expect(result).toEqual(new Set(DEFAULT_REDACTED_QUERY_PARAMS)); }); it("should return default redacted query params when config.redactedQueryParams is undefined", () => { const { redactedQueryParams, ...configWithoutParams } = baseConfig; const config = configWithoutParams; const result = getRedactedQueryParams(config); expect(result).toEqual(new Set(DEFAULT_REDACTED_QUERY_PARAMS)); }); });