refactor(sync-service): Convert Logger calls to use static strings with metadata#3969
refactor(sync-service): Convert Logger calls to use static strings with metadata#3969
Conversation
…th metadata Refactor all Logger calls in electric-telemetry and sync-service packages to use static strings with metadata attributes instead of string interpolation. This improves log structuring for better observability and integrates with OTEL log handlers that can extract metadata fields. Changes: - Extract dynamic values from log messages into metadata attributes - Update config/runtime.exs with extended metadata list for default formatter - Add OTEL metadata_map entries for new attributes - Update Lux tests to match new log format with metadata - Update unit tests to check for static messages with metadata Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
❌ 1 Tests Failed:
View the top 2 failed test(s) by shortest run time
View the full list of 3 ❄️ flaky test(s)
To view more test analytics, go to the Test Analytics Dashboard |
|
Found 1 test failure on Blacksmith runners: Failure
|
Fix test assertions that were checking for interpolated log messages. Now check for static messages with metadata attributes. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
LINE1 |
Update Lux test patterns to match Logger calls that now use metadata attributes instead of string interpolation. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Update manual-table-publishing.lux for Failed to create snapshot pattern - Update postgres-disconnection.lux for Database connection failed pattern - Update tests to use simpler "Starting replication client" pattern Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Update Snapshot started pattern to match new metadata-based format. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Rename `msg:` to `unexpected_msg:` to avoid reserved key conflict - Remove `state:` from logger metadata to prevent credential leakage Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The Lux test fail pattern matches "error" case-insensitively, which causes false failures when error_message= appears in log metadata output. Renaming to err_msg avoids this issue. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Remove `opts: opts` metadata from SchemaReconciler (exposes internal config) - Guard eager `length/1` calls in consumer.ex hot paths with `Logger.enabled?(:debug)` - Rename `lock_name:` to `slot_name:` for consistency in acquire_lock log - Remove redundant `client_pid: self()` from api.ex (`:pid` already in global metadata) - Add missing metadata keys to formatter and OTEL metadata_map in runtime.exs - Remove unused `lock_name` from formatter metadata list and OTEL map - Update Lux tests for lock_name -> slot_name rename Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
✅ Deploy Preview for electric-next ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
✅ Deploy Preview for electric-next ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Claude Code ReviewSummaryAll five Important issues and the changeset suggestion from previous iterations have been resolved. The PR is in excellent shape — every Logger call in What’s Working Well
Issues FoundCritical (Must Fix)None. Important (Should Fix)None. Suggestions (Nice to Have)1. File:
2. Large struct values stored as debug metadata File:
Issue ConformanceNo linked issue. PR description is accurate and up to date. No change from previous reviews. Previous Review Status
Review iteration: 7 | 2026-03-09 |
- Fix test assertion: lock_name= -> slot_name= in replication_client_test - Rename message: to pg_message: metadata key to avoid OTEL reserved field - Add missing metadata keys to formatter list (version, instance_id, etc.) - Add missing OTEL metadata_map entries (query_string, idle_time_s, etc.) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Logger.enabled?/1 takes a PID, not a log level. Use Logger.compare_levels(Logger.level(), :debug) != :gt to correctly check if debug logging is enabled before computing expensive metadata. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add ~26 missing metadata keys to formatter list and OTEL metadata_map - Rename pid: to connection_pid:/materializer_pid:/monitored_pid: to avoid shadowing built-in :pid metadata - Standardize dependency_handle -> dep_handle for consistency - Add 9 missing OTEL metadata_map entries (interval_ms, trash_dir, etc.) - Add patch changeset for sync-service and electric-telemetry Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Summary
electric-telemetryandsync-servicepackages to use static strings with metadata attributes instead of string interpolationconfig/runtime.exswith extended metadata list for default formatter and OTEL metadata_map entriesTest plan
mix compile --warnings-as-errors- passes🤖 Generated with Claude Code