Skip to content

fix(worker): install shutdown signals before readiness; test(engine): isolate OTLP ingestion metrics storage - #2235

Open
guibeira wants to merge 2 commits into
mainfrom
fix/split-2198-unrelated
Open

guibeira wants to merge 2 commits into
mainfrom
fix/split-2198-unrelated

Conversation

@guibeira

@guibeira guibeira commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Split out of #2198 (which is now scoped to #2178 only), as requested in review, to ease review and bisecting. Neither change touches trigger handling.

Changes

  • fix(worker): install the shutdown signal handlers before exit-watch reports readiness (crates/iii-worker/src/daemon_exit.rs), so a signal sent right after readiness is not missed. Covered by sandbox_daemon_exit_integration.
  • test(engine): OTLP ingestion edge-case tests now use owned metric storage through an extracted ingest_otlp_metrics_into(json, storage) helper (otel.rs), instead of clearing the process-wide store. This fixes a CI flake (test_ingest_metrics_multiple_resources counted 3 metrics instead of 2) caused by a non-serialized test writing to the same global store. Production behaviour is unchanged: ingest_otlp_metrics still ingests into the global store.
    • The misleading "interleaved writer" test (a thread spawned and joined immediately) was rewritten as a sequential ..._ignores_foreign_writer test.

Validation

  • cargo fmt --check ok
  • cargo test -p iii --lib workers::observability: 442 passed
  • cargo test -p iii-worker daemon_exit: 5 passed + 1 integration passed

Summary by CodeRabbit

  • Bug Fixes
    • Improved shutdown-signal handling so signals are registered before exit monitoring begins. If one signal handler fails or its stream closes, other shutdown and engine-exit checks remain active.
    • Metric ingestion now handles unavailable storage without attempting to store metrics, while malformed input continues to return an error. Empty batches and malformed batches are also covered by additional checks.

@vercel

vercel Bot commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
iii-website Ready Ready Preview Sep 24, 2026 9:54pm UTC

Request Review

@coderabbitai

coderabbitai Bot commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository: iii-hq/iii/.coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: f03b6503-4fc7-49cb-be9f-c2d3e6bbcc1f

📥 Commits

Reviewing files that changed from the base of the PR and between f2bc2b2 and fb4dc05.

📒 Files selected for processing (4)
  • crates/iii-worker/src/daemon_exit.rs
  • crates/iii-worker/tests/sandbox_daemon_exit_integration.rs
  • engine/src/workers/observability/metrics.rs
  • engine/src/workers/observability/otel.rs

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.


📝 Walkthrough

Walkthrough

The daemon registers shutdown-signal handlers before polling exit watches. OTLP metric ingestion now uses a helper that accepts optional storage. The changes also update the SIGTERM integration test and OTLP ingestion tests.

Changes

Daemon shutdown signals

Layer / File(s) Summary
Register signals before waiting
crates/iii-worker/src/daemon_exit.rs, crates/iii-worker/tests/sandbox_daemon_exit_integration.rs
ExitWatch::wait registers SIGINT, SIGTERM, and SIGHUP before polling exit watches. Registration failures disable the affected signal arm. The SIGTERM integration test checks that the readiness log precedes the parent exit-watch armed log.

OTLP metric ingestion

Layer / File(s) Summary
Separate parsing and storage selection
engine/src/workers/observability/otel.rs
ingest_otlp_metrics passes global storage to ingest_otlp_metrics_into. The helper parses batches before checking storage availability and uses the supplied storage when available.
Verify ingestion with owned storage
engine/src/workers/observability/metrics.rs
Tests use explicitly supplied storage to check isolation, malformed and empty batches, and existing metric ingestion cases. Several tests now use local storage and synchronous ingestion.

Priority: ⬇️ Low

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix

Suggested reviewers: andersonleal

Merge Risk: ⚪ Minimal · up to fb4dc

The shutdown and metric-ingestion changes appear ready to merge after normal checks.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes both primary changes: installing shutdown signals before readiness and isolating OTLP ingestion metric storage in tests.
Description check ✅ Passed The description explains the changes, motivation, test impact, production behavior, and validation results. It uses Changes and Validation headings instead of the template's What, Why, and Notes headi…
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 17 functions across 4 files.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

This branch was successfully deployed

1 active deployment
Preview — fb4dc05f Deployed Sep 24, 2026 by vercel[bot]
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.

1 participant