Repository navigation
Add high-cardinality telemetry protection: label budgets, redaction and log sampling (#214) - #382
Merged
github-actions[bot] merged 2 commits intoOct 18, 2026
Conversation
…sive volume (TRELLIS-STELLAR#214) TelemetryGuard rejects unsafe label values as-is before they reach Prometheus: identifiers/tokens collapse to placeholders, charset and length are bounded, and a per metric::label cardinality budget (default 128) aggregates new values into __over_budget__ so totals stay exact. Rejections are counted in a bounded counter (trellis_telemetry_label_rejections_total{metric,label,reason}). Log lines run through the sensitive-data mask with length-capped fields and a metadata size cap (originals untouched on returned events), and non-failure lines are deterministically sampled at TELEMETRY_LOG_SAMPLE_RATE (default 1 = previous behaviour); failures always emit, suppressed lines are counted, metrics are never sampled. Log serialization failures degrade to a warning instead of throwing.
|
@OkeyAmy Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
Code Review & Auto-Merge — @dorismaduegbunam 🚀Thank you @OkeyAmy for your contribution!
Verified code changes and repository requirements. Merging pull request. |
github-actions
Bot
merged commit Oct 18, 2026
77ae9c8
into
TRELLIS-STELLAR:main
1 of 3 checks passed
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.
What
Closes #214 with a small, well-tested vertical slice: a
TelemetryGuardsitting between callers andTelemetryService's telemetry sinks.__sensitive__, UUID/email/address/hash identifiers → placeholders, charset bounded, 64-char cap) and counted against a permetric :: labelcardinality budget (default 128). Values beyond the budget collapse into__over_budget__; observations are never dropped, so totals stay exact. Every collapse incrementstrellis_telemetry_label_rejections_total{metric,label,reason}so operators can find the leaking caller.TELEMETRY_LOG_SAMPLE_RATE(default1= previous behaviour); failures always emit; suppressed lines are counted intrellis_telemetry_log_events_suppressed_total{kind}. Metrics series are never sampled.Why
recordOperationlabels come from caller-influenced sources — the@Telemetrydecorator readsactor_typefrom token claims anderror_codefrom thrown errors. One Prometheus series per distinct value means unbounded memory growth and unusable dashboards under abusive input; logs had no volume or payload control at all.Impact
src/observability/telemetry-guard.ts+ spec (18 tests)src/observability/telemetry.service.ts(guard wiring, sampled/capped log emission, guarded funnel logging) + spec (6 new integration tests; all 15 pre-existing tests unchanged and green)docs/TELEMETRY_PROTECTION.md— configuration, operational edge cases, failure modes, rollback/recoveryCompatibility
Public APIs and event schemas are unchanged. Default configuration (budget 128, rate 1) is behaviour-compatible: legitimate operation/actor/error values pass through verbatim, so existing dashboards and alerts keep matching. Gauges are deliberately not routed through the guard (stateful budget vs inc/dec pairing) — documented as a follow-up, along with the per-request timing log line.
Verification
npx jest src/observability/telemetry.service.spec.ts src/observability/telemetry-guard.spec.ts→ 39/39 green, repeated ×3enums/sensitive-action-event-type.enum— pre-existing baseline red, verified viagit stash)npx tsc --noEmitfiltered toobservability/paths → clean (repo baseline has pre-existing errors elsewhere)