Skip to content

fix: treat ephemeral containers consistently - #276

Merged
adamlogic merged 3 commits into
mainfrom
platform-refactor
Jun 16, 2026
Merged

adamlogic merged 3 commits into
mainfrom
platform-refactor

Conversation

@adamlogic

@adamlogic adamlogic commented Jun 12, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Treat release and one-off runtime containers as ephemeral platform instances.
  • Skip reporting from ephemeral containers in the shared reporter so Rails and Rack entry points behave consistently.
  • Keep redundant-instance behavior unchanged.

Design decisions

The reporter owns the skip behavior because ephemeral containers should never report regardless of which framework entry point starts Judoscale. Platform subclasses own the naming rules because only Heroku and Scalingo expose these container conventions.


Note

Low Risk
Behavior change is limited to skipping metrics reporting on ephemeral containers (including new Heroku release phase); redundant-instance logic is untouched.

Overview
Ephemeral container handling is centralized in the shared Reporter: start! returns early when config.current_platform.ephemeral_instance?, so Rails and other entry points no longer duplicate that check (Rails railtie drops in_one_off_container?).

Platform naming is updated from one_off? to ephemeral_instance?. Heroku now treats release.* dynos (in addition to run.*) as ephemeral, with case-normalized prefix matching. Scalingo still treats one-off-* as ephemeral. Formation dynos/containers are unchanged.

Tests cover the rename, release dynos, and reporter behavior for Heroku release, Heroku one-off, and Scalingo one-off.

Reviewed by Cursor Bugbot for commit c8399c7. Bugbot is set up for automated code reviews on this repo. Configure here.

Skip reporting from release and one-off containers through the shared reporter so Rails and Rack entry points behave the same way.

Co-authored-by: Cursor <cursoragent@cursor.com>
@adamlogic
adamlogic force-pushed the platform-refactor branch from f85e1e7 to 812f41a Compare June 12, 2026 18:24
config.after_initialize do
if in_rails_console_or_runner?
logger.debug "No reporting since we're in a Rails console or runner process"
elsif in_one_off_container?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No longer needed here since Reporter#start! has this logic. We're moving it there for parity with Node/Python libs and so this behavior is not Rails-specific.

@adamlogic
adamlogic marked this pull request as ready for review June 12, 2026 18:25

@carlosantoniodasilva carlosantoniodasilva left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

container.start_with?("run.")
# Heroku release phase and one-off dynos are named "release.1234" and "run.1234".
def ephemeral_instance?
container.downcase.start_with?("release.") || container.start_with?("run.")

@carlosantoniodasilva carlosantoniodasilva Jun 16, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We downcase the release but not run because that's possibly a user-entered value in the Procfile?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just inherited what we were doing previously, but there's not a good reason for it. I'll downcase both for consistency.

Comment on lines +135 to +140
[
["Heroku release", Platform::Heroku.new("release.1")],
["Heroku", Platform::Heroku.new("run.1234")],
["Scalingo", Platform::Scalingo.new("one-off-1234")]
].each do |platform_name, platform|
it "does not run the reporter thread in a #{platform_name} ephemeral instance" do

@carlosantoniodasilva carlosantoniodasilva Jun 16, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

previous comment

Minor suggestion to run a single test for "ephemeral instances" and then if we're testing multiple we loop inside. It's fine though to have individual/separated tests, but generally for single behavior-testing on a few variants, and even slightly perf-gain, I usually lean on that.

Suggested change
[
["Heroku release", Platform::Heroku.new("release.1")],
["Heroku", Platform::Heroku.new("run.1234")],
["Scalingo", Platform::Scalingo.new("one-off-1234")]
].each do |platform_name, platform|
it "does not run the reporter thread in a #{platform_name} ephemeral instance" do
it "does not run the reporter thread in an ephemeral instance" do
[
["Heroku release", Platform::Heroku.new("release.1")],
["Heroku", Platform::Heroku.new("run.1234")],
["Scalingo", Platform::Scalingo.new("one-off-1234")]
].each do |platform_name, platform|

Update: it's a bit of a personal opinion and may be controversial, and I also see the node and python packages are doing a similar test, so it's totally cool to leave as-is for consistency across the board.

adamlogic and others added 2 commits June 16, 2026 11:14
Normalize Heroku container names once before checking release and one-off prefixes.

Co-authored-by: Cursor <cursoragent@cursor.com>
Use Ruby's multi-prefix start_with? form for normalized Heroku ephemeral container checks.

Co-authored-by: Cursor <cursoragent@cursor.com>
@adamlogic
adamlogic merged commit ce7dc28 into main Jun 16, 2026
124 checks passed
@adamlogic
adamlogic deleted the platform-refactor branch June 16, 2026 15:43
adamlogic pushed a commit that referenced this pull request Nov 4, 2026
🤖 I have created a release *beep* *boop*
---


##
[1.13.4](v1.13.3...v1.13.4)
(2026-11-03)


### Bug Fixes

* detect Solid Queue queues from running workers
([#277](#277))
([43d0f3d](43d0f3d))
* skip the reporter in one-off containers
([#273](#273))
([cfcbe12](cfcbe12))
* treat ephemeral containers consistently
([#276](#276))
([ce7dc28](ce7dc28))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants