Add GVL/allocation instrumentation and optional log fields#58
Conversation
|
🤖 AI-assisted review (Claude Code), non-blocking. Nice that the patches are opt-in (require-your-own) and covered by specs. Two small notes:
|
tycooon-review-bot
left a comment
There was a problem hiding this comment.
Claude Code (AI review) — reviewed against origin/main.
Clean, well-scoped extraction. Verified the parts that are easy to get wrong: the three instrumentation files are genuinely opt-in (the gem's entrypoint uses explicit require_relative and doesn't load them, so require "gvltools" only fires for consumers who opt in), GVLTools::LocalTimer.monotonic_time is nanoseconds so / 1_000_000.0 → ms is correct, GC.stat(:malloc_increase_bytes) reads the single key without allocating the stat hash, and the base gem really does define extract_path (the spec stub mirrors it). The prior review's two notes (GC.stat allocation, negative/cross-thread malloc) are already addressed in the current code.
Two non-blocking notes:
- P1 —
add_stats(rails_semantic_logger) andmetrics_payload(sidekiq_job_metrics) duplicate the same 6-stat extraction block plus a secondPRECISION = 6; worth extracting a shared helper. - P2 — the controller patch leaves the raw
:exception_objectin the logged payload on failed actions, inconsistent with the Sidekiq path (which keeps only[class, message]).
No P0s. The TinyJsonFormatter optional-fields change is backward-compatible. CI is green across Ruby 3.3 / 3.4 / 4.0.
tycooon-review-bot
left a comment
There was a problem hiding this comment.
APPROVED — Claude Code (AI review). Both findings addressed in 25fcc21 with tests (P1: shared ActiveSupportEvent#stats; P2: :exception_object dropped + failed-action spec). CI green on Ruby 3.3/3.4/4.0.
Extracted GVL/memory instrumentation from our applications into the shared gem.
Added new files (loaded only via explicit
require):patches/active_support_event— adds#gvl_timeand#malloc_increase_bytestoActiveSupport::Notifications::Event;patches/rails_semantic_logger— enriches the "Completed" action log entry with GC/GVL/allocation stats;semantic_logger/sidekiq_job_metrics— same stats for Sidekiq jobs.TinyJsonFormatternow supports optionaldurationandpayloadkeys incustom_names_mapping. Previously such keys were silently ignored. Output is unchanged unless the keys are explicitly requested.