Skip to content

Commit 29d7bbc

Browse files
anton-107Isaac
andcommitted
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
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* `apps init` no longer suggests installing skills when a detected coding agent has the Databricks plugin. ([#7467](https://github.com/databricks/cli/pull/7467))
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* Bound the whole telemetry upload at exit, including config resolution and authentication, by its timeout, so a stalled auth or telemetry endpoint no longer keeps a command from exiting. ([#7467](https://github.com/databricks/cli/pull/7467))

‎acceptance/cmd/aitools/telemetry/apps-init-tip/home/.claude/.gitkeep‎

Whitespace-only changes.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Cloud = false
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
2+
=== apps init with flags prints the tip: one hint-shown event per hint printed
3+
4+
>>> [CLI] apps init --template ./template --skip-install --name app-tip
5+
Databricks skills are not installed. To work with Databricks reliably, first run: databricks aitools install
6+
✔ Creating project
7+
8+
✔ Project created successfully!
9+
10+
Location: [TEST_TMP_DIR]/app-tip
11+
Files: 3
12+
13+
Tip: coding agents detected without Databricks skills. Run 'databricks aitools install' to install them.
14+
15+
>>> print_telemetry
16+
{"command":"apps_init","exit_code":0,"aitools_hint_event":{"hint_kind":"INSTALL_TEXT"}}
17+
{"command":"apps_init","exit_code":0,"aitools_hint_event":{"hint_kind":"APPS_INIT_TIP"}}
18+
19+
=== plugin installed: no hint, no tip, no event
20+
21+
>>> [CLI] apps init --template ./template --skip-install --name app-plugin
22+
✔ Creating project
23+
24+
✔ Project created successfully!
25+
26+
Location: [TEST_TMP_DIR]/app-plugin
27+
Files: 3
28+
29+
30+
>>> print_telemetry
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"plugins":{"databricks@claude-plugins-official":[{"scope":"user","version":"0.2.9"}]}}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Isolate HOME so the real machine's agents and skills are not seen. The
2+
# committed home/.claude, a Claude Code config dir without Databricks skills, is
3+
# what makes apps init print its tip.
4+
sethome home
5+
export CLAUDECODE=1
6+
unset CLAUDE_CODE_SESSION_ID
7+
unset CLAUDE_CONFIG_DIR
8+
9+
title "apps init with flags prints the tip: one hint-shown event per hint printed"
10+
trace $CLI apps init --template ./template --skip-install --name app-tip > LOG.apps-init
11+
trace print_telemetry
12+
rm -rf app-tip
13+
14+
title "plugin installed: no hint, no tip, no event"
15+
sethome ./plugin-home
16+
trace $CLI apps init --template ./template --skip-install --name app-plugin > LOG.apps-init-plugin
17+
trace print_telemetry
18+
rm -rf app-plugin
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
command: ['npm', 'run', 'start']
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"version": "1.0",
3+
"plugins": {}
4+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
bundle:
2+
name: {{.projectName}}

0 commit comments

Comments
 (0)