Repository navigation
Commit 29d7bbc
aitools: log install-hint telemetry and bound telemetry uploads
The CLI logs a new `aitools_hint_event` each time it shows a recommendation to install Databricks AI tools, so hints shown can be compared with installs that follow. It also bounds the whole telemetry upload, including client construction and authentication, by the upload timeout.
```diff
MaybeHint(ctx, cmd) # non-aitools command run by Claude Code without the tools
cmdio.LogString(hintText)
+ logHintShown(INSTALL_TEXT)
runCreate (apps init)
flags mode, skills missing
- cmdio.LogString("Tip: ...")
+ PrintSkillsTip # prints the same tip
+ logHintShown(APPS_INIT_TIP)
otherwise: RecommendSkillsInstall, skills missing
no prompt possible
- cmdio.LogString("Tip: ...")
+ PrintSkillsTip # APPS_INIT_TIP
+ logHintShown(APPS_INIT_PROMPT) # before asking, so a declined prompt counts
AskYesOrNo(...)
```
Wire shape (one entry per hint shown):
```json
{"aitools_hint_event": {"hint_kind": "INSTALL_TEXT"}}
```
- The event carries only the hint kind. The command it was shown on is the entry's `execution_context.command`. The calling agent is not a field: the SDK already sends `agent/<name>` in the User-Agent of the telemetry upload.
- `AitoolsHintKind` also declares `CLAUDE_CODE_NATIVE` and `AGENT_INSTALL_TEXT`, which nothing emits yet.
- One `apps init` run can log two events (`INSTALL_TEXT` from the root hint and `APPS_INIT_TIP`), so count per `hint_kind`.
- The `apps init` tip and prompt now also stay silent when a detected agent has the databricks plugin in its own plugin manifest, not only when the skills are installed (`HasDatabricksToolingInstalled`).
Upload timeout (`libs/telemetry/logger.go`). The SDK resolves the config (including host metadata discovery) and fetches tokens with `context.Background()`, so before this change the upload timeout bounded only the HTTP requests. A slow token endpoint or host could hold the command's exit far past the timeout.
```diff
Upload(ctx)
- client.New(cfg) # unbounded: config resolution, host metadata
ctx = WithTimeout(uploadTimeout) # 3s, DATABRICKS_CLI_TELEMETRY_TIMEOUT
+ within(ctx, newAPIClient(cfg)) # client construction gives up at the deadline
+ AuthVisitor = authenticate # every request, SDK retries included:
+ within(ctx, cfg.Authenticate) # gives up at the deadline
for 3 attempts: attempt(ctx, ...) # requests stay on the caller's goroutine
```
An upload whose events are all hint events uses a 1s timeout instead of the 3s default, since most commands that show a hint would otherwise not upload at all. `DATABRICKS_CLI_TELEMETRY_TIMEOUT`, when set, applies to every upload. A hint-only upload is skipped when the command's credentials never resolved (`cfg.AuthType` is empty), so a command whose auth failed does not run the credential chain again at exit.
On timeout the goroutine started by `within` is abandoned; a panic in it is returned as an error. `cmd/root` runs `Upload` as the last step before the process exits; the ssh agent shim runs it just before exec, and while an abandoned goroutine still runs, a second `Upload` on the same logger is skipped.
Supporting changes:
```text
libs/telemetry/logger.go BufferedEvents(ctx): read buffered events from tests in other packages
libs/testserver/handlers.go POST /telemetry-ext accepts every log in the request
acceptance/cmd/aitools/telemetry/ print_telemetry helper + `hint` and `apps-init-tip` cases
libs/aitools/agents/hint_test.go uses testutil.SetAgentEnv instead of its own agent env list
```
Changelog fragments: `.nextchanges/cli/telemetry-upload-timeout.md`, `.nextchanges/cli/apps-init-plugin-tip.md`.
Co-authored-by: Isaac <no-reply@databricks.com>1 parent 8b4f052 commit 29d7bbc
32 files changed
Lines changed: 774 additions & 58 deletions
File tree
- .nextchanges/cli
- acceptance/cmd/aitools/telemetry
- apps-init-tip
- home/.claude
- plugin-home/.claude/plugins
- template
- hint
- installed-home/.claude/plugins
- cmd
- apps
- root
- libs
- aitools/agents
- telemetry
- protos
- testserver
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
Whitespace-only changes.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 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 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 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 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
0 commit comments