方寸 Portal

AI Engineer Portal

Your personal operating system for career transition.

Private mode

Exercise

Build an observability metrics aggregator

Build an Observability Metrics Aggregator

Production LLM services emit request events. An aggregator processes them into the operational metrics that matter: latency percentiles, error rates, cost by feature, quality trend.

What to build

LLMObservabilityAggregator processing RequestEvent(timestamp, feature, model, latency_ms, input_tokens, output_tokens, success, quality_score):

  1. ingest(event)
  2. latency_percentiles(feature=None) -> dict{"p50", "p95", "p99"} in ms
  3. error_rate(window_minutes=60) -> float
  4. cost_by_feature(model_prices: dict) -> dict
  5. quality_trend(bucket_minutes=60) -> list[dict][{"bucket_start", "avg_score", "count"}] oldest-first, only scored events

Constraints

  • Standard library only.
  • Nearest-rank percentile: ceil(p/100 * n) - 1 index into sorted array.

Evaluation / medium / Step 18 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.