One Rails request, one event: production context for coding agents
Wide Events is a Rails gem that puts the production context a coding agent needs onto one OpenTelemetry root span per request or job. In one production search request, the root event showed 30.0 seconds total duration, 446 ms of Postgres time, and 29.4 seconds of outbound HTTP time. That was enough to focus the investigation on an external dependency. The trace then identified a POST that took…
Wide Events is a Rails gem that gathers production context for coding agents onto a single OpenTelemetry root span per request or job. A recent production search request demonstrated this, with a total duration of 30.0 seconds, 446 ms of Postgres time, and 29.4 seconds of outbound HTTP time. The trace highlighted a problematic POST that took 28.9 seconds, containing 82 spans and 20,261 bytes of attribute JSON. The root event held 40 attributes and 1,420 bytes.
Coding agents have the advantage of accessing every model, controller, job, migration, and test within a few seconds. However, they also lack crucial information about the running system, such as which account experienced the issue, the build being used, active feature flags, query counts, LLM call costs, and whether the issue appears in one or all tenants.
Wide Events addresses this by accumulating context while processing one unit of work, then attaching it to the OpenTelemetry root span. The span is marked as main=true, allowing each request or job to be queried as a single row. The context is stored in ClickHouse and can be queried as one row, or emitted as a single JSON log line if tracing is not in use.
To set up Wide Events, Ruby 3.2 or newer and Rails 7.1 or newer are required. After generating the installation files and configuring the gem, attributes such as user type, account ID, and search results can be added to the event. The gem works with existing OTLP backends and provides request and Active Job boundaries, while allowing developers to define their own application context.
For async work, one initiating request and a subsequent generation job are linked by an opaque identifier, emitted as separate events. This ensures visibility and proper tracking of asynchronous processes.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.
