feat(sdk): add DECO_OTEL_ACCESS_LOG_RATE sampling for INFO access logs#293
Open
igoramf wants to merge 1 commit into
Open
feat(sdk): add DECO_OTEL_ACCESS_LOG_RATE sampling for INFO access logs#293igoramf wants to merge 1 commit into
igoramf wants to merge 1 commit into
Conversation
5xx requests always emit an ERROR-level access log (never sampled). INFO access logs (2xx/3xx/4xx) are now gated by DECO_OTEL_ACCESS_LOG_RATE (float 0–1, default 1.0 = 100% = current behavior). When the rate is < 1, sampling uses FNV-1a 32-bit hash of requestId/ traceId for consistent per-request decisions — same request always gets the same answer, regardless of isolate. Falls back to Math.random() only when neither ID is available (should not happen in practice). Set DECO_OTEL_ACCESS_LOG_RATE=0.1 to reduce INFO access log volume by 90%, eliminating the main source of high-volume INFO traffic to otel-ingest without affecting error visibility. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.
Summary
DECO_OTEL_ACCESS_LOG_RATEenv var (float 0–1, default1.0= 100% = current behavior) to control INFO access log volumerequestId/traceIdfor consistent per-request decisions (same request always gets the same pass/drop outcome)Math.random()only when no request ID is availableWhy
logRequest()emits 1 INFO log per HTTP request. casaevideo + bagaggio alone generate ~2,200 INFO access logs/minute at otel-ingest, even though 99% are discarded after arrival. Moving the sampling decision to the SDK (before the POST) reduces otel-ingest load and billing.Recommended prod config:
Test plan
DECO_OTEL_ACCESS_LOG_RATEunset): 100% of access logs emitted — same as beforeDECO_OTEL_ACCESS_LOG_RATE=0: 0 INFO access logs; 5xx still emit ERROR logDECO_OTEL_ACCESS_LOG_RATE=0.1: ~10% of INFO access logs pass; 5xx always pass🤖 Generated with Claude Code
Summary by cubic
Adds
DECO_OTEL_ACCESS_LOG_RATEto sample INFO access logs and reduce otel-ingest volume. Default remains 100% (no behavior change).New Features
DECO_OTEL_ACCESS_LOG_RATE(0–1; default1.0).requestId/traceId; falls back toMath.random()if missing.Migration
DECO_OTEL_ACCESS_LOG_RATE=0.1in production to keep ~10% of INFO logs.Written for commit 2bcc74b. Summary will update on new commits.