Skip to content

fix(cli): install panic hook so panics flow through OpenTelemetry (OTel) - #187

Open
aatran14 wants to merge 2 commits into
a24films:mainfrom
aatran14:at/add-panic-hook
Open

fix(cli): install panic hook so panics flow through OpenTelemetry (OTel)#187
aatran14 wants to merge 2 commits into
a24films:mainfrom
aatran14:at/add-panic-hook

Conversation

@aatran14

Copy link
Copy Markdown

useful for folks who will end up using the open telemetry

Why

install_panic_hook was defined ,but never called. As a result of this behavior, the panics never reach OTel.

Add

Calls install_panic_hook() at startup.

Testing

Lacks unit test, which I suspect belongs in cli/src/observability.rs. Worth making sure those test(s) age well.
I was able to get a clean build cargo build -p puffgres-cli

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8233fa12d3

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread crates/cli/src/main.rs
);
}

puffgres_cli::observability::install_panic_hook();

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Flush telemetry before exiting on panic

In an OTEL-enabled command such as puffgres run, apply, or remove that panics after observability::init, this hook only enqueues a tracing::error! and then invokes the default panic hook; because the unwind never returns from run().await, the Telemetry::shutdown() call in main is skipped. The log this change is intended to export can therefore remain buffered and be lost at process exit unless the panic path catches the unwind and flushes/shuts down telemetry synchronously.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I think agree with this

To my understanding:

  • This PR makes panic visible to the Otel pipeline; for example, structured payload & location
  • The "flush-on-panic" gap is existing behavior. Any batched telementry not yet exported is lost when a panic unwinds past main's shutdown(), regardless of this change.
  • This PR happens to be the first log emitted at panic time. I think that flushing on the panic path whether that be a sync force_flush in run() or the hook ultimately entails a lot more work which justifies its own PR.

To clarify:
In the interest of simplicity, scope this PR to

  1. puffgres_cli::observability::install_panic_hook(); in cli/src/main.rs
  2. the testing for it

@aatran14
aatran14 force-pushed the at/add-panic-hook branch from 5634835 to 8233fa1 Compare July 22, 2026 06:50
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