Repository navigation
feat(log): allow disabling the zap duplicate-message sampler - #292
Merged
Merged
Conversation
armru
added a commit
to cloudnative-pg/cloudnative-pg
that referenced
this pull request
Jul 6, 2026
Track the latest commit of cloudnative-pg/machinery#292 in both modules, and promote klog to a direct dependency now that the manager tests import it. Signed-off-by: Armando Ruocco <[email protected]>
Member
Author
|
/test |
The controller-runtime zap builder installs a sampler on production-mode loggers that passes only the first 100 messages sharing the same (level, message) pair each second, and roughly 1 in 100 afterwards. That is fine for a controller's reconcile noise, but it silently drops records from processes whose output must be complete, such as the instance manager forwarding the PostgreSQL log stream, where every record is logged with the same message. Add a WithDisabledSampling option to Flags.ConfigureLogging. The builder only installs the sampler when the configured level does not enable zapcore.Level(-2), so the option passes a fully-verbose level to make the builder skip it and then restores the requested level by filtering the core. Signed-off-by: Armando Ruocco <[email protected]>
NiccoloFei
force-pushed
the
feat/configurable-log-sampling
branch
from
July 24, 2026 13:59
1f63480 to
12f2c0c
Compare
Signed-off-by: Niccolò Fei <[email protected]>
NiccoloFei
force-pushed
the
feat/configurable-log-sampling
branch
from
July 24, 2026 14:55
785522e to
61daa1c
Compare
NiccoloFei
approved these changes
Jul 24, 2026
Signed-off-by: Marco Nenciarini <[email protected]>
Assert only that the sampler deduped some messages, rather than pinning the exact worst-case window split, which occasionally failed under a scheduler stall spreading the burst across three or more sampler windows. Signed-off-by: Marco Nenciarini <[email protected]>
mnencia
approved these changes
Jul 28, 2026
NiccoloFei
approved these changes
Jul 28, 2026
mnencia
pushed a commit
to cloudnative-pg/cloudnative-pg
that referenced
this pull request
Jul 28, 2026
Replace the local machinery checkout with the pseudo-version of the commit opened as cloudnative-pg/machinery#292, so CI builds against the same code. To be bumped to the tagged machinery release once available. Signed-off-by: Armando Ruocco <[email protected]>
mnencia
pushed a commit
to cloudnative-pg/cloudnative-pg
that referenced
this pull request
Jul 28, 2026
Track the latest commit of cloudnative-pg/machinery#292 in both modules, and promote klog to a direct dependency now that the manager tests import it. Signed-off-by: Armando Ruocco <[email protected]>
mnencia
added a commit
to cloudnative-pg/cloudnative-pg
that referenced
this pull request
Jul 28, 2026
The previous pin pointed at the pre-merge commit of cloudnative-pg/machinery#292, which is not an ancestor of machinery's main once that PR was squash-merged. Point both modules at the actual merge commit instead. Signed-off-by: Marco Nenciarini <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The controller-runtime zap builder installs a duplicate-message sampler on every production-mode logger, letting through only the first 100 messages sharing a (level, message) pair each second and roughly 1 in 100 afterwards. That's the right default for an operator reconciliation loop, but it silently drops most records for a process whose output must be complete, such as the CloudNativePG instance manager forwarding the PostgreSQL log stream under a burst of pgaudit activity.
This adds an optional
WithDisabledSampling()argument toFlags.ConfigureLogging. It passes a fully-verbose level to the controller-runtime builder so it skips installing the sampler, then restores the caller's requested level withzap.IncreaseLevel. Callers that don't pass the option are unaffected.This adds the capability only; none of machinery's existing callers pass the option yet. The instance manager still needs a follow-up PR to opt in, and that follow-up will need to be subcommand-aware since
cmd/manager'sConfigureLogging()call is shared by every subcommand (controller, instance, walarchive, pgbouncer, …) — passing the option there unconditionally would also silence the operator's own reconcile-loop sampling.Refs cloudnative-pg/cloudnative-pg#10815