Log every HotCell call to the Rails log by default - #78
Merged
Merged
Conversation
Each application that wanted a log line per call had to write its own `perform.hot_cell` subscriber. Add `HotCell::LogSubscriber`, which the railtie attaches, and describe its line in the README. [Fix #10]
When an exception escaped the call, such as the application's own request timeout, `HotCell::LogSubscriber` logged the call as `"code":"ok"` with no cell and no operation. Put the cell and the operation on the event before the call, and log the exception's class in place of the code.
This was referenced Sep 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
The client publishes the
perform.hot_cellActive Support notification on every call, success or failure (client.rb). Its payload carries the cell, the operation, the failure code and cause, the tool'sstderr, the byte counts, and the time the cell measured (publish).Nothing in the gem turns that event into a log line. An application that wanted one line per call had to write its own subscriber, and each application that adopted HotCell wrote the same one.
Details
HotCell::LogSubscriberis anActiveSupport::LogSubscriber. It writes oneinfoline per call:A failed call adds
causeandstderrwhen it has them. A call that an exception interrupts, such as the application's own request timeout, logs the exception's class in place of the code.stderris text a tool wrote while reading an untrusted file. It goes only inside the JSON, which is ASCII-only, so neither a newline nor a Unicode line separator in it can forge a log line.The railtie attaches the subscriber at boot, so a Rails application logs to
Rails.loggerwith no setup. An application turns it off withHotCell::LogSubscriber.detach_from :hot_cell. Without Rails, an application requireshot_cell/log_subscriber, callsattach_to :hot_cell, and setsActiveSupport::LogSubscriber.logger.An application that already logs this event should delete its own subscriber, or it will log each call twice. The CHANGELOG says so under "Upgrading".
Fixes #10