Design: Local performance and capacity benchmarks¶
Control¶
| Field | Value |
|---|---|
| Status | READY FOR REVIEW |
| Design revision | 2 |
| Owner | telemetry-platform |
| Reviewer / approval | User-directed public-module expansion; capacity thresholds still pending maintainer approval |
| Governing source | User request dated 2026-09-19; repository Safety Floor and verification contracts |
| Delivery unit | Linear epic PL-64 and child issues PL-65 through PL-71 |
| Change class | Brownfield verification infrastructure |
This design is not approved merely because it is complete. A maintainer must approve revision 2
before implementation issues receive the ready-for-agent label.
1. Outcome and scope¶
Outcome: A local operator can run one bounded benchmark command and receive reproducible, environment-qualified measurements of the maximum stable load handled by the Python telemetry runtime and each repository-owned Collector topology.
Requirements¶
- REQ-01 — Capacity: Report the maximum stable local throughput for traces, metric points, and log records, separately and under a balanced three-signal load.
- REQ-02 — Topologies: Measure the stateless base, persistent-queue, and routed tail-sampling topologies without contacting a live vendor backend.
- REQ-03 — Bottlenecks: Distinguish generator, Python runtime, Collector, sink, CPU, memory, queue, disk, and transport limits instead of reporting every failed run as Collector saturation.
- REQ-04 — Reproducibility: Bind results to the exact source, wheel, lock, images, configuration, workload, host/container resources, seed, and raw observations.
- REQ-05 — Safety: Use synthetic telemetry, bounded resources and duration, deterministic cleanup, explicit abort conditions, and no production credentials or endpoints.
- REQ-06 — Qualification: Reuse the existing paired overhead and evidence conventions rather than creating a competing release-evidence system.
In scope¶
- Python API/SDK emission cost through
TelemetryRuntime. - Collector-only and runtime-to-Collector-to-sink capacity.
- gRPC and HTTP/protobuf at the stateless intake boundary.
- Healthy steady state, controlled overload, persistent outage/drain, and tail-sampling pressure.
- CPU, RSS, heap where available, disk, network, queue, error/loss, throughput, batch, and latency measurements.
- A quick structural smoke profile and an opt-in qualification profile.
Out of scope¶
- Production SLOs, cloud sizing, vendor-backend capacity, WAN behavior, or cost forecasts.
- Claims that one laptop's absolute result applies to another machine or to production.
- Consumer-owned request mixes and domain semantics.
- Combining persistent queues with tail sampling, which is an unsupported topology.
- Running sustained load in ordinary pull-request CI or against third-party endpoints.
Must remain unchanged¶
- Disabled telemetry remains side-effect free and does not import OpenTelemetry.
- Consumer packages and domain vocabulary stay outside
src/telemetryand Collector base profiles. - Existing queues, timeouts, privacy transforms, cardinality limits, and failure isolation are not relaxed to improve a benchmark result.
scripts/qualify_platform.pyremains the authority for the current compatibility/overhead evidence until an explicitly versioned schema change adopts capacity evidence.
2. Current system and constraints¶
| Evidence | Current fact | Design consequence |
|---|---|---|
scripts/qualify_platform.py |
Validates supplied paired overhead, outage, and soak evidence but does not generate load | Add a producer/orchestrator; do not replace the evaluator |
src/telemetry/otel.py:OpenTelemetryRuntime |
Uses bounded batch processors, a periodic metric reader, and both OTLP transports | Benchmark public runtime calls and flush behavior with the configured bounds |
collector/base.yaml |
Applies memory limiting, identity/safety transforms, sampling/filtering, and batching before fan-out | Capacity must include the real processing chain |
collector/profiles/persistent-queue.yaml |
Enables file-backed queue storage | Measure request rate, request size, disk growth, outage retention, and drain rate |
collector/profiles/tail-routing.yaml and tail-sampling.yaml |
Split routing and stateful sampling; metrics/logs bypass the sampler | Report traces/s, spans/s, trace size, sampler memory, completeness, and bypass progress |
scripts/verify_collector_local.py |
Already owns isolated Docker lifecycle, synthetic inputs, fault injection, and cleanup | Extract or reuse its safe orchestration patterns rather than building a second container framework |
operations/platform.toml |
Queue warnings begin at 70% and critical state at 85%; refusals and enqueue failures are unacceptable | Use the existing 70% warning boundary for the capacity envelope; do not invent a looser queue budget |
docs/specs/09-deployment-inputs-and-preflight.md |
Persistent sizing needs measured request rate R, p95 request bytes B, and recovery throughput |
Emit those values directly from the benchmark report |
The research basis is recorded in
../research/performance-testing.md. The important consequences
are: use an open workload for arrival-rate capacity, measure latency from scheduled arrival to
completion so generator slowdown cannot hide queueing, retain tail percentiles, randomize paired
comparisons, repeat independent trials, and record the environment and raw distributions.
The present gap is therefore not another assertion-only test. It is a controlled measurement system that can prove its own generator and sink had enough headroom.
3. Proposed design¶
3.1 Decisions¶
| ID | Decision | Rationale | Traces to |
|---|---|---|---|
| D-01 | Build three layers: Python emission, Collector-only, and end-to-end | Separates SDK/runtime overhead from Collector and sink limits while preserving a real journey | REQ-01, REQ-03 |
| D-02 | Use scheduled open-loop arrivals for capacity sweeps and record scheduler lag | A closed loop reduces offered load when latency rises and can conceal saturation | REQ-01, REQ-03 |
| D-03 | Define capacity as the highest confirmed rate with generator fidelity, no unexplained loss/refusal, stable queues/resources, CPU and memory headroom, and a declared latency guard | Produces an operationally meaningful, evidence-backed envelope without inventing a production SLO | REQ-01, REQ-03 |
| D-04 | Report the full rate/resource/latency curve, the conservative confirmed capacity, and the first failing point; do not infer a production operating rate | Preserves saturation evidence and avoids turning a local observation into an unsupported capacity plan | REQ-01, REQ-04 |
| D-05 | Use pinned telemetrygen for Collector-only load initially, but declare a trial inconclusive when generator fidelity or headroom fails |
Reuses the repository pin while acknowledging that the alpha generator can itself saturate | REQ-03, REQ-04 |
| D-06 | Use a benchmark-only counting OTLP sink and overlays under collector/tests/; also retain one local-file-capture scenario |
Avoids live backends and separates repository processing capacity from local disk-export capacity | REQ-02, REQ-05 |
| D-07 | Retain one-second raw time series and an immutable normalized JSON summary | Supports independent recomputation and later regression analysis | REQ-04, REQ-06 |
| D-08 | Keep long benchmarks opt-in; ordinary CI validates the harness, schema, calculations, and a low-rate smoke only | Shared CI noise and runtime are unsuitable for absolute-capacity gates | REQ-04, REQ-05 |
| D-09 | Change regression gates only after a reviewed baseline exists; compare only matching environment classes | Prevents one noisy or unlike machine from becoming a false release oracle | REQ-04, REQ-06 |
| D-10 | Treat expected sampling and filtering as classified outcomes, not loss | Head/tail sampling and the log filter intentionally change delivered counts | REQ-02, REQ-03 |
Consequential alternatives:
| Alternative | Advantage | Rejection reason |
|---|---|---|
Extend verify_collector_local.py with a few timers |
Small initial diff | Its assertions use small deterministic corpora and do not model sustained open-loop load or capacity search |
| Adopt the upstream Go Collector testbed wholesale | Mature Collector-specific framework | Adds a second toolchain and does not exercise this package's Python public runtime or repository-specific profiles |
| Benchmark only the Python SDK | Fast and stable | Cannot answer Collector/topology capacity or outage recovery |
| Benchmark only end to end | Directly user-visible | Cannot identify whether the generator, Python runtime, Collector, or sink caused saturation |
| Put the full benchmark in required CI | Continuous evidence | Runner variance, duration, and Docker contention would produce weak and expensive gates |
3.2 Workload contract¶
Every scenario has a versioned workload identity and SHA3-512 digest. It declares signal, transport, topology, payload shape, batch settings, concurrency, arrival schedule, warmup, measurement duration, seed, resource limits, and expected sampling/filtering.
Payload shapes are platform-neutral:
nominal-v1: six required resource fields plus a moderate fixed attribute set. The trace form follows the OpenTelemetry SDK benchmark's ten-attribute throughput shape.safety-ceiling-v1: valid values at the platform's configured count and length ceilings. This quantifies the cost of the Safety Floor without introducing invalid data.balanced-three-signal-v1: equal item rates for spans, metric points, and log records. It tests shared-resource contention but is not presented as a representative consumer mix.tail-traces-v1: deterministic complete traces across fixed spans-per-trace and byte-size buckets, with known error, slow, baseline, incomplete, and late-span classifications.
The full rate search runs per signal and for balanced-three-signal-v1 using the nominal shape. The
safety-ceiling shape runs per signal over the primary gRPC transport; one balanced safety-ceiling point
runs at 80% of the nominal confirmed capacity. This contains the matrix while still measuring the
worst valid data shape.
3.3 Capacity search and repetition¶
For each capacity scenario:
- Run a low-rate calibration to establish delivery-lag and resource baselines.
- Warm the exact topology and payload shape for at least 30 seconds. Continue until three consecutive ten-second windows keep accepted rate, p95 scheduled-to-ack latency, CPU, and RSS within 5% of their combined median, with a two-minute cap; exclude warmup data and fail an unstable point.
- Exponentially increase the scheduled item rate until the first failed or inconclusive step.
- Bisect the last passing/first failing interval until it is at most 5% of the passing rate.
- Run five independent cold-start confirmation trials at both the candidate rate and the point immediately below it, alternating them in randomized order with a retained seed. Each measured window lasts 120 seconds.
- Confirm a 30-minute soak at 80% of capacity and another at the selected capacity for the representative stateless and advanced scenarios.
Each rate step has a 30-second controlled drain period. A trial aborts before uncontrolled resource exhaustion when queue occupancy reaches 85%, any memory-limiter refusal or enqueue failure appears, disk use reaches 85% of its benchmark quota, or the configured wall-clock limit expires.
A trial is:
passwhen the achieved offered rate is within 1% of target, expected count conservation holds, refusal/enqueue/permanent-failure deltas are zero, queue occupancy stays below 70% and returns below 50% during drain, Collector CPU remains below 85% of its allocation, RSS stays below its configured memory-limiter soft threshold, and p99 scheduled-to-ack latency stays below twice its low-load value;failwhen the system under test violates one of those conditions while generator and sink headroom remain valid; orinconclusivewhen the generator misses its schedule, the sink saturates, the environment changes, cleanup is incomplete, or required measurements are unavailable.
The generator is invalid when more than 0.1% of scheduled dispatches miss by more than one inter-arrival interval, when generator CPU exceeds 80% of its allocation, or when container throttling exceeds 1% of the measured interval. These values, the 5% search resolution, the 85% Collector CPU headroom, and the two-times-low-load latency guard are measurement-contract proposals to approve with this design, not production SLOs. Reports retain all five trials, the median and range, and a deterministic bootstrap 95% confidence interval. The reported confirmed capacity is the lower confidence bound of achieved items/s at the highest point that passes every confirmation trial; no best-run result is the headline.
3.4 Measurements and accounting¶
| Category | Required observations |
|---|---|
| Load | target, scheduled, generated, acknowledged, Collector accepted/refused, sink received, expected sampled/filtered, unexplained loss |
| Rate | spans/s, traces/s, metric-points/s, log-records/s, OTLP requests/s, bytes/s |
| Latency | generator scheduling lag; OTLP request p50/p95/p99/max; source-to-sink delivery p50/p95/p99/max; flush and drain duration |
| Collector | process CPU, RSS, heap, receiver/processor refusals, sent/failed/enqueue-failed items, queue size/capacity, exporter duration |
| Runtime/generator/sink | CPU, RSS, thread count, achieved-rate fidelity, internal queue/drop diagnostics, sink queue and write latency |
| Persistent queue | p95 request bytes, queue and storage high-water marks, disk bytes per queued request, recovery requests/s, drain duration, duplicates |
| Tail sampler | traces/s, spans/s, spans/trace, bytes/trace, pending trace count, policy outcomes, evictions/refusals, complete-trace rate, late-span outcomes |
| Environment | source and wheel digests, lock, image digests, configuration fingerprint, OS/architecture, CPU model/count, memory, Docker version and limits, filesystem, Python and dependency versions |
Hostnames, usernames, environment values, credentials, telemetry bodies, and arbitrary exception text are forbidden in retained evidence.
For stateless flows, the independent count oracle is:
generated = receiver_refused + accepted
accepted = expected_filtered + expected_sampled_out + delivered + unexplained_loss
For tail sampling, whole-trace outcomes are reconciled against deterministic trace IDs and policy fixtures; a sampled trace is complete only when all expected spans arrive. Persistent delivery permits duplicates and reports them separately because the contract is at-least-once.
3.5 Runtime and data flow¶
flowchart LR
O[Benchmark orchestrator] --> G[Runtime driver or pinned telemetrygen]
G --> C[Collector topology under test]
C --> S[Counting OTLP sink or bounded file capture]
O --> GM[Generator/runtime resource samples]
O --> CM[Collector self-metrics]
O --> SM[Sink resource and count samples]
GM --> R[Raw time series]
CM --> R
SM --> R
S --> R
R --> V[Report validator and capacity classifier]
V --> J[Normalized JSON summary]
The orchestrator creates unique Docker names, networks, ports, volumes, and output directories. It
starts measurement dependencies, validates health, runs the workload, drains, scrapes final counters,
classifies the trial, writes evidence atomically, and cleans up in a finally path. Interrupted runs
remain inconclusive and never overwrite a completed report.
3.6 Change surface¶
| Path / artifact | Planned responsibility |
|---|---|
benchmarks/workloads/*.toml |
Versioned workload and matrix definitions; no credentials or consumer vocabulary |
collector/tests/performance/*.yaml |
Verification-only counting-sink and advanced-profile overlays |
scripts/run_performance.py |
Bounded orchestration, environment capture, workload execution, cleanup, and raw evidence |
src/telemetry/performance/ |
Public Consumer evaluation module and dependency-free shared statistics |
scripts/validate_performance_report.py |
Capacity-specific schema, conservation, classification, and comparison adapter |
tests/unit/test_performance_analysis.py |
Deterministic classifier, trend, percentile, confidence, and schema contracts |
tests/delivery/test_performance_harness.py |
Pinned images, safe overlays, Make targets, cleanup, and report wiring |
Makefile |
perf-smoke, perf-capacity, and focused scenario entry points |
docs/performance-testing.md |
Operator procedure, result interpretation, limitations, and retained artifacts |
scripts/qualify_platform.py |
Later schema-versioned reference to an accepted capacity artifact; no silent change to schema 2 |
docs/specs/10-verification-packaging-and-release.md |
Long-run policy and evidence contract after approval |
docs/specs/11-traceability-and-inventory.md |
New source and executable evidence inventory |
The public telemetry.performance module owns generic Evaluation Cases, Measurements, repeated trials,
statistics, reports, comparison, and Assessment Rules. Collector-only orchestration remains in scripts
because Docker topology, OTLP accounting, and host identity are Capacity Evaluation concerns. The
runtime driver must use the public TelemetryRuntime/Telemetry interface and must not add benchmark
hooks to production classes.
3.7 Consumer performance evaluation seam¶
Consumer projects pass private case inputs and expected values plus an Algorithm Candidate callable to
PerformanceEvaluator. Case-level, corpus-level, and structural custom Measurement adapters reduce
each trial to finite scores. Inputs, expected values, outputs, case names, and exception messages remain
in-process; the immutable Evaluation Report retains only counts, timing, scores, uncertainty, and safe
failure classifications. Compatible reports support objective-aware comparison, threshold rules, and
regression rules without assigning product meaning to the platform.
4. Test design¶
4.1 Risk-to-evidence map¶
| ID | Risk | Observation and boundary | Required evidence |
|---|---|---|---|
| R-01 | Closed-loop or coordinated-omission bias hides saturation | Scheduled-versus-actual arrival and scheduled-arrival latency in the driver | V-02, V-06 |
| R-02 | Generator or sink is the bottleneck | Per-process resource use and achieved-rate fidelity | V-03, V-06 |
| R-03 | Intentional sampling/filtering is reported as loss | Independent deterministic count reconciliation | V-04, V-08 |
| R-04 | Queue growth appears stable during a short run | One-second queue series, drain check, and 30-minute soak | V-06, V-09 |
| R-05 | Persistent queue loses data or cannot recover | Outage, restart, duplicate-aware count, and measured drain rate | V-07 |
| R-06 | Tail sampler evicts or fragments traces under pressure | Whole-trace oracle, policy outcomes, memory/refusal metrics | V-08 |
| R-07 | Machine noise or setup order biases comparison | Five trials, retained random order/seed, raw distribution, confidence interval | V-01, V-06 |
| R-08 | Load test damages external systems or the workstation | Local endpoints, resource/disk/time aborts, unique resources, cleanup | V-05, V-10 |
| R-09 | A local number is presented as production capacity | Environment fingerprint and mandatory scope/limitation fields | V-01 |
4.2 Verification cases¶
| ID / exact test name | Level and seam | Given / When | Then / independent oracle | Pre-change signal |
|---|---|---|---|---|
V-01 / test_performance_report_requires_reproducibility_identity |
Unit; report validator | Remove each candidate, environment, config, workload, seed, or raw-artifact identity | Report is rejected; oracle: REQ-04 | RED: validator/module absent |
V-02 / test_capacity_analysis_uses_scheduled_arrival_latency |
Unit; analysis | Actual sends lag scheduled arrivals during a synthetic stall | Queueing delay remains in p99; oracle: scheduled timestamps | RED: analysis absent |
V-03 / test_generator_limited_trial_is_inconclusive |
Unit; classifier | Generator violates schedule, CPU-headroom, or throttling validity without SUT refusal | Result is inconclusive, never a capacity pass/fail |
RED: classifier absent |
V-04 / test_signal_accounting_separates_policy_outcomes_from_loss |
Unit; count model | Fixed accepted, sampled, filtered, delivered, and refused counts | Only the unexplained residual is loss | RED: count model absent |
V-05 / test_performance_harness_is_local_bounded_and_cleanup_safe |
Delivery/static | Inspect declared endpoints, quotas, timeouts, names, and cleanup paths | No vendor endpoint/secret; every resource is bounded and uniquely cleaned | RED: assets absent |
V-06 / perf-smoke plus stateless qualification |
Docker; OTLP ingress-to-sink | Nominal traces, metrics, logs, and balanced load over gRPC and HTTP | Raw and normalized counts, tails, resource metrics, and capacity classification are retained | RED: target absent |
| V-07 / persistent qualification | Docker; persistent queue | Healthy load, bounded outage/restart, restored sink, continuing arrivals | Queue/storage stay bounded, at-least-once data drains, duplicates are explicit, recovery rate and duration are measured | RED: scenario absent |
| V-08 / tail qualification | Docker; router/sampler/sink | Deterministic traces at increasing rates plus concurrent metrics/logs | Complete policy-correct traces; pressure is classified; metrics/logs bypass and progress | RED: scenario absent |
| V-09 / representative 30-minute soak | Docker; end to end | Run at 80% and at the selected confirmed capacity | No monotonic queue/resource leak; counts remain reconciled | RED: capacity runner absent |
V-10 / test_interrupted_run_is_inconclusive_and_recoverable |
Delivery; lifecycle | Interrupt each orchestration phase | Partial evidence is not accepted and no benchmark resource remains | RED: lifecycle absent |
Full load and soak cases are characterization/qualification evidence, not conventional TDD red tests. Their deterministic schemas, calculations, safety controls, and low-rate path are test-first; absolute capacity is established only by controlled execution on a declared environment.
4.3 Required commands¶
The implementation must expose:
make perf-smoke
make perf-capacity PERF_SCENARIO=stateless-traces-grpc
make perf-capacity PERF_SCENARIO=all
perf-smoke must finish within the existing Docker job scale and prove wiring only. perf-capacity
is opt-in, writes under .build/performance/<run-id>/, never publishes, and refuses to run if required
Docker limits or free disk checks are unavailable. The existing make test-static, make test-unit,
make test-integration, and make test-docker remain required implementation gates.
5. Delivery slices¶
| Slice / Linear issue | Capability after completion | Dependencies |
|---|---|---|
| S-01 / PL-65 | Approved benchmark contract, workload identities, report schema, and deterministic validator tests | None |
| S-02 / PL-66 | Safe orchestrator, counting sink, environment capture, rate fidelity, and low-rate smoke | S-01 |
| S-03 / PL-67 | Stateless per-signal, balanced, transport, runtime, and local-file capacity reports | S-02 |
| S-04 / PL-68 | Persistent healthy/outage/restart/drain measurements and preflight sizing outputs | S-02, S-03 |
| S-05 / PL-69 | Tail-router/sampler pressure, completeness, and bypass measurements | S-02, S-03 |
| S-06 / PL-70 | Repeated-trial statistics, 30-minute soak, normalized comparison report, and operator docs | S-03, S-04, S-05 |
| S-07 / PL-71 | Reviewed local baseline and explicit decision on release-evidence/CI regression adoption | S-06 |
Each slice adds the narrow deterministic tests first, then the smallest Docker smoke that exposes its
real boundary. Performance thresholds are not loosened to obtain a pass; a resource-limited or noisy
environment produces an inconclusive result with retained evidence.
6. Evidence and adoption policy¶
The first accepted run establishes a baseline; it is not retroactively a requirement. Reviewers must inspect raw distributions, bottleneck classification, environment identity, and run-to-run variation before adopting any regression threshold.
Recommended adoption stages:
- Informational: local/periodic manual runs produce reports; CI validates only the harness.
- Comparable baseline: a controlled runner records at least three accepted baselines across time.
- Regression gate: only matching environment classes are compared, with both an accepted practical budget and uncertainty interval. Any environment or generator failure remains inconclusive, not a product regression.
- Qualification integration: bump the qualification evidence schema and require a checksummed capacity artifact only after the gate has demonstrated acceptable stability.
Rollback is deletion of benchmark-only assets and removal of opt-in Make targets. It does not require a package or Collector-profile migration. Retained historical reports keep their schema identity.
7. Risks and resolved decisions¶
| Risk / trigger | Prevention or detection | Mitigation / fallback | Owner |
|---|---|---|---|
| Pinned telemetrygen cannot drive the SUT | Achieved-rate and generator-resource gates | Parallel pinned generators or a separately reviewed generator change; report inconclusive meanwhile | telemetry-platform |
| Counting sink changes the bottleneck | Sink CPU/RSS/queue and isolated sink calibration | Lower sink work, allocate separate resources, and retain local-file scenario | telemetry-platform |
| Docker Desktop obscures CPU allocation | Record Docker/host resources and effective limits | Treat results as that Docker environment only; use a controlled Linux runner for cross-run baselines | release owner |
| Matrix runtime becomes excessive | Representative interactions plus targeted boundary shapes | Keep quick, qualification, and soak profiles separate | telemetry-platform |
| Capacity definition is mistaken for an SLO | Mandatory scope and environment fields | Rename/report as local measured envelope; production sizing remains external | release owner |
Resolved assumptions:
- The requested “system” is the reusable Python telemetry runtime plus repository-owned Collector delivery mechanics, not a specific consumer or backend.
- Local capacity is meaningful only with a recorded environment and resource envelope.
- The existing 70% queue warning is the only repository-approved headroom boundary available today.
- Long performance runs are explicitly local/opt-in and never authorize load against live services.
Open questions: none required for implementation after maintainer approval. Vendor- or consumer-specific workloads are separate future requirements.
8. Readiness¶
- [x] Scope, non-goals, current behavior, and unchanged boundaries are explicit.
- [x] Research and repository evidence support the measurement strategy.
- [x] Capacity, bottleneck, accounting, safety, and evidence contracts are concrete.
- [x] Risks trace to discriminating verification cases.
- [x] Delivery slices are dependency ordered.
- [x] Long-run adoption does not claim approval or existing benchmark results.
- [ ] Maintainer approves design revision 2 and the proposed measurement-contract thresholds.
Author gate: READY FOR REVIEW; not approved for implementation yet.