Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

feat(flags): log the first sighting of a shadow mismatch (#90216)

James Gill2440f8c73e87
diff --git a/rust/feature-flags/src/bin/flags_cache_builder.rs b/rust/feature-flags/src/bin/flags_cache_builder.rs
index 7ca317cf1219..e3153d3eebd9 100644
--- a/rust/feature-flags/src/bin/flags_cache_builder.rs
+++ b/rust/feature-flags/src/bin/flags_cache_builder.rs
@@ -115,7 +115,7 @@ const SHADOW_TRACKER_STORE_ERRORS: &str = "flags_cache_shadow_tracker_store_erro
// same buckets as the real-build duration histogram.
const SHADOW_BUILD_DURATION_SECONDS: &str = "flags_cache_shadow_build_duration_seconds";
-/// Caps on the confirmed-mismatch log line (see `summarize_diffs`).
+/// Caps on the mismatch log lines (see `summarize_diffs`).
const SHADOW_LOG_MAX_ENTRIES: usize = 20;
const SHADOW_LOG_MAX_BYTES: usize = 4096;
@@ -665,13 +665,26 @@ async fn process_shadow_team(
metrics::counter!(SHADOW_MISMATCH_FIRST_SIGHT, "issue_type" => diff.issue_type.as_label())
.increment(1);
}
+ // A first sighting logs at WARN and a confirmed mismatch at ERROR,
+ // because a single-shot disagreement is expected: a shadow build races
+ // Python's own rebuild. `mismatch_stage` splits the two in a log query
+ // without a text match on the message.
if !observation.confirmed.is_empty() {
tracing::error!(
team_id,
+ mismatch_stage = "confirmed",
diff = %summarize_diffs(&observation.confirmed, SHADOW_LOG_MAX_ENTRIES, SHADOW_LOG_MAX_BYTES),
"Shadow compare mismatch persisted across consecutive builds"
);
}
+ if !observation.first_sight.is_empty() {
+ tracing::warn!(
+ team_id,
+ mismatch_stage = "first_sight",
+ diff = %summarize_diffs(&observation.first_sight, SHADOW_LOG_MAX_ENTRIES, SHADOW_LOG_MAX_BYTES),
+ "Shadow compare mismatch seen for the first time"
+ );
+ }
}
}