| 66 | // "k=v,k2=v2" form. A malformed pair is skipped rather than failing the boot: |
| 67 | // losing traces must never cost the operator their server. |
| 68 | const parseHeaders = (raw: string | undefined): Record<string, string> | undefined => { |
| 69 | const entries = (raw ?? "") |
| 70 | .split(",") |
| 71 | .map((pair) => pair.trim()) |
| 72 | .filter((pair) => pair.length > 0) |
| 73 | .flatMap((pair) => { |
| 74 | const separator = pair.indexOf("="); |
| 75 | if (separator <= 0) return []; |
| 76 | return [[pair.slice(0, separator).trim(), pair.slice(separator + 1).trim()] as const]; |
| 77 | }); |
| 78 | return entries.length > 0 ? Object.fromEntries(entries) : undefined; |
| 79 | }; |
| 80 | |
| 81 | /** |
| 82 | * OTLP export layer for the self-hosted server, or {@link Layer.empty} when no |