Skip to content

Add bounded sampling for high-volume API logs#1611

Merged
kryputh merged 2 commits into
Stellar-Mail:mainfrom
Johnpii1:issue-1519
Jul 20, 2026
Merged

Add bounded sampling for high-volume API logs#1611
kryputh merged 2 commits into
Stellar-Mail:mainfrom
Johnpii1:issue-1519

Conversation

@Johnpii1

Copy link
Copy Markdown
Contributor

Description

This PR introduces deterministic API log sampling to reduce routine success-log volume while ensuring that security-related events and unexpected errors are always recorded. Logging decisions are made predictably using the request ID and route, while aggregate metrics continue to capture all requests regardless of sampling.

Changes Made

  • Added deterministic log sampling based on request ID and route.
  • Introduced configurable sampling for routine successful requests to reduce log noise.
  • Ensured unexpected errors and denied security actions are always logged and never sampled out.
  • Preserved aggregate metrics so all requests are counted regardless of whether a log entry is emitted.
  • Added logging utilities in src/server/api/logging.ts to centralize and standardize sampling behavior.
  • Added unit tests to verify deterministic sampling behavior and ensure critical logs are never omitted.

Testing

  • ✅ Ran targeted unit tests:
    • tests/unit/api/logging.test.ts
  • ✅ Ran the full unit test suite — 756 tests passed.
  • npm run lint completed successfully.
  • npm run build completed successfully.

closes #1519

Johnpii1 added 2 commits July 20, 2026 06:06
…tion-error-schema

Stabilize validation error schema and add deterministic API log sampling
@kryputh
kryputh merged commit a110318 into Stellar-Mail:main Jul 20, 2026
10 checks passed
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.

Add bounded sampling for high-volume API logs

2 participants