Monitoring & Observability
Observability goes beyond logs: combine metrics, traces, and events to answer “what is happening?” without redeploying code. Ruby offers hooks like ActiveSupport::Notifications, TracePoint, and third-party agents that integrate with Datadog, Honeycomb, or OpenTelemetry.
Three pillars of observability
Metrics
Quantitative measures (request latency, Sidekiq queue depth). Send via StatsD, Prometheus exporters, or OpenTelemetry metrics APIs.
Logs
High-cardinality, structured events (see Logging topic) that support full-text search and incident forensics.
Traces
End-to-end request timelines across services. Capture spans in controllers, jobs, and external HTTP clients.
Instrument with Notifications
Wrap critical flows (`LessonPublisher`, AI responses, Sidekiq jobs) so dashboards can chart latency and throughput without extra code.
Low-level instrumentation
Combine TracePoint with sampling to avoid performance degradation. For performance analysis, pair with `stackprof` or `flamegraph` to visualise call stacks.
Monitoring checklist
- Alert on failing Sidekiq jobs, queue latency, and AI response times; route incidents to Slack with PagerDuty escalation.
- Dashboards should correlate metrics (error rate, request latency) with deploy markers to spot regressions quickly.
- After incidents, add postmortem action items—instrument the missing signals or tighten alert thresholds.