maxObservedToSpanRatio constant

double const maxObservedToSpanRatio

Trace-vs-observed cross-check: a capture that pairs a hand-authored expectedMagnitude.observed with a trace whose scenario-marker span is orders of magnitude smaller than the claim almost certainly describes a fabricated export. For time-unit magnitudes (ms, us, s, ns) we bind the span to the two scenario-marker instant events (see scenarioBeginMarker / scenarioEndMarker), convert the claimed observed into the same unit (microseconds), and reject if the claim exceeds the span by more than maxObservedToSpanRatio. For non-time units (bytes, frames, requests, …) no cross-check is attempted — the trace cannot meaningfully certify those.

The ratio is 100, down from 100_000. The prior bound admitted realistic 100×–10_000× fabrication (observed: 1000 ms paired with a 1–10 ms span). A real profile-mode capture of a 1000 ms scenario emits markers bracketing the full 1000 ms; 100× allows modest instrumentation overhead (marker emission just before/after the scenario, driver framework preamble) but not order-of-magnitude drift.

The span is bound to scenario markers, not the global minTs/maxTs over every work-phase event. The prior implementation iterated the full trace, so an attacker could pad a single unrelated event at ts=1_000_000 and inflate the denominator until any observed claim fit.

Implementation

static const double maxObservedToSpanRatio = 100;