BlogsShopifyProduction Rails Debugging Tools

Production Rails Debugging Tools

Production Rails Debugging Tools

2
posts
2015–2016

This feature thread tracks the development and enhancement of tools and strategies for debugging production Rails applications. Initial efforts focused on addressing the challenges of quickly identifying and resolving issues without extensive code changes or deployments. This post details the use of Ruby's introspection methods (`#class`, `#is_a?`, `#instance_methods`, `#method`, `#caller`, `#instance_variables`, etc.) and class/module methods (`::name`, `::class_variables`, `::instance_methods`, `::ancestors`, `::constants`, etc.) to inspect object types, inheritance, available methods, instance and class variables, and constants. It also covers the use of debuggers like `debugger` and `byebug` with commands like `var`, `backtrace`, and `frame` for live code inspection. The thread also touches upon the broader topic of production debugging tools, including the use of `gdb` for core dumps and inspecting Ruby object representations.

2016

Adventures in Production Rails Debugging - Shopify

3/8/2016

This post introduces and details the practical application of `gdb` for debugging production Rails applications. It outlines a step-by-step process for attaching to a running process, setting breakpoints in C source files of the Ruby interpreter, generating core dumps for later analysis, and using Python scripts within `gdb` to retrieve Ruby call stacks and inspect Ruby string objects. The specific problem solved was identifying a UTF-8 warning triggered by malformed cookie data, leading to a temporary monkey-patch solution.

2015

There's More to Ruby Debugging Than puts() - Shopify

2/24/2015

This post introduces and details several under-utilized Ruby introspection methods (`#class`, `#is_a?`, `#kind_of?`, `#instance_of?`, `#methods`, `#public_methods`, `#protected_methods`, `#private_methods`, `#singleton_methods`, `#method`, `#caller`, `#instance_variables`, `#instance_variable_get`, `#instance_variable_set`, `#instance_variable_defined?`, `#remove_instance_variable`) and class/module methods (`::name`, `::class_variables`, `::class_variable_get`, `::class_variable_set`, `::class_variable_defined?`, `::remove_class_variable`, `::instance_methods`, `::instance_method`, `::included_modules`, `::superclass`, `Module.nesting`, `::ancestors`, `::constants`, `::const_get`, `::const_set`, `::const_defined?`) that aid in debugging Ruby code. It also provides an overview of debugger commands (`var`, `backtrace`, `frame`, `help`) available in gems like `debugger` and `byebug`.