[8.19] [CI] Speed up telemetry_check by pre-filtering to collector files (#265978)#267652
Merged
kibanamachine merged 1 commit intoelastic:8.19from May 5, 2026
Merged
Conversation
…astic#265978) ## Summary The `telemetry.sh` quick check takes **~8m 45s** in CI — the single slowest check in the `quick_checks` step. It also runs in the serial `mayChangeFiles` queue, blocking all other serial checks behind it. ### The problem `extractCollectors()` passes **all ~36K TS files** from each of the 10 telemetry roots into `ts.createProgram()`, even though only **~69 files** across the entire repo actually contain `makeUsageCollector` or `makeStatsCollector` calls. TypeScript parses and type-checks thousands of unrelated source files that will never yield a collector. ### The fix Pre-filter files with a simple regex scan on file contents before feeding them to the TS compiler: ```ts const collectorPaths = fullPaths.filter((p) => COLLECTOR_RE.test(readFileSync(p, 'utf-8'))); ``` TypeScript still resolves all transitive imports needed for type-checking the collector files, but avoids parsing thousands of unrelated files. ### Benchmark results (local) **`src/platform/` root** (largest OSS root): | Approach | Root files | Source files TS loads | Time | |---|---|---|---| | Current (all files) | 8,852 | 17,279 | 48s | | New (collector files only) | 30 | 4,814 | 15s | | **Speedup** | | **3.6x fewer** | **3.1x faster** | **`x-pack/platform/` root** (largest x-pack root): | Approach | Root files | Source files TS loads | Time | |---|---|---|---| | Current (all files) | 15,344 | 25,002 | 71s | | New (collector files only) | 27 | 13,835 | 49s | | **Speedup** | | **1.8x fewer** | **1.5x faster** | **CI estimate**: `telemetry.sh` should drop from **~8m 45s to ~3-4 min**. ### How it was tested - Profiled `createKibanaProgram` locally with the actual Kibana telemetry roots - Verified the same collector files are found and processed - The pre-filter is conservative — any file mentioning the collector function names is included Made with [Cursor](https://cursor.com) Co-authored-by: Ahmad Bamieh <ahmad.bamyeh@elastic.co> (cherry picked from commit b3cb3c8)
Contributor
Author
💚 Build Succeeded
Metrics [docs]
cc @shahzad31 |
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.
Backport
This will backport the following commits from
mainto8.19:Questions ?
Please refer to the Backport tool documentation