Skip to content

[9.3] Speed up telemetry check by sharing a single TS program across roots !! (#267651)#268008

Merged
kibanamachine merged 1 commit into
elastic:9.3from
kibanamachine:backport/9.3/pr-267651
May 6, 2026
Merged

[9.3] Speed up telemetry check by sharing a single TS program across roots !! (#267651)#268008
kibanamachine merged 1 commit into
elastic:9.3from
kibanamachine:backport/9.3/pr-267651

Conversation

@kibanamachine
Copy link
Copy Markdown
Contributor

Backport

This will backport the following commits from main to 9.3:

Questions ?

Please refer to the Backport tool documentation

…!! (elastic#267651)

## Summary

The CI telemetry check (`node scripts/telemetry_check`) was creating a
separate TypeScript program (`ts.createProgram` + `getTypeChecker()`)
for each of the 10 telemetry roots. Since each program independently
resolves the same shared Kibana transitive dependencies, this resulted
in ~212s of redundant sequential CPU work.

This PR:
- **Creates a single shared TS program** for all 69 collector files
across all roots, then partitions the parsed results back by root
- **Parallelizes globbing** across all roots via `Promise.all`
- **Extracts `filterCollectorPaths` and `extractCollectorsWithProgram`**
as reusable functions

### Benchmark results (local, 3 consistent runs)

| Metric | Before | After | Improvement |
|--------|--------|-------|-------------|
| Total wall time | **210s** | **59s** | **-151s (72%)** |
| TS type-check time | 212s (6 programs) | 50s (1 program) | -162s |
| Glob phase | 0.7s (sequential) | 0.3s (parallel) | -0.4s |

### Validation

- `node scripts/telemetry_check` — passes (no changes mode)
- `node scripts/telemetry_check --fix` — passes, correctly detects and
fixes schema drift
- `schema_checks.test.ts` — all 13 tests pass
- `kbn-telemetry-tools` unit tests — all 8 suites / 45 tests pass
- Tested with a real collector change (added field to CSP collector) to
verify end-to-end detection, fix, and schema JSON update

## Test plan

- [ ] CI telemetry check passes on this PR
- [ ] Verify telemetry check correctly detects schema drift when a
collector is modified
- [ ] Verify `--fix` correctly updates the JSON schema files
- [ ] Verify `--path` flag still works for scoped checks

Made with [Cursor](https://cursor.com)

---------

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
(cherry picked from commit 010a027)
@kibanamachine kibanamachine added the backport This PR is a backport of another PR label May 6, 2026
@kibanamachine kibanamachine enabled auto-merge (squash) May 6, 2026 16:08
@kibanamachine
Copy link
Copy Markdown
Contributor Author

💚 Build Succeeded

Metrics [docs]

✅ unchanged

cc @shahzad31

@kibanamachine kibanamachine merged commit 5b1aef5 into elastic:9.3 May 6, 2026
30 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport This PR is a backport of another PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants