Context & User
Adding context to errors helps you debug faster by understanding exactly what was happening when an error occurred.User Context
Identify which user experienced the error:In Rails
Set user context in a before_action:Custom User Fields
Add any fields relevant to your app:Tags
Tags are indexed for fast searching:Extra Context
Add arbitrary data to the error:Request Context
Automatically captured in Rails:- URL - Full request URL
- Method - GET, POST, etc.
- Headers - Request headers (sensitive ones filtered)
- Params - Request parameters (sensitive ones filtered)
- Session - Session data
Filtering Sensitive Data
Configure which fields to scrub:Environment Context
Automatically captured:- Ruby version
- Rails version
- Gem versions
- Hostname
- Process ID
- Git commit
- Git branch
Block-Scoped Context
Add context for a specific operation:Per-Error Context
Add context when capturing:Context Priority
When the same key exists in multiple places:- Per-error context (highest priority)
- Block-scoped context
- Global context (lowest priority)