[CI] Speed up telemetry_check by pre-filtering to collector files#265978
[CI] Speed up telemetry_check by pre-filtering to collector files#265978shahzad31 merged 9 commits intoelastic:mainfrom
Conversation
The telemetry check passes all ~36K TS files from each root directory into `ts.createProgram()`, even though only ~69 files actually contain `makeUsageCollector` or `makeStatsCollector` calls. Pre-filter with a simple regex scan on file contents before feeding to the TS compiler. TypeScript still resolves transitive imports needed for type-checking, but avoids parsing thousands of unrelated files. Benchmarked locally (src/platform root): - Before: 8,852 root files → 17,279 source files loaded → 48s - After: 30 root files → 4,814 source files loaded → 15s (3.1x faster) This optimization applies per-root. Combined across all 10 roots, the telemetry_check should drop from ~8m 45s to ~3-4 min in CI. Made-with: Cursor
|
Pinging @elastic/actionable-obs-team (Team:actionable-obs) |
ApprovabilityVerdict: Needs human review The modified file is owned by @elastic/kibana-core, not the PR author. The pre-filtering optimization could potentially miss files that reference collectors through re-exports rather than direct usage. The designated code owners should verify this CI optimization is safe. No code changes detected at You can customize Macroscope's approvability policy. Learn more. |
💛 Build succeeded, but was flaky
Failed CI StepsMetrics [docs]
History
|
|
Starting backport for target branches: 8.19, 9.2, 9.3, 9.4 https://github.com/elastic/kibana/actions/runs/25362981633 |
💚 All backports created successfully
Note: Successful backport PRs will be merged automatically after passing CI. Questions ?Please refer to the Backport tool documentation |
…es (#265978) (#267655) # Backport This will backport the following commits from `main` to `9.4`: - [[CI] Speed up telemetry_check by pre-filtering to collector files (#265978)](#265978) <!--- Backport version: 9.6.6 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"Shahzad","email":"shahzad31comp@gmail.com"},"sourceCommit":{"committedDate":"2026-05-05T07:14:21Z","message":"[CI] Speed up telemetry_check by pre-filtering to collector files (#265978)\n\n## Summary\n\nThe `telemetry.sh` quick check takes **~8m 45s** in CI — the single\nslowest check in the `quick_checks` step. It also runs in the serial\n`mayChangeFiles` queue, blocking all other serial checks behind it.\n\n### The problem\n\n`extractCollectors()` passes **all ~36K TS files** from each of the 10\ntelemetry roots into `ts.createProgram()`, even though only **~69\nfiles** across the entire repo actually contain `makeUsageCollector` or\n`makeStatsCollector` calls.\n\nTypeScript parses and type-checks thousands of unrelated source files\nthat will never yield a collector.\n\n### The fix\n\nPre-filter files with a simple regex scan on file contents before\nfeeding them to the TS compiler:\n\n```ts\nconst collectorPaths = fullPaths.filter((p) => COLLECTOR_RE.test(readFileSync(p, 'utf-8')));\n```\n\nTypeScript still resolves all transitive imports needed for\ntype-checking the collector files, but avoids parsing thousands of\nunrelated files.\n\n### Benchmark results (local)\n\n**`src/platform/` root** (largest OSS root):\n\n| Approach | Root files | Source files TS loads | Time |\n|---|---|---|---|\n| Current (all files) | 8,852 | 17,279 | 48s |\n| New (collector files only) | 30 | 4,814 | 15s |\n| **Speedup** | | **3.6x fewer** | **3.1x faster** |\n\n**`x-pack/platform/` root** (largest x-pack root):\n\n| Approach | Root files | Source files TS loads | Time |\n|---|---|---|---|\n| Current (all files) | 15,344 | 25,002 | 71s |\n| New (collector files only) | 27 | 13,835 | 49s |\n| **Speedup** | | **1.8x fewer** | **1.5x faster** |\n\n**CI estimate**: `telemetry.sh` should drop from **~8m 45s to ~3-4\nmin**.\n\n### How it was tested\n\n- Profiled `createKibanaProgram` locally with the actual Kibana\ntelemetry roots\n- Verified the same collector files are found and processed\n- The pre-filter is conservative — any file mentioning the collector\nfunction names is included\n\n\nMade with [Cursor](https://cursor.com)\n\nCo-authored-by: Ahmad Bamieh <ahmad.bamyeh@elastic.co>","sha":"b3cb3c89a91ae1ee18b0d7d10c98a1ceb903e82a","branchLabelMapping":{"^v9.5.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","backport:all-open","Team:actionable-obs","author:actionable-obs","ci:use-selective-testing","v9.5.0"],"title":"[CI] Speed up telemetry_check by pre-filtering to collector files","number":265978,"url":"https://github.com/elastic/kibana/pull/265978","mergeCommit":{"message":"[CI] Speed up telemetry_check by pre-filtering to collector files (#265978)\n\n## Summary\n\nThe `telemetry.sh` quick check takes **~8m 45s** in CI — the single\nslowest check in the `quick_checks` step. It also runs in the serial\n`mayChangeFiles` queue, blocking all other serial checks behind it.\n\n### The problem\n\n`extractCollectors()` passes **all ~36K TS files** from each of the 10\ntelemetry roots into `ts.createProgram()`, even though only **~69\nfiles** across the entire repo actually contain `makeUsageCollector` or\n`makeStatsCollector` calls.\n\nTypeScript parses and type-checks thousands of unrelated source files\nthat will never yield a collector.\n\n### The fix\n\nPre-filter files with a simple regex scan on file contents before\nfeeding them to the TS compiler:\n\n```ts\nconst collectorPaths = fullPaths.filter((p) => COLLECTOR_RE.test(readFileSync(p, 'utf-8')));\n```\n\nTypeScript still resolves all transitive imports needed for\ntype-checking the collector files, but avoids parsing thousands of\nunrelated files.\n\n### Benchmark results (local)\n\n**`src/platform/` root** (largest OSS root):\n\n| Approach | Root files | Source files TS loads | Time |\n|---|---|---|---|\n| Current (all files) | 8,852 | 17,279 | 48s |\n| New (collector files only) | 30 | 4,814 | 15s |\n| **Speedup** | | **3.6x fewer** | **3.1x faster** |\n\n**`x-pack/platform/` root** (largest x-pack root):\n\n| Approach | Root files | Source files TS loads | Time |\n|---|---|---|---|\n| Current (all files) | 15,344 | 25,002 | 71s |\n| New (collector files only) | 27 | 13,835 | 49s |\n| **Speedup** | | **1.8x fewer** | **1.5x faster** |\n\n**CI estimate**: `telemetry.sh` should drop from **~8m 45s to ~3-4\nmin**.\n\n### How it was tested\n\n- Profiled `createKibanaProgram` locally with the actual Kibana\ntelemetry roots\n- Verified the same collector files are found and processed\n- The pre-filter is conservative — any file mentioning the collector\nfunction names is included\n\n\nMade with [Cursor](https://cursor.com)\n\nCo-authored-by: Ahmad Bamieh <ahmad.bamyeh@elastic.co>","sha":"b3cb3c89a91ae1ee18b0d7d10c98a1ceb903e82a"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.5.0","branchLabelMappingKey":"^v9.5.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/265978","number":265978,"mergeCommit":{"message":"[CI] Speed up telemetry_check by pre-filtering to collector files (#265978)\n\n## Summary\n\nThe `telemetry.sh` quick check takes **~8m 45s** in CI — the single\nslowest check in the `quick_checks` step. It also runs in the serial\n`mayChangeFiles` queue, blocking all other serial checks behind it.\n\n### The problem\n\n`extractCollectors()` passes **all ~36K TS files** from each of the 10\ntelemetry roots into `ts.createProgram()`, even though only **~69\nfiles** across the entire repo actually contain `makeUsageCollector` or\n`makeStatsCollector` calls.\n\nTypeScript parses and type-checks thousands of unrelated source files\nthat will never yield a collector.\n\n### The fix\n\nPre-filter files with a simple regex scan on file contents before\nfeeding them to the TS compiler:\n\n```ts\nconst collectorPaths = fullPaths.filter((p) => COLLECTOR_RE.test(readFileSync(p, 'utf-8')));\n```\n\nTypeScript still resolves all transitive imports needed for\ntype-checking the collector files, but avoids parsing thousands of\nunrelated files.\n\n### Benchmark results (local)\n\n**`src/platform/` root** (largest OSS root):\n\n| Approach | Root files | Source files TS loads | Time |\n|---|---|---|---|\n| Current (all files) | 8,852 | 17,279 | 48s |\n| New (collector files only) | 30 | 4,814 | 15s |\n| **Speedup** | | **3.6x fewer** | **3.1x faster** |\n\n**`x-pack/platform/` root** (largest x-pack root):\n\n| Approach | Root files | Source files TS loads | Time |\n|---|---|---|---|\n| Current (all files) | 15,344 | 25,002 | 71s |\n| New (collector files only) | 27 | 13,835 | 49s |\n| **Speedup** | | **1.8x fewer** | **1.5x faster** |\n\n**CI estimate**: `telemetry.sh` should drop from **~8m 45s to ~3-4\nmin**.\n\n### How it was tested\n\n- Profiled `createKibanaProgram` locally with the actual Kibana\ntelemetry roots\n- Verified the same collector files are found and processed\n- The pre-filter is conservative — any file mentioning the collector\nfunction names is included\n\n\nMade with [Cursor](https://cursor.com)\n\nCo-authored-by: Ahmad Bamieh <ahmad.bamyeh@elastic.co>","sha":"b3cb3c89a91ae1ee18b0d7d10c98a1ceb903e82a"}}]}] BACKPORT--> Co-authored-by: Shahzad <shahzad31comp@gmail.com> Co-authored-by: Ahmad Bamieh <ahmad.bamyeh@elastic.co>
…ilder_new_vis_attachment * commit '6fd683609eb6dee81f242f8ff6951edbe3bfd66c': (226 commits) Remove Model Author group-by option from external inference endpoints (elastic#264761) [Streams][Streamlang] Align ES|QL condition transpiler with Painless on null propagation (elastic#264751) chore(axios,workflows-eng): remove axios from workflows connector utils (elastic#267512) [failed-test-reporter] avoid opening issues for scout env failures (elastic#267649) [kbn-api-contracts] Detect request-body additionalProperties:false tightening (elastic#267546) [main] Sync bundled packages with Package Storage (elastic#267644) Centralize phase colors and descriptions (elastic#266680) [Unified Waterfall] Add "Scroll to origin" button (elastic#266594) [APM] Add alert and SLO badges to the service map embeddable (elastic#266360) [CI] Speed up telemetry_check by pre-filtering to collector files (elastic#265978) [Discover] Address flaky large CSV test (elastic#266642) avoid passing unrelated props within integration card icon component conditional render (elastic#266569) [Cases][Templates] Extend cases search by template field label (elastic#266414) [Background search] Migrate custom SplitButton to EuiSplitButton (elastic#267447) [i18n] Report translation coverage during integrate (elastic#264124) [api-docs] 2026-05-05 Daily api_docs build (elastic#267639) [Scout] Update test config manifests (elastic#267636) [content list] Add saved object provider services (elastic#266428) [Fleet] Otel UI add health and implement it in OTelComponentDetail (elastic#267292) Update dependency msw to v2.13.4 (main) (elastic#266770) ...
…les (#265978) (#267652) # Backport This will backport the following commits from `main` to `8.19`: - [[CI] Speed up telemetry_check by pre-filtering to collector files (#265978)](#265978) <!--- Backport version: 9.6.6 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"Shahzad","email":"shahzad31comp@gmail.com"},"sourceCommit":{"committedDate":"2026-05-05T07:14:21Z","message":"[CI] Speed up telemetry_check by pre-filtering to collector files (#265978)\n\n## Summary\n\nThe `telemetry.sh` quick check takes **~8m 45s** in CI — the single\nslowest check in the `quick_checks` step. It also runs in the serial\n`mayChangeFiles` queue, blocking all other serial checks behind it.\n\n### The problem\n\n`extractCollectors()` passes **all ~36K TS files** from each of the 10\ntelemetry roots into `ts.createProgram()`, even though only **~69\nfiles** across the entire repo actually contain `makeUsageCollector` or\n`makeStatsCollector` calls.\n\nTypeScript parses and type-checks thousands of unrelated source files\nthat will never yield a collector.\n\n### The fix\n\nPre-filter files with a simple regex scan on file contents before\nfeeding them to the TS compiler:\n\n```ts\nconst collectorPaths = fullPaths.filter((p) => COLLECTOR_RE.test(readFileSync(p, 'utf-8')));\n```\n\nTypeScript still resolves all transitive imports needed for\ntype-checking the collector files, but avoids parsing thousands of\nunrelated files.\n\n### Benchmark results (local)\n\n**`src/platform/` root** (largest OSS root):\n\n| Approach | Root files | Source files TS loads | Time |\n|---|---|---|---|\n| Current (all files) | 8,852 | 17,279 | 48s |\n| New (collector files only) | 30 | 4,814 | 15s |\n| **Speedup** | | **3.6x fewer** | **3.1x faster** |\n\n**`x-pack/platform/` root** (largest x-pack root):\n\n| Approach | Root files | Source files TS loads | Time |\n|---|---|---|---|\n| Current (all files) | 15,344 | 25,002 | 71s |\n| New (collector files only) | 27 | 13,835 | 49s |\n| **Speedup** | | **1.8x fewer** | **1.5x faster** |\n\n**CI estimate**: `telemetry.sh` should drop from **~8m 45s to ~3-4\nmin**.\n\n### How it was tested\n\n- Profiled `createKibanaProgram` locally with the actual Kibana\ntelemetry roots\n- Verified the same collector files are found and processed\n- The pre-filter is conservative — any file mentioning the collector\nfunction names is included\n\n\nMade with [Cursor](https://cursor.com)\n\nCo-authored-by: Ahmad Bamieh <ahmad.bamyeh@elastic.co>","sha":"b3cb3c89a91ae1ee18b0d7d10c98a1ceb903e82a","branchLabelMapping":{"^v9.5.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","backport:all-open","Team:actionable-obs","author:actionable-obs","ci:use-selective-testing","v9.5.0"],"title":"[CI] Speed up telemetry_check by pre-filtering to collector files","number":265978,"url":"https://github.com/elastic/kibana/pull/265978","mergeCommit":{"message":"[CI] Speed up telemetry_check by pre-filtering to collector files (#265978)\n\n## Summary\n\nThe `telemetry.sh` quick check takes **~8m 45s** in CI — the single\nslowest check in the `quick_checks` step. It also runs in the serial\n`mayChangeFiles` queue, blocking all other serial checks behind it.\n\n### The problem\n\n`extractCollectors()` passes **all ~36K TS files** from each of the 10\ntelemetry roots into `ts.createProgram()`, even though only **~69\nfiles** across the entire repo actually contain `makeUsageCollector` or\n`makeStatsCollector` calls.\n\nTypeScript parses and type-checks thousands of unrelated source files\nthat will never yield a collector.\n\n### The fix\n\nPre-filter files with a simple regex scan on file contents before\nfeeding them to the TS compiler:\n\n```ts\nconst collectorPaths = fullPaths.filter((p) => COLLECTOR_RE.test(readFileSync(p, 'utf-8')));\n```\n\nTypeScript still resolves all transitive imports needed for\ntype-checking the collector files, but avoids parsing thousands of\nunrelated files.\n\n### Benchmark results (local)\n\n**`src/platform/` root** (largest OSS root):\n\n| Approach | Root files | Source files TS loads | Time |\n|---|---|---|---|\n| Current (all files) | 8,852 | 17,279 | 48s |\n| New (collector files only) | 30 | 4,814 | 15s |\n| **Speedup** | | **3.6x fewer** | **3.1x faster** |\n\n**`x-pack/platform/` root** (largest x-pack root):\n\n| Approach | Root files | Source files TS loads | Time |\n|---|---|---|---|\n| Current (all files) | 15,344 | 25,002 | 71s |\n| New (collector files only) | 27 | 13,835 | 49s |\n| **Speedup** | | **1.8x fewer** | **1.5x faster** |\n\n**CI estimate**: `telemetry.sh` should drop from **~8m 45s to ~3-4\nmin**.\n\n### How it was tested\n\n- Profiled `createKibanaProgram` locally with the actual Kibana\ntelemetry roots\n- Verified the same collector files are found and processed\n- The pre-filter is conservative — any file mentioning the collector\nfunction names is included\n\n\nMade with [Cursor](https://cursor.com)\n\nCo-authored-by: Ahmad Bamieh <ahmad.bamyeh@elastic.co>","sha":"b3cb3c89a91ae1ee18b0d7d10c98a1ceb903e82a"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.5.0","branchLabelMappingKey":"^v9.5.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/265978","number":265978,"mergeCommit":{"message":"[CI] Speed up telemetry_check by pre-filtering to collector files (#265978)\n\n## Summary\n\nThe `telemetry.sh` quick check takes **~8m 45s** in CI — the single\nslowest check in the `quick_checks` step. It also runs in the serial\n`mayChangeFiles` queue, blocking all other serial checks behind it.\n\n### The problem\n\n`extractCollectors()` passes **all ~36K TS files** from each of the 10\ntelemetry roots into `ts.createProgram()`, even though only **~69\nfiles** across the entire repo actually contain `makeUsageCollector` or\n`makeStatsCollector` calls.\n\nTypeScript parses and type-checks thousands of unrelated source files\nthat will never yield a collector.\n\n### The fix\n\nPre-filter files with a simple regex scan on file contents before\nfeeding them to the TS compiler:\n\n```ts\nconst collectorPaths = fullPaths.filter((p) => COLLECTOR_RE.test(readFileSync(p, 'utf-8')));\n```\n\nTypeScript still resolves all transitive imports needed for\ntype-checking the collector files, but avoids parsing thousands of\nunrelated files.\n\n### Benchmark results (local)\n\n**`src/platform/` root** (largest OSS root):\n\n| Approach | Root files | Source files TS loads | Time |\n|---|---|---|---|\n| Current (all files) | 8,852 | 17,279 | 48s |\n| New (collector files only) | 30 | 4,814 | 15s |\n| **Speedup** | | **3.6x fewer** | **3.1x faster** |\n\n**`x-pack/platform/` root** (largest x-pack root):\n\n| Approach | Root files | Source files TS loads | Time |\n|---|---|---|---|\n| Current (all files) | 15,344 | 25,002 | 71s |\n| New (collector files only) | 27 | 13,835 | 49s |\n| **Speedup** | | **1.8x fewer** | **1.5x faster** |\n\n**CI estimate**: `telemetry.sh` should drop from **~8m 45s to ~3-4\nmin**.\n\n### How it was tested\n\n- Profiled `createKibanaProgram` locally with the actual Kibana\ntelemetry roots\n- Verified the same collector files are found and processed\n- The pre-filter is conservative — any file mentioning the collector\nfunction names is included\n\n\nMade with [Cursor](https://cursor.com)\n\nCo-authored-by: Ahmad Bamieh <ahmad.bamyeh@elastic.co>","sha":"b3cb3c89a91ae1ee18b0d7d10c98a1ceb903e82a"}}]}] BACKPORT--> Co-authored-by: Shahzad <shahzad31comp@gmail.com> Co-authored-by: Ahmad Bamieh <ahmad.bamyeh@elastic.co>
…es (#265978) (#267654) # Backport This will backport the following commits from `main` to `9.3`: - [[CI] Speed up telemetry_check by pre-filtering to collector files (#265978)](#265978) <!--- Backport version: 9.6.6 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"Shahzad","email":"shahzad31comp@gmail.com"},"sourceCommit":{"committedDate":"2026-05-05T07:14:21Z","message":"[CI] Speed up telemetry_check by pre-filtering to collector files (#265978)\n\n## Summary\n\nThe `telemetry.sh` quick check takes **~8m 45s** in CI — the single\nslowest check in the `quick_checks` step. It also runs in the serial\n`mayChangeFiles` queue, blocking all other serial checks behind it.\n\n### The problem\n\n`extractCollectors()` passes **all ~36K TS files** from each of the 10\ntelemetry roots into `ts.createProgram()`, even though only **~69\nfiles** across the entire repo actually contain `makeUsageCollector` or\n`makeStatsCollector` calls.\n\nTypeScript parses and type-checks thousands of unrelated source files\nthat will never yield a collector.\n\n### The fix\n\nPre-filter files with a simple regex scan on file contents before\nfeeding them to the TS compiler:\n\n```ts\nconst collectorPaths = fullPaths.filter((p) => COLLECTOR_RE.test(readFileSync(p, 'utf-8')));\n```\n\nTypeScript still resolves all transitive imports needed for\ntype-checking the collector files, but avoids parsing thousands of\nunrelated files.\n\n### Benchmark results (local)\n\n**`src/platform/` root** (largest OSS root):\n\n| Approach | Root files | Source files TS loads | Time |\n|---|---|---|---|\n| Current (all files) | 8,852 | 17,279 | 48s |\n| New (collector files only) | 30 | 4,814 | 15s |\n| **Speedup** | | **3.6x fewer** | **3.1x faster** |\n\n**`x-pack/platform/` root** (largest x-pack root):\n\n| Approach | Root files | Source files TS loads | Time |\n|---|---|---|---|\n| Current (all files) | 15,344 | 25,002 | 71s |\n| New (collector files only) | 27 | 13,835 | 49s |\n| **Speedup** | | **1.8x fewer** | **1.5x faster** |\n\n**CI estimate**: `telemetry.sh` should drop from **~8m 45s to ~3-4\nmin**.\n\n### How it was tested\n\n- Profiled `createKibanaProgram` locally with the actual Kibana\ntelemetry roots\n- Verified the same collector files are found and processed\n- The pre-filter is conservative — any file mentioning the collector\nfunction names is included\n\n\nMade with [Cursor](https://cursor.com)\n\nCo-authored-by: Ahmad Bamieh <ahmad.bamyeh@elastic.co>","sha":"b3cb3c89a91ae1ee18b0d7d10c98a1ceb903e82a","branchLabelMapping":{"^v9.5.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","backport:all-open","Team:actionable-obs","author:actionable-obs","ci:use-selective-testing","v9.5.0"],"title":"[CI] Speed up telemetry_check by pre-filtering to collector files","number":265978,"url":"https://github.com/elastic/kibana/pull/265978","mergeCommit":{"message":"[CI] Speed up telemetry_check by pre-filtering to collector files (#265978)\n\n## Summary\n\nThe `telemetry.sh` quick check takes **~8m 45s** in CI — the single\nslowest check in the `quick_checks` step. It also runs in the serial\n`mayChangeFiles` queue, blocking all other serial checks behind it.\n\n### The problem\n\n`extractCollectors()` passes **all ~36K TS files** from each of the 10\ntelemetry roots into `ts.createProgram()`, even though only **~69\nfiles** across the entire repo actually contain `makeUsageCollector` or\n`makeStatsCollector` calls.\n\nTypeScript parses and type-checks thousands of unrelated source files\nthat will never yield a collector.\n\n### The fix\n\nPre-filter files with a simple regex scan on file contents before\nfeeding them to the TS compiler:\n\n```ts\nconst collectorPaths = fullPaths.filter((p) => COLLECTOR_RE.test(readFileSync(p, 'utf-8')));\n```\n\nTypeScript still resolves all transitive imports needed for\ntype-checking the collector files, but avoids parsing thousands of\nunrelated files.\n\n### Benchmark results (local)\n\n**`src/platform/` root** (largest OSS root):\n\n| Approach | Root files | Source files TS loads | Time |\n|---|---|---|---|\n| Current (all files) | 8,852 | 17,279 | 48s |\n| New (collector files only) | 30 | 4,814 | 15s |\n| **Speedup** | | **3.6x fewer** | **3.1x faster** |\n\n**`x-pack/platform/` root** (largest x-pack root):\n\n| Approach | Root files | Source files TS loads | Time |\n|---|---|---|---|\n| Current (all files) | 15,344 | 25,002 | 71s |\n| New (collector files only) | 27 | 13,835 | 49s |\n| **Speedup** | | **1.8x fewer** | **1.5x faster** |\n\n**CI estimate**: `telemetry.sh` should drop from **~8m 45s to ~3-4\nmin**.\n\n### How it was tested\n\n- Profiled `createKibanaProgram` locally with the actual Kibana\ntelemetry roots\n- Verified the same collector files are found and processed\n- The pre-filter is conservative — any file mentioning the collector\nfunction names is included\n\n\nMade with [Cursor](https://cursor.com)\n\nCo-authored-by: Ahmad Bamieh <ahmad.bamyeh@elastic.co>","sha":"b3cb3c89a91ae1ee18b0d7d10c98a1ceb903e82a"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.5.0","branchLabelMappingKey":"^v9.5.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/265978","number":265978,"mergeCommit":{"message":"[CI] Speed up telemetry_check by pre-filtering to collector files (#265978)\n\n## Summary\n\nThe `telemetry.sh` quick check takes **~8m 45s** in CI — the single\nslowest check in the `quick_checks` step. It also runs in the serial\n`mayChangeFiles` queue, blocking all other serial checks behind it.\n\n### The problem\n\n`extractCollectors()` passes **all ~36K TS files** from each of the 10\ntelemetry roots into `ts.createProgram()`, even though only **~69\nfiles** across the entire repo actually contain `makeUsageCollector` or\n`makeStatsCollector` calls.\n\nTypeScript parses and type-checks thousands of unrelated source files\nthat will never yield a collector.\n\n### The fix\n\nPre-filter files with a simple regex scan on file contents before\nfeeding them to the TS compiler:\n\n```ts\nconst collectorPaths = fullPaths.filter((p) => COLLECTOR_RE.test(readFileSync(p, 'utf-8')));\n```\n\nTypeScript still resolves all transitive imports needed for\ntype-checking the collector files, but avoids parsing thousands of\nunrelated files.\n\n### Benchmark results (local)\n\n**`src/platform/` root** (largest OSS root):\n\n| Approach | Root files | Source files TS loads | Time |\n|---|---|---|---|\n| Current (all files) | 8,852 | 17,279 | 48s |\n| New (collector files only) | 30 | 4,814 | 15s |\n| **Speedup** | | **3.6x fewer** | **3.1x faster** |\n\n**`x-pack/platform/` root** (largest x-pack root):\n\n| Approach | Root files | Source files TS loads | Time |\n|---|---|---|---|\n| Current (all files) | 15,344 | 25,002 | 71s |\n| New (collector files only) | 27 | 13,835 | 49s |\n| **Speedup** | | **1.8x fewer** | **1.5x faster** |\n\n**CI estimate**: `telemetry.sh` should drop from **~8m 45s to ~3-4\nmin**.\n\n### How it was tested\n\n- Profiled `createKibanaProgram` locally with the actual Kibana\ntelemetry roots\n- Verified the same collector files are found and processed\n- The pre-filter is conservative — any file mentioning the collector\nfunction names is included\n\n\nMade with [Cursor](https://cursor.com)\n\nCo-authored-by: Ahmad Bamieh <ahmad.bamyeh@elastic.co>","sha":"b3cb3c89a91ae1ee18b0d7d10c98a1ceb903e82a"}}]}] BACKPORT--> Co-authored-by: Shahzad <shahzad31comp@gmail.com> Co-authored-by: Ahmad Bamieh <ahmad.bamyeh@elastic.co>
…es (#265978) (#267653) # Backport This will backport the following commits from `main` to `9.2`: - [[CI] Speed up telemetry_check by pre-filtering to collector files (#265978)](#265978) <!--- Backport version: 9.6.6 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"Shahzad","email":"shahzad31comp@gmail.com"},"sourceCommit":{"committedDate":"2026-05-05T07:14:21Z","message":"[CI] Speed up telemetry_check by pre-filtering to collector files (#265978)\n\n## Summary\n\nThe `telemetry.sh` quick check takes **~8m 45s** in CI — the single\nslowest check in the `quick_checks` step. It also runs in the serial\n`mayChangeFiles` queue, blocking all other serial checks behind it.\n\n### The problem\n\n`extractCollectors()` passes **all ~36K TS files** from each of the 10\ntelemetry roots into `ts.createProgram()`, even though only **~69\nfiles** across the entire repo actually contain `makeUsageCollector` or\n`makeStatsCollector` calls.\n\nTypeScript parses and type-checks thousands of unrelated source files\nthat will never yield a collector.\n\n### The fix\n\nPre-filter files with a simple regex scan on file contents before\nfeeding them to the TS compiler:\n\n```ts\nconst collectorPaths = fullPaths.filter((p) => COLLECTOR_RE.test(readFileSync(p, 'utf-8')));\n```\n\nTypeScript still resolves all transitive imports needed for\ntype-checking the collector files, but avoids parsing thousands of\nunrelated files.\n\n### Benchmark results (local)\n\n**`src/platform/` root** (largest OSS root):\n\n| Approach | Root files | Source files TS loads | Time |\n|---|---|---|---|\n| Current (all files) | 8,852 | 17,279 | 48s |\n| New (collector files only) | 30 | 4,814 | 15s |\n| **Speedup** | | **3.6x fewer** | **3.1x faster** |\n\n**`x-pack/platform/` root** (largest x-pack root):\n\n| Approach | Root files | Source files TS loads | Time |\n|---|---|---|---|\n| Current (all files) | 15,344 | 25,002 | 71s |\n| New (collector files only) | 27 | 13,835 | 49s |\n| **Speedup** | | **1.8x fewer** | **1.5x faster** |\n\n**CI estimate**: `telemetry.sh` should drop from **~8m 45s to ~3-4\nmin**.\n\n### How it was tested\n\n- Profiled `createKibanaProgram` locally with the actual Kibana\ntelemetry roots\n- Verified the same collector files are found and processed\n- The pre-filter is conservative — any file mentioning the collector\nfunction names is included\n\n\nMade with [Cursor](https://cursor.com)\n\nCo-authored-by: Ahmad Bamieh <ahmad.bamyeh@elastic.co>","sha":"b3cb3c89a91ae1ee18b0d7d10c98a1ceb903e82a","branchLabelMapping":{"^v9.5.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","backport:all-open","Team:actionable-obs","author:actionable-obs","ci:use-selective-testing","v9.5.0"],"title":"[CI] Speed up telemetry_check by pre-filtering to collector files","number":265978,"url":"https://github.com/elastic/kibana/pull/265978","mergeCommit":{"message":"[CI] Speed up telemetry_check by pre-filtering to collector files (#265978)\n\n## Summary\n\nThe `telemetry.sh` quick check takes **~8m 45s** in CI — the single\nslowest check in the `quick_checks` step. It also runs in the serial\n`mayChangeFiles` queue, blocking all other serial checks behind it.\n\n### The problem\n\n`extractCollectors()` passes **all ~36K TS files** from each of the 10\ntelemetry roots into `ts.createProgram()`, even though only **~69\nfiles** across the entire repo actually contain `makeUsageCollector` or\n`makeStatsCollector` calls.\n\nTypeScript parses and type-checks thousands of unrelated source files\nthat will never yield a collector.\n\n### The fix\n\nPre-filter files with a simple regex scan on file contents before\nfeeding them to the TS compiler:\n\n```ts\nconst collectorPaths = fullPaths.filter((p) => COLLECTOR_RE.test(readFileSync(p, 'utf-8')));\n```\n\nTypeScript still resolves all transitive imports needed for\ntype-checking the collector files, but avoids parsing thousands of\nunrelated files.\n\n### Benchmark results (local)\n\n**`src/platform/` root** (largest OSS root):\n\n| Approach | Root files | Source files TS loads | Time |\n|---|---|---|---|\n| Current (all files) | 8,852 | 17,279 | 48s |\n| New (collector files only) | 30 | 4,814 | 15s |\n| **Speedup** | | **3.6x fewer** | **3.1x faster** |\n\n**`x-pack/platform/` root** (largest x-pack root):\n\n| Approach | Root files | Source files TS loads | Time |\n|---|---|---|---|\n| Current (all files) | 15,344 | 25,002 | 71s |\n| New (collector files only) | 27 | 13,835 | 49s |\n| **Speedup** | | **1.8x fewer** | **1.5x faster** |\n\n**CI estimate**: `telemetry.sh` should drop from **~8m 45s to ~3-4\nmin**.\n\n### How it was tested\n\n- Profiled `createKibanaProgram` locally with the actual Kibana\ntelemetry roots\n- Verified the same collector files are found and processed\n- The pre-filter is conservative — any file mentioning the collector\nfunction names is included\n\n\nMade with [Cursor](https://cursor.com)\n\nCo-authored-by: Ahmad Bamieh <ahmad.bamyeh@elastic.co>","sha":"b3cb3c89a91ae1ee18b0d7d10c98a1ceb903e82a"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.5.0","branchLabelMappingKey":"^v9.5.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/265978","number":265978,"mergeCommit":{"message":"[CI] Speed up telemetry_check by pre-filtering to collector files (#265978)\n\n## Summary\n\nThe `telemetry.sh` quick check takes **~8m 45s** in CI — the single\nslowest check in the `quick_checks` step. It also runs in the serial\n`mayChangeFiles` queue, blocking all other serial checks behind it.\n\n### The problem\n\n`extractCollectors()` passes **all ~36K TS files** from each of the 10\ntelemetry roots into `ts.createProgram()`, even though only **~69\nfiles** across the entire repo actually contain `makeUsageCollector` or\n`makeStatsCollector` calls.\n\nTypeScript parses and type-checks thousands of unrelated source files\nthat will never yield a collector.\n\n### The fix\n\nPre-filter files with a simple regex scan on file contents before\nfeeding them to the TS compiler:\n\n```ts\nconst collectorPaths = fullPaths.filter((p) => COLLECTOR_RE.test(readFileSync(p, 'utf-8')));\n```\n\nTypeScript still resolves all transitive imports needed for\ntype-checking the collector files, but avoids parsing thousands of\nunrelated files.\n\n### Benchmark results (local)\n\n**`src/platform/` root** (largest OSS root):\n\n| Approach | Root files | Source files TS loads | Time |\n|---|---|---|---|\n| Current (all files) | 8,852 | 17,279 | 48s |\n| New (collector files only) | 30 | 4,814 | 15s |\n| **Speedup** | | **3.6x fewer** | **3.1x faster** |\n\n**`x-pack/platform/` root** (largest x-pack root):\n\n| Approach | Root files | Source files TS loads | Time |\n|---|---|---|---|\n| Current (all files) | 15,344 | 25,002 | 71s |\n| New (collector files only) | 27 | 13,835 | 49s |\n| **Speedup** | | **1.8x fewer** | **1.5x faster** |\n\n**CI estimate**: `telemetry.sh` should drop from **~8m 45s to ~3-4\nmin**.\n\n### How it was tested\n\n- Profiled `createKibanaProgram` locally with the actual Kibana\ntelemetry roots\n- Verified the same collector files are found and processed\n- The pre-filter is conservative — any file mentioning the collector\nfunction names is included\n\n\nMade with [Cursor](https://cursor.com)\n\nCo-authored-by: Ahmad Bamieh <ahmad.bamyeh@elastic.co>","sha":"b3cb3c89a91ae1ee18b0d7d10c98a1ceb903e82a"}}]}] BACKPORT--> Co-authored-by: Shahzad <shahzad31comp@gmail.com> Co-authored-by: Ahmad Bamieh <ahmad.bamyeh@elastic.co>
Summary
The
telemetry.shquick check takes ~8m 45s in CI — the single slowest check in thequick_checksstep. It also runs in the serialmayChangeFilesqueue, blocking all other serial checks behind it.The problem
extractCollectors()passes all ~36K TS files from each of the 10 telemetry roots intots.createProgram(), even though only ~69 files across the entire repo actually containmakeUsageCollectorormakeStatsCollectorcalls.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:
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):x-pack/platform/root (largest x-pack root):CI estimate:
telemetry.shshould drop from ~8m 45s to ~3-4 min.How it was tested
createKibanaProgramlocally with the actual Kibana telemetry rootsMade with Cursor