GAURAV VARMA
Rails 8.1 introduces Structured Event Reporting, a new way to emit structured events across your application using a unified Rails.event interface. Authentication flows generated by the Rails 8 authentication system and long-running workflows powered by Active Job Continuations can both emit rich, structured events.
Rails applications already have powerful instrumentation through ActiveSupport::Notifications, but many teams still rely on custom logging or external tools to emit structured operational events.
Structured Event Reporting provides a simple and consistent API for generating machine-readable events that can be consumed by observability tools, logs, or analytics systems.
What is Structured Event Reporting?
Structured Event Reporting allows developers to emit typed, structured events instead of plain log messages.
Instead of writing text-based logs, applications can emit events containing structured data.
Example event:
1Rails.event "user.login", user_id: user.id, ip: request.remote_ipThis produces an event with metadata that can be analyzed by monitoring or analytics systems.
Why structured events?
Traditional logs are difficult to parse and analyze because they rely on free-form text.
Structured events solve this problem by producing machine-readable data.
Benefits include:
- easier log analysis
- better observability
- integration with monitoring systems
- consistent event formatting
Structured logging is widely used in distributed systems and modern observability platforms.
Emitting an event
Rails applications can emit events using the new interface:
1Rails.event "order.created", order_id: order.id, total: order.totalThe event includes:
- event name
- structured attributes
- timestamps
- context information
These events can then be consumed by logging frameworks or event pipelines.
Example use cases
Structured events are useful for many application-level events:
- user sign-ins
- order creation
- background job completion
- payment processing
- API requests
This allows teams to track operational behavior without relying solely on logs.
Integrating with observability tools
Events emitted via Rails.event can be forwarded to:
- log aggregation systems
- metrics platforms
- event pipelines
- analytics dashboards
This makes Rails applications easier to monitor in production environments.
Links
Summary
Structured Event Reporting gives Rails developers a clean and consistent way to emit application events. With the new Rails.event interface, applications can produce structured, machine-readable data that improves observability and monitoring.