Skip to content

feat(access-logs): make GCP log buffer size configurable and count drops#271

Merged
ldebruijn merged 2 commits into
mainfrom
feature/gcp-access-log-buffer-limit
Jul 1, 2026
Merged

feat(access-logs): make GCP log buffer size configurable and count drops#271
ldebruijn merged 2 commits into
mainfrom
feature/gcp-access-log-buffer-limit

Conversation

@rickbijkerk

@rickbijkerk rickbijkerk commented Jul 1, 2026

Copy link
Copy Markdown
Collaborator

Problem

The Google Cloud Logging client buffers pending log entries in memory . Its default BufferedByteLimit is 1GiB. When the Cloud Logging flush slows down, the buffer grows unbounded. Drops on the GCP path were also completely silent (no metric, no log).

Changes

  • Configurable buffer size via log_buffer_max_size_mb (default 1000, i.e. ~1GiB — preserves current behaviour). Wired into logging.BufferedByteLimit. Operators can now bound it below the container memory limit so the bundler drops entries instead of OOMing.
  • graphql_protect_access_logging_gcp_dropped_total counter — increments when the bundler returns ErrOverflow, so drops are observable.
  • Error logging on OnError — non-overflow async errors now increment gcp_errors_total and emit a warning, instead of being swallowed.
  • Docs + example config updated.

Tests

  • TestDefaultConfig — asserts the buffer default stays 1000 (behaviour-neutral upgrade).
  • TestGoogleCloudConfig_YAMLBinding — guards the YAML tag name against typos.
  • TestGoogleCloudConfig_YAMLOmittedKeepsDefault — omitted key preserves the default when unmarshalling over DefaultConfig().

go vet clean, full package test suite passes.

Rick Bijkerk added 2 commits July 1, 2026 17:06
The Google Cloud Logging client buffers pending entries in memory using a
non-blocking bundler whose default BufferedByteLimit is 1GiB. With full
payload/variable access logging enabled, a slow Cloud Logging flush lets the
buffer grow until the container crosses its memory limit and is OOMKilled
before the bundler's own overflow-drop can kick in.

Make the buffer size configurable via `log_buffer_max_size_mb` (default 1000,
preserving prior behaviour) and add a `gcp_dropped_total` counter plus error
logging on the async OnError path so overflow drops are observable instead of
silent.
Comment thread internal/business/rules/accesslogging/config.go
@ldebruijn ldebruijn merged commit 53869d7 into main Jul 1, 2026
2 checks passed
@ldebruijn ldebruijn deleted the feature/gcp-access-log-buffer-limit branch July 1, 2026 17:15
}

logger := client.Logger(logName)
logger := client.Logger(logName, logging.BufferedByteLimit(cfg.BufferedByteLimit<<20))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think it's rather confusing that logging.BufferedByteLimit is in byes, and cfg.BufferedByteLimit is apparently in megabytes. So I would suggest to either implement it in bytes in cfg as well, or rename the variable to BufferedMegaByteLimit or something to make sure people don't make expensive/risky mistakes here.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

the yaml property does explicitly state: log_buffer_max_size_mb so i think we should be good here, its the only place where the property can be defined

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