feat(otel-collector): per-signal table TTL + reconcile on existing tables#2709
Open
ZeynelKoca wants to merge 1 commit into
Open
feat(otel-collector): per-signal table TTL + reconcile on existing tables#2709ZeynelKoca wants to merge 1 commit into
ZeynelKoca wants to merge 1 commit into
Conversation
🦋 Changeset detectedLatest commit: 166644f The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
@ZeynelKoca is attempting to deploy a commit to the HyperDX Team on Vercel. A member of the Team first needs to authorize it. |
Contributor
Greptile SummaryThis PR adds per-signal retention settings for ClickHouse telemetry tables. The main changes are:
Confidence Score: 5/5The latest changes look safe to merge.
Important Files Changed
Reviews (5): Last reviewed commit: "feat(otel-collector): per-signal table T..." | Re-trigger Greptile |
ZeynelKoca
force-pushed
the
feat/per-signal-table-ttl
branch
2 times, most recently
from
July 22, 2026 15:06
8d2c8dc to
ff12401
Compare
ZeynelKoca
marked this pull request as ready for review
July 22, 2026 15:22
ZeynelKoca
force-pushed
the
feat/per-signal-table-ttl
branch
from
July 22, 2026 15:37
ff12401 to
760433c
Compare
ZeynelKoca
force-pushed
the
feat/per-signal-table-ttl
branch
from
July 23, 2026 07:59
760433c to
166644f
Compare
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
Adds per-signal ClickHouse table TTLs and, opt-in, reconciles TTL on already-existing tables. Implements #1311.
Why
Today
HYPERDX_OTEL_EXPORTER_TABLES_TTL(#1720) sets one TTL for every signal, and it only applies at table creation (CREATE TABLE IF NOT EXISTS). So:Why this matters for compliance. Frameworks like SOC 2 (and ISO 27001, HIPAA, PCI-DSS) commonly require security-relevant logs, and often traces, to be retained for 6–12 months — while high-volume metrics are kept short to control storage cost. That is inherently a per-signal retention policy, and it must apply to the tables a running deployment already has, not just fresh installs. #1311 asked for exactly this (per-signal 90 days / 6 months / 1 year / 5 years). Without this change, operators on any serious/regulated deployment have to hand-run
ALTER TABLE ... MODIFY TTLon every table after each deploy or upgrade — easy to get wrong and easy to silently drift out of compliance.Changes
Per-signal env vars, each falling back to
HYPERDX_OTEL_EXPORTER_TABLES_TTLso existing setups are unchanged:HYPERDX_OTEL_EXPORTER_LOGS_TTLHYPERDX_OTEL_EXPORTER_TRACES_TTLHYPERDX_OTEL_EXPORTER_METRICS_TTLHYPERDX_OTEL_EXPORTER_SESSIONS_TTLThe seed SQL now uses per-signal
${*_TTL}macros (logs also covers its rollup/compat tables; traces likewise; metrics its tables; sessions its own).HYPERDX_OTEL_EXPORTER_RECONCILE_TABLE_TTL(defaultfalse). When enabled, after seeding the migrate tool reconciles TTL on existing managed tables: it reads each table's current TTL fromsystem.tablesand, only when the retention differs, runsALTER TABLE ... MODIFY TTL <anchor + new interval> SETTINGS materialize_ttl_after_modify = 0. It is diff-guarded via a syntax-agnostic duration comparison (sotoIntervalDay(30)vsINTERVAL 30 DAYdoesn't cause churn), preserves each table's timestamp anchor, and is non-fatal (a failedALTERlogs a warning and never blocks startup).Backward compatibility
TABLES_TTL; create-only).Testing
go test ./cmd/migrate/— added unit tests for per-signal config resolution/fallback, seed macro substitution, table→signal classification, TTL-clause extraction (incl. column-level TTL present), interval parsing (bothtoIntervalX(N)andINTERVAL N UNITforms, day/hour/minute/second), and the reconcile decisionplanTTLReconcile— a pure function covering the cross-syntax diff-guard, extend vs shrink, and multi-interval refusal.go vetandgofmtclean.Empirically verified
Ran the
migratebinary (built from this branch) against a throwawayclickhouse-server:25.7-alpinecontainer:Confirms: per-signal TTLs apply; existing logs/traces tables (incl. rollups) are reconciled with timestamp anchors preserved; metrics/sessions are isolated; extending materializes (existing data retained for the new period) while shrinking stays lazy (no startup delete); and an identical re-run alters nothing.
Implements #1311.