Skip to content

Speed & Slowdown Analyser

In plain English

Reads raw website response logs, flags unusual speed spikes or missing records, and draws clear visual summary charts automatically.

A Python 3.12 pipeline validating CSV service logs into SQLite before computing pandas percentile rollups, anomaly detection, and Matplotlib SVG exports.

1. Why I built it

Built to pair strict CSV ingestion checks with vectorised statistical aggregation and zero-variance safeguards.

Problem being solvedCorrupted CSV values (`NaN`, negative latencies) distort percentiles, and arithmetic means mask 95th-percentile latency spikes.

2. How it works

Implemented `TelemetryRecord`, `ServiceStatistics`, `AnalyticsWorkbench`, and `pearson_correlation` in `src/data_workbench/pipeline.py`.

Service telemetry CSVs frequently arrive with missing identifiers, non-finite floats, negative durations, or impossible error percentages (`> 100%`). Feeding dirty exports directly into analytics skews tail percentiles silently.

`AnalyticsWorkbench` verifies `csv_path.is_file()` and required header columns first, validates `math.isfinite()` and domain ranges per row, tracks accepted vs rejected counts, and batch-inserts clean records into SQLite with `executemany()`.

From SQLite, pandas computes per-service medians (`p50`), 95th percentiles (`p95`), and population standard deviation (`σ`) via NumPy, alongside positive-threshold Z-score anomaly flags, finiteness-checked Pearson `r` correlation, and headless Matplotlib SVG bar charts.

3. Output & Source Specimen

Pipeline Stages & Data Contracts

011. ingest_csv() -> Checks file & headers; rejects latency < 0, error_rate > 100, non-finite
022. sqlite3 executemany() -> Batch writes valid TelemetryRecord rows into service_telemetry
033. summarise_by_service() -> Aggregates count, mean, p50, p95, pstdev per service via pandas
044. detect_anomalies() -> Requires z_threshold > 0; guards pstdev == 0.0 zero-division
055. render_svg() -> Headless Matplotlib Agg p50 vs p95 chart export
Validation rules and statistical stages defined in src/data_workbench/pipeline.pyRun checks: pytest -v tests/test_pipeline.py

4. Design Decisions & Challenges

Key Design Decisions

  • 01.Validated file existence and required CSV headers upfront in `ingest_csv()` before iterating rows.
  • 02.Used SQLite `executemany()` with finiteness assertions and positive `z_threshold` validation.
  • 03.Configured Matplotlib's headless `Agg` backend for consistent SVG chart generation in CI environments.

Edge Cases Handled

  • Guarding `detect_latency_anomalies()` and `pearson_correlation()` against zero-variance inputs (`pstdev == 0.0`) and non-finite numbers.

5. Testing & Limits

Automated Checks

Verified by 5 pytest suites in `tests/test_pipeline.py` checking malformed row rejections, header validation, p50/p95/p99 percentiles, Z-score anomalies, Pearson `r`, grouped SVG export, and exit code 2 input validation.

Current Limits & Next Steps

  • Z-score filtering assumes symmetric spread around the mean; adding IQR or MAD thresholds would suit heavily skewed latency curves.

6. Key Takeaways

What building Speed & Slowdown Analyser reinforced

Explicit validation counters make data quality measurable, while comparing `p50` against `p95` shows why averages understate tail spikes.

  • — 5 pytest checks and Ruff lint pass cleanly in CI.
  • — Source hosted at github.com/16lv/telemetry-latency-analyser.

Recent Activity

Latest repository updates

All changes for 16lv/telemetry-latency-analyser

fix: validate --z-threshold upfront and emit exit code 2 on CLI input errors

Checked finite positive --z-threshold values before CSV ingestion and handled invalid input paths cleanly in telemetry-analyser.

2026-11-247cfbc08

fix: group p50/p95/p99 latency bars clearly in exported chart

Updated export_latency_chart() in telemetry-latency-analyser to plot three aligned p50/p95/p99 bars per service.

2026-11-2334b7a14

Add python -m data_workbench runner and verify editable install in CI

Committed directly to telemetry-latency-analyser (main) · Reads raw website response logs, flags unusual speed spikes or missing records, and draws clear visual summary charts automatically.

2026-11-215cec857