Commit 133c453
authored
[telemetry] Detect Python package manager(s) at project setup (#1918)
## Changes
Measurement-only telemetry to learn which Python package manager(s) our
users' projects actually use (pip / conda / uv / poetry), so the VPEX
setup-flow investment can be prioritized from first-party data instead
of public-survey estimates. No setup behavior changes — this is
detection only.
The work splits cleanly into three layers so each is independently
testable and the dependency direction stays correct (high-level →
low-level):
- **Pure classifier** (`packageManagerDetection.ts`): given a set of
already-collected signals, reports every applicable manager, a
best-guess primary (priority `uv > poetry > conda > pip`), the firing
signals, `hasLockfile`, and interpreter source. Side-effect free and
total.
- **Emit** (`telemetry/packageManagerExtensions.ts`): adds
`recordPackageManagerDetection` to the existing `Telemetry` class via
the same `declare module` pattern as `commandExtensions.ts`. Keeps
disk/Python-extension dependencies out of the telemetry client.
- **Collection** (`PackageManagerTelemetry.ts`): a best-effort,
non-blocking collector that reads disk and already-resolved interpreter
metadata, runs the pure classifier, and calls the emit method.
Deduplicated per session on `(trigger, projectRoot)`; any failure
degrades to `unknown` and is swallowed so it never disrupts setup.
Emission is wired into three setup touchpoints: project-open environment
check (`auto_open`), the set-up-environment command
(`explicit_command`), and first Run/Debug with Databricks Connect
(`run`/`debug`).
A new `Events.PYTHON_ENV_SETUP_DETECTED` event carries a typed,
documented schema (reuses the existing telemetry transport; opt-out
honored; categorical data only — no paths, package names, or cluster
names). A handoff note for the analytics/dashboard owner is included at
`src/telemetry/PACKAGE_MANAGER_DETECTION.md`.
**Detection correctness** (the parts most worth reviewing):
- `interpreterSource` is derived from the active interpreter alone,
never from project files. A `uv.lock` project running a
conda/venv/system interpreter reports that interpreter's real source,
keeping the "uv project, interpreter not uv-managed yet" setup-flow gap
visible. A genuinely uv-provisioned venv is identified by the `uv =`
marker in `pyvenv.cfg`, not by `uv.lock`.
- conda is attributed only when the active interpreter resides under
`CONDA_PREFIX` (path-boundary checked), not on the bare env var — which
is session-global in the extension host (launching VS Code from an
activated conda shell) and would otherwise over-count conda for
uv/poetry/pip projects.
- `pyproject` `[tool.uv]`/`[tool.poetry]` detection uses a bounded
table-header scan, not substring matching: ignores comments and in-value
mentions, rejects prefix collisions (e.g. `tool.uvicorn`), and matches
subtable and array-of-table headers (`[tool.uv.sources]`,
`[[tool.poetry.source]]`).
- No external executable is run for telemetry: the uv-on-PATH probe was
removed (it spawned a PATH-resolved `uv` for a weak, non-attributing
signal). Detection reads only disk and already-resolved interpreter
metadata.
**Scope / privacy:** measurement only — no changes to setup behavior
(the VPEX flows are a separate effort). Only enum/categorical data and a
closed set of signal identifiers are emitted; the existing telemetry
opt-out (`telemetry.telemetryLevel`) is respected by the transport.
## Tests
- [x] `yarn run test:unit`: 202 passing, 0 failing — includes the pure
classifier (each manager, interpreter sources, overlaps like uv+pip /
conda+pip / poetry+uv, weak signals, none) and pure helpers
(`pyprojectHasToolSection`, `pyvenvCfgMarksUv`,
`interpreterUnderCondaPrefix`), covering the conda-prefix boundary and
shell-global false-positive cases.
- [x] `yarn run build` (typecheck) passes.
- [x] `eslint` clean; `prettier` formatted.
Reviewer can validate with:
```bash
cd packages/databricks-vscode
yarn run build
yarn run test:unit
npx eslint src --ext ts && npx prettier . -c
```1 parent 04f964b commit 133c453
13 files changed
Lines changed: 1581 additions & 7 deletions
File tree
- packages/databricks-vscode/src
- language
- run
- telemetry
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
75 | 75 | | |
76 | 76 | | |
77 | 77 | | |
| 78 | + | |
78 | 79 | | |
79 | 80 | | |
80 | 81 | | |
| |||
335 | 336 | | |
336 | 337 | | |
337 | 338 | | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
338 | 357 | | |
339 | 358 | | |
340 | 359 | | |
| |||
619 | 638 | | |
620 | 639 | | |
621 | 640 | | |
622 | | - | |
| 641 | + | |
| 642 | + | |
623 | 643 | | |
624 | 644 | | |
625 | 645 | | |
626 | 646 | | |
627 | 647 | | |
628 | | - | |
| 648 | + | |
| 649 | + | |
629 | 650 | | |
630 | 651 | | |
631 | 652 | | |
| |||
1003 | 1024 | | |
1004 | 1025 | | |
1005 | 1026 | | |
1006 | | - | |
| 1027 | + | |
| 1028 | + | |
1007 | 1029 | | |
1008 | 1030 | | |
1009 | 1031 | | |
| |||
Lines changed: 4 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
11 | 12 | | |
12 | 13 | | |
13 | | - | |
| 14 | + | |
| 15 | + | |
14 | 16 | | |
15 | 17 | | |
16 | 18 | | |
17 | 19 | | |
| 20 | + | |
18 | 21 | | |
19 | 22 | | |
20 | 23 | | |
| |||
Lines changed: 7 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
13 | 14 | | |
14 | 15 | | |
15 | 16 | | |
| |||
18 | 19 | | |
19 | 20 | | |
20 | 21 | | |
21 | | - | |
| 22 | + | |
| 23 | + | |
22 | 24 | | |
23 | 25 | | |
24 | 26 | | |
| |||
404 | 406 | | |
405 | 407 | | |
406 | 408 | | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
407 | 413 | | |
408 | 414 | | |
409 | 415 | | |
| |||
Lines changed: 209 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
0 commit comments