Skip to content

Move shape_handle into Logger metadata for No-consumer error#4145

Open
alco wants to merge 3 commits intomainfrom
fix/1457-no-consumer-log-handle
Open

Move shape_handle into Logger metadata for No-consumer error#4145
alco wants to merge 3 commits intomainfrom
fix/1457-no-consumer-log-handle

Conversation

@alco
Copy link
Copy Markdown
Member

@alco alco commented Apr 21, 2026

Summary

Replace the interpolated shape_handle in the Logger.error("No consumer process when waiting on initial snapshot creation for #{shape_handle}") call with a static message plus shape_handle as structured Logger metadata.

Why

Including the shape handle directly in the error message is unnecessary — the handle is better logged as a metadata item. The shape_handle key is already in the stratovolt :default_formatter metadata list and mapped to the shape.handle OTEL attribute, so the handle remains visible in both plain-text logs and OTEL-exported logs.

This also improves log aggregation — static messages are easier to group and search for.

Fixes https://github.com/electric-sql/stratovolt/issues/1457.

Test plan

  • mix compile --warnings-as-errors passes
  • Existing shape_cache_test.exs assertion updated to match the new static message

Keep the log message static so Sentry deduplicates these events
instead of treating every shape handle variant as a distinct issue.
@alco alco added the claude label Apr 21, 2026
@claude
Copy link
Copy Markdown

claude Bot commented Apr 21, 2026

Claude Code Review

Summary

This PR moves shape_handle from string interpolation in a Logger.error call to structured Logger metadata, preventing Sentry deduplication bypass during incident storms. Minimal, well-targeted fix -- ready to merge.

What's Working Well

  • Minimal, focused change: Exactly one log call modified, test updated to match. No scope creep.
  • Correct Logger API usage: Logger.error/2 with a metadata keyword list is idiomatic and correct.
  • Changeset included: .changeset/fix-no-consumer-log-shape-handle.md is present and well-described.
  • PR description is excellent: Explains the root cause (Sentry TTL dedup + unique strings), the incident metrics, and confirms shape_handle remains visible via the stratovolt formatter and OTEL attribute mapping.
  • Tightened test assertion (fixup 3a97db37): The final assertion checks the full structured-log string rather than a bare substring check. This verifies the metadata key-value format, log level, and static message text in one shot.

Issues Found

Critical (Must Fix)

None.

Important (Should Fix)

None.

Suggestions (Nice to Have)

None.

Issue Conformance

No linked issue in this repository (references stratovolt#1457 which appears to be a private/external tracker). Given the detailed PR description documenting the incident, impact metrics, and the well-scoped fix, the absence of a public linked issue is acceptable here.

Previous Review Status

All prior feedback has been addressed:

  • Iteration 1: Add an assertion that shape_handle appears in the captured log -- done.
  • Iteration 2: Reviewed the added assertion -- clean.
  • Iteration 3 (this pass): Fixup commit 3a97db37 refined the assertion to check the full formatted log string including key=value format and log level. No regressions, no new issues.

Review iteration: 3 | 2026-04-21

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 21, 2026

❌ 1 Tests Failed:

Tests completed Failed Passed Skipped
2772 1 2771 1
View the top 2 failed test(s) by shortest run time
Elixir.Electric.ShapeCacheTest::test get_or_create_shape_handle/2 against real db crashes when initial snapshot query fails to return data quickly enough
Stack Traces | 0s run time
29) test get_or_create_shape_handle/2 against real db crashes when initial snapshot query fails to return data quickly enough (Electric.ShapeCacheTest)
     test/electric/shape_cache_test.exs:507
     ** (EXIT from #PID<0.10818.0>) killed
Elixir.Electric.Shapes.ApiTest::test serve/1 live=true request recovers from out of bounds offset via subscription
Stack Traces | 1.02s run time
50) test serve/1 live=true request recovers from out of bounds offset via subscription (Electric.Shapes.ApiTest)
     .../electric/shapes/api_test.exs:929
     Assertion failed, no matching message after 1000ms
     The process mailbox is empty.
     code: assert_receive {:trace, _, :call, {Api, :hold_until_change, _}}
     stacktrace:
       .../electric/shapes/api_test.exs:981: (test)

To view more test analytics, go to the Test Analytics Dashboard
📋 Got 3 mins? Take this short survey to help us improve Test Analytics.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants