Skip to content

Lesson 9 of 9 · 25m

Observability, Clock Skew, and Incident Response for Time Bugs

Instrument event time, processing time, clock health, schedule lag, and timezone versions so temporal incidents can be reconstructed instead of guessed.

When time logic fails, the first operational question is rarely philosophical. It is "which timeline are we looking at?" Logs interleave badly, dashboards disagree, a queue message carries the customer's clock, and the database records ingestion in UTC. If you did not label the timeline before the incident, you will reconstruct it painfully during the incident.

Log more than one kind of time

Distinguish these fields explicitly:

{
  "event_time": "2026-11-30T13:14:59Z",
  "ingested_at": "2026-11-30T13:15:04Z",
  "processed_at": "2026-11-30T13:15:07Z",
  "schedule_key": "2026-11-30",
  "timezone": "America/New_York"
}

Event time is when the thing happened. Ingestion time is when your system first saw evidence of it. Processing time is when a worker acted. They can differ by milliseconds in a healthy system or days during an outage. Collapsing them into timestamp destroys the distinction.

Monitor schedule lag, not merely success

A job can succeed every time and still be late enough to be operationally useless. Emit metrics for intended occurrence time versus actual start:

schedule_lag_seconds = actual_start - intended_start
queue_age_seconds = dequeue_time - enqueue_time
clock_offset_seconds = local_wall_clock - trusted_reference

Alert on schedule lag for user-facing workflows. A reminder sent after the meeting is not a successful execution; it is a false positive in your health checks.

Clock skew is a security and correctness issue

Distributed systems depend on approximate clock agreement for TLS certificate validation, token expiry, cache TTLs, and event ordering. Track synchronization state:

chronyc sources -v
chronyc tracking
timedatectl show-timesync --all

Do not build security critical decisions on tiny timestamp differences unless you understand the error budget. Token expiry should include reasonable leeway; ordering across machines should use sequence or causality where correctness matters.

Version the rules as well as the code

When behavior changes after a tzdata update, application code may be identical. Record timezone database version, runtime version, host timezone, and container image digest in deploy metadata. In JavaScript systems, record the runtime's ICU behavior if you rely on internationalization APIs. In Python, record whether tzdata is packaged.

Build incident timelines defensively

During analysis, convert everything to UTC first and annotate source confidence. A browser report of "about 9 AM" is not equivalent to a server log instant. Preserve original strings before normalization; timezone conversion is lossy when the original representation was ambiguous. Use sequence IDs, trace IDs, and database commit order to support or contradict timestamp order.

Practice the failure before production does

Game days should include stopping a scheduler, filling a queue, moving a test clock across DST, and replaying a backfill. You are testing operational procedure as much as code. Can you rerun only missed partitions? Can you suppress stale notifications? Can you prove no duplicate charge was created? If the answer is "probably," the design is unfinished.

Field notes

  • Never use a single field named time in events that cross service boundaries.
  • Dashboards should display UTC by default for operations, with explicit local rendering only when labeled.
  • Include timezone and rule-version metadata in support tickets involving appointments or recurring schedules.
  • A clock rollback can make negative durations appear in metrics; clamp display if needed, but preserve the raw evidence.

Was this lesson helpful?

Sign in to rate