mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-09-07 10:06:21 +00:00
R4 review finding, and the comment I wrote in R3 was simply wrong: the
probe session is NOT running for every render. probeStage's needsBrowser
gate launches one only for unknown duration, unresolved compositions, or
specific media cases — and hasRuntimeInsertedMedia matches only
createElement("video"|"audio"), never createElement("span"). So the exact
shape that motivated the live-DOM fix (a known-duration, media-free
caption comp building thousands of nodes in script) gets NO probe, falls
back to the static source scan, reads as ~2 elements, and could enter the
applied cohort at 40k live nodes. The R3 fix measured the right thing but
only for the population that already had a probe.
Now the count carries provenance and the band fails closed:
- resolveCompositionElementCount returns { count, source: "live" |
"static" }. Only "live" — an actual DOM measurement — may open the band.
- resolveDeShortBand gains a third decisive outcome, "unmeasured", for
the static case. It deliberately does NOT report skipped_elements: a
static undercount is not a real oversize observation, and putting it in
the control arm would contaminate the DiD just as putting it in the
treatment arm would. Neither cohort; never routes.
- composition_element_count_source ships alongside the count, so the
fleet rate of "static" sizes the population a future
conditional-probe-launch would unlock — which is the data PR B needs to
decide whether that launch cost is worth paying.
Regression coverage walks the real chain rather than a full render, using
the production functions in pipeline order: probeRequiresBrowser (newly
extracted from the inline needsBrowser expression, so the gate is
testable at all) returns false for the caption-comp shape → the resolver
reports static and a count under the ceiling → the band reports
unmeasured, not applied. Fault injection confirms it bites: removing the
one guard line fails exactly these three tests.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
82 lines
4.1 KiB
TypeScript
82 lines
4.1 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,
|
|
captureCompositionElementCount: capture.compositionElementCount,
|
|
captureCompositionElementCountSource: capture.compositionElementCountSource,
|
|
captureDeShortBand: capture.deShortBand,
|
|
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,
|
|
};
|
|
}
|