API monitoring with custom instrumentation

6240
0

Production visibility requires more than basic request logging. I instrument critical code paths using ActiveSupport::Notifications to publish custom metrics that monitoring services consume. Each instrumented block publishes events with timing data, metadata, and success/failure indicators. I track business metrics like API calls to external services, cache hit rates, and background job durations. These metrics feed into dashboards and alerts that surface degradations before they become outages. The instrumentation API is lightweight and doesn't require external dependencies—I can log to Rails logger in development and ship to Datadog or StatsD in production by subscribing to the notification channel.