RubyFlow The Ruby and Rails community linklog

×

The Ruby and Rails community linklog

Made a library? Written a blog post? Found a useful tutorial? Share it with the Ruby community here or just enjoy what everyone else has found!

Wide Events: Token-efficient Rails telemetry for coding agents

I released Wide Events, a Rails gem that records each request or job execution as one dense, high-cardinality telemetry event. It gives coding agents queryable production context without making them reconstruct what happened from scattered logs, spans, and metrics. Agents can retrieve only the relevant rows and fields for a route, account, build SHA, feature flag, or error, keeping the context compact.

The event is attached to the OpenTelemetry root span. If you do not use tracing, a log sink emits the same event as a single JSON line. I extracted the gem from a production Rails app where it currently exports to a self-hosted ClickStack setup, although any OTLP backend should work.

One request in that app performs a hybrid search and drafts a reply with an LLM. Its event includes the account, active feature flags, search-quality measurements, model, token usage, cost, and Postgres query count. Instead of collecting that context from several systems, an agent can query one row.

More example on how we use this on production here.

The gem also includes a generator that installs agent skills for adding instrumentation and querying the resulting events. Attributes are declared in a YAML registry that can be enforced in tests and CI, handled errors receive explicit slugs, and instrumentation never raises into application code.

Wide Events supports Ruby 3.2+ and Rails 7.1+ and is MIT licensed. I would especially appreciate feedback on the agent workflow, registry design, and attribute naming conventions.

Comments

I wrote up the production problem behind Wide Events, a Rails gem that adds application context to the OpenTelemetry root span for each request or job. The article uses real, sanitized production data to compare one compact root event with the full trace and shows how a coding agent can use it to investigate and verify production behavior.

https://dev.to/adammiribyan/one-rails-request-one-event-production-context-for-coding-agents-47n3

Post a comment

You can use basic HTML markup (e.g. <a>) or Markdown.

As you are not logged in, you will be
directed via GitHub to signup or sign in