fix(telemetry): send both telemetry ports through one collector transport (Q-6.9-4)

The application port (best-effort-telemetry) and the feature port
(feature-telemetry pipeline) each posted to TELEMETRY_ENDPOINT on their
own: 20+20 sends per minute, cookies on the application side, no
pagehide flush or dispose abort on the feature side, and no deadline on
any fetch, so a hung collector held activeFlush forever (6.3-10).

New src/adapters/telemetry/telemetry-collector.ts is the one transport:
shared send-rate window (createTelemetrySendRate, now in the platform
pipeline and injectable via `sendRate`), credentials "omit", cache
"no-store", a per-request deadline through the kernel
createAbortableOperation, and one pagehide fan-out. runtime-adapters
builds one collector and passes it to both ports. Body projections are
unchanged and pinned by characterization tests first.

Verified: new tests in tests/unit/telemetry.test.ts (5 RED before
wiring: credentials/cache, hung collector timeout, shared rate,
feature pagehide flush, feature dispose abort); all gates pass except
the known tests/unit/removal-fixture.test.ts (artifacts/ absent);
check:adapter-inventory 137/137; FE-RB-004 drill PASS.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
DongHyeonka
2026-09-24 13:58:35 +09:00
co-authored by Claude Opus 5.5
parent b35304dd48
commit a328776bf2
9 changed files with 528 additions and 98 deletions
+12
View File
@@ -33,6 +33,7 @@ import { createBrowserMutationIntentFactory } from "../adapters/platform/index.t
import {
createFeatureTelemetry,
createTelemetryAdapter,
createTelemetryCollector,
} from "../adapters/telemetry/index.ts";
import type { AuthSessionPort } from "../application/ports/auth-session-port.ts";
import type { ReleaseInfo } from "../application/ports/release-info-port.ts";
@@ -307,10 +308,20 @@ export async function createRuntimeAdapters(
? createExternalAuthSessionAdapter(externalOwner)
: createUnavailableSessionAdapter();
const diagnostics = createDiagnosticsAdapter();
// Q-6.9-4. Both telemetry ports post through one collector transport: one
// send-rate window, one page-exit flush and one fetch policy per endpoint.
const telemetryCollector =
config.TELEMETRY_ENABLED && config.TELEMETRY_ENDPOINT
? createTelemetryCollector({
endpoint: config.TELEMETRY_ENDPOINT,
...(context.fetcher === undefined ? {} : { fetcher: context.fetcher }),
})
: undefined;
const telemetry = createTelemetryAdapter({
enabled: config.TELEMETRY_ENABLED,
endpoint: config.TELEMETRY_ENDPOINT,
fetcher: context.fetcher,
...(telemetryCollector === undefined ? {} : { collector: telemetryCollector }),
onDrop(event) {
const attributes =
event.attributes && typeof event.attributes === "object"
@@ -543,6 +554,7 @@ export async function createRuntimeAdapters(
? {}
: { endpoint: config.TELEMETRY_ENDPOINT }),
...(context.fetcher === undefined ? {} : { fetcher: context.fetcher }),
...(telemetryCollector === undefined ? {} : { collector: telemetryCollector }),
});
// Each installed contribution receives only the capabilities it declares.
const featureCapabilities = Object.freeze({