Skip to content

Conversation

@jbardin
Copy link
Member

@jbardin jbardin commented Jul 17, 2025

Continuing from #292, we update the implementation slightly, but maintain the same behavior:

  • Don't shadow the builtin panic symbol.
  • Don't turn off the panic flag once we see it. Concurrent logs would interfere with capturing the full stack trace, and programs which do capture the stack and continue are often going to present it via the logs anyway.
  • Catch fatal errors along with panics as they both produce a stack trace.
  • Flatten the if block since we are already using a switch.
  • Add an end-to-end test of the panic capturing behavior.
  • Add a CHANGELOG entry, indicating the change in behavior.

Most clients won't notice the change, but some like Terraform must capture plugin stack traces in order to help users identify the source of the error. Changing the stream is a breaking change for Terraform, so updating to a new minor version will need to be coordinated with downstream consumers.

@jbardin jbardin requested a review from a team as a code owner July 17, 2025 17:53
@jbardin jbardin force-pushed the jbardin/panic-logging-cleanup branch from 0f18701 to 7769a89 Compare July 17, 2025 17:57

func TestClient_logger(t *testing.T) {
t.Run("net/rpc", func(t *testing.T) { testClient_logger(t, "netrpc") })
t.Run("netrpc", func(t *testing.T) { testClient_logger(t, "netrpc") })
Copy link
Member Author

Choose a reason for hiding this comment

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

This change is solely for test ergonomics, the extra / made it behave as a sub-sub-test.

@jbardin
Copy link
Member Author

jbardin commented Aug 5, 2025

@hashicorp/team-ip-compliance, waiting on review please

Copy link
Member

@robmonte robmonte left a comment

Choose a reason for hiding this comment

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

Looks great, just one question!

sonamtenzin2
sonamtenzin2 previously approved these changes Aug 7, 2025
sonamtenzin2
sonamtenzin2 previously approved these changes Aug 7, 2025
It wasn't clear which versions of the protobuf tooling needed to be used
to generate the test code, and updating them required some additional
changes. Since the `buf` tool was adopted to generate the example code,
use the same tool to make generating the test code easier too.
@jbardin jbardin merged commit d2a064e into main Aug 8, 2025
3 checks passed
@jbardin jbardin deleted the jbardin/panic-logging-cleanup branch August 11, 2025 15:38
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.

4 participants