Files
hyperframes/packages/cli/src/telemetry/renderObservability.ts
T
Vance IngallsandClaude Opus 5 4520cd240b fix(engine): bucket gpu_renderer + cover the failure cohort (review)
Three review findings on the win32 drawElement PR:

1. gpu_renderer shipped the raw UNMASKED_RENDERER_WEBGL string — unbounded,
   driver-authored, GPU-model-specific, and |-joined across parallel
   sessions, i.e. high cardinality by construction, against this file's own
   convention of sanitizing engine-sourced strings (deGateReason is a
   bucket; error messages go through redactTelemetryString). Now bucketed at
   the source by classifyGpuRenderer to <backend>/<vendor>
   (metal/apple, d3d11/nvidia, swiftshader/other, ...), which is the whole
   analytic signal the win32 rollout needs and nothing else. The raw string
   never leaves the engine.

2. gpu_renderer reached render_complete only, so a crashed render — the
   cohort the field exists to attribute — carried no backend. It now rides
   RenderCaptureObservability (deGpuRenderer, sourced from the live probe
   session like the de_* counters), so both render_complete and
   render_error carry it and a hard failure still reports its GPU backend.
   On render_complete the perfSummary value still wins by spread order.

3. Restore the fallow-ignore-next-line suppression above
   __resetDeParallelRouterTrialStateForTests: CLI test files are not fallow
   entry points, so removing it fails the CI dead-code audit (local
   pre-commit passed only because of its changed-file scope).

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-28 00:55:10 -07:00

79 lines
4.0 KiB
TypeScript

import type { RenderJob, RenderPerfSummary } from "@hyperframes/producer";
import type { RenderObservabilityTelemetryPayload } from "./events.js";
type RenderObservabilitySummary = NonNullable<RenderPerfSummary["observability"]>;
export function renderObservabilityTelemetryPayload(
observability: RenderObservabilitySummary | undefined,
): RenderObservabilityTelemetryPayload {
if (!observability) return {};
const diagnostics = observability.browserDiagnostics;
const capture = observability.capture;
const extraction = observability.extraction;
const init = observability.init;
return {
observabilityRenderJobId: observability.renderJobId,
observabilityCompositionHash: observability.compositionHash,
observabilityEventCount: observability.eventCount,
observabilityLastPhase: observability.lastEvent?.phase,
observabilityLastStatus: observability.lastEvent?.status,
observabilityFailedPhase: observability.failedPhase,
browserDiagnosticCount: diagnostics.total,
browserDiagnosticErrors: diagnostics.errors,
browserDiagnosticPageErrors: diagnostics.pageErrors,
browserDiagnosticRequestFailed: diagnostics.requestFailed,
browserDiagnosticHttpErrors: diagnostics.httpErrors,
browserDiagnosticNavigationStarts: diagnostics.navigationStarts,
browserDiagnosticNavigationFailures: diagnostics.navigationFailures,
browserDiagnosticConsoleErrors: diagnostics.consoleErrors,
browserDiagnosticConsoleWarnings: diagnostics.consoleWarnings,
captureMode: capture.captureMode,
captureForceScreenshot: capture.forceScreenshot,
captureWorkerCount: capture.workerCount,
captureUseStreamingEncode: capture.useStreamingEncode,
captureUseLayeredComposite: capture.useLayeredComposite,
captureUsePageSideCompositing: capture.usePageSideCompositing,
captureHasHdrContent: capture.hasHdrContent,
captureBrowserGpuMode: capture.browserGpuMode,
captureProtocolTimeoutMs: capture.protocolTimeoutMs,
capturePageNavigationTimeoutMs: capture.pageNavigationTimeoutMs,
capturePlayerReadyTimeoutMs: capture.playerReadyTimeoutMs,
captureTransientRetries: capture.transientRetries,
captureMemoryExhaustionDetected: capture.memoryExhaustionDetected,
captureDeWorkerInversion: capture.deWorkerInversion,
captureDePreInversionWorkers: capture.dePreInversionWorkers,
captureDeParallelRouter: capture.deParallelRouter,
captureDeGpuRenderer: capture.deGpuRenderer,
captureDePreRouterWorkers: capture.dePreRouterWorkers,
captureDeSelfVerifyFallback: capture.deSelfVerifyFallback,
captureDeFallbackReason: capture.deFallbackReason,
captureDeFallbackFailedDb: capture.deFallbackFailedDb,
captureDeFallbackFrameIndex: capture.deFallbackFrameIndex,
captureDeFallbackThresholdDb: capture.deFallbackThresholdDb,
captureParallelStream: capture.captureParallelStream,
observabilityExtractVideoCount: extraction?.videoCount,
observabilityExtractedVideoCount: extraction?.extractedVideoCount,
observabilityExtractTotalFrames: extraction?.totalFramesExtracted,
observabilityExtractMaxFramesPerVideo: extraction?.maxFramesPerVideo,
observabilityExtractAvgFramesPerVideo: extraction?.avgFramesPerExtractedVideo,
observabilityExtractVfrProbeMs: extraction?.vfrProbeMs,
observabilityExtractVfrPreflightMs: extraction?.vfrPreflightMs,
observabilityExtractVfrPreflightCount: extraction?.vfrPreflightCount,
observabilityExtractCacheHits: extraction?.cacheHits,
observabilityExtractCacheMisses: extraction?.cacheMisses,
observabilityInitDurationMs: init?.initDurationMs,
observabilityInitTweenCount: init?.tweenCount,
};
}
export function renderJobObservabilityTelemetryPayload(
job: RenderJob | undefined,
): RenderObservabilityTelemetryPayload {
return {
...renderObservabilityTelemetryPayload(
job?.errorDetails?.observability ?? job?.perfSummary?.observability,
),
subTimelineWait: job?.errorDetails?.subTimelineWait ?? job?.perfSummary?.subTimelineWait,
};
}