方寸 Portal

AI Engineer Portal

Your personal operating system for career transition.

Private mode

Exercise

Build a quality monitoring dashboard data pipeline

Build a Quality Monitoring Dashboard Data Pipeline

Transform raw LLM request traces into hourly quality snapshots suitable for a time-series monitoring dashboard.

What you are building

Implement a QualityPipeline that:

  1. Ingests raw trace events -- each event has trace_id, feature_name, timestamp_ms, pass_rate, latency_ms, prompt_tokens, completion_tokens.
  2. Aggregates into hourly buckets -- for each (feature, hour) pair, compute: sample count, avg pass rate, P95 latency, total tokens, estimated cost.
  3. Detects anomalies -- flags hours where the pass rate is more than 1.5 standard deviations below the feature's 7-day rolling average.
  4. Generates a dashboard payload -- returns a dict keyed by feature name with hourly snapshots and an anomalies list.
  5. Estimates cost -- use pricing of $3/million input tokens and $15/million output tokens.

Constraints

  • Use only the Python standard library.
  • Bucket events by UTC hour (floor timestamp to hour boundary).
  • Anomaly detection requires at least 7 hourly data points before flagging.

Evaluation / medium / Step 11 of 36

Practice stage

Evaluation and review loops

Hint

Separate the scoring logic from the interpretation logic. Your goal is not just a number; it is a useful next action.

Success criteria
  • - Produces a useful signal, not decorative output
  • - Makes regression review easier
  • - Would support a benchmark or observability loop
Review checklist
  • - Would this output help decide what to fix next?
  • - Are important failure modes visible?
  • - Does the score hide any ambiguity I should record?

Practice

Generate a variation

Generate a new exercise variation to deepen understanding or practice a related concept.

Attempt history

Recent submissions

Before you submit, decide what a strong answer should make obvious to the reviewer.

No attempts yet.