databricks-cli/libs
shreyas-goenka 06b71fe5da
Add synchronous logger for telemetry (#2432)
## Changes
This PR adds a synchronous telemetry logger for the CLI with a max
timeout of 3 seconds. Due to the 3-second timeout configuration, this is
only meant to be used in long-running commands.

This is a short-term solution. Eventually, we'd like to transition to a
daemon process to upload the telemetry logs to amortise the costs of
configuring authentication and maintaining a warm pool of HTTP
connections, as well as a better UX for the end user.

Note that users can set the `DATABRICKS_CLI_DISABLE_TELEMETRY`
environment variable to disable telemetry collection.

## Why
To collect telemetry, which was previously inaccessible to us, and
answer questions like which templates customers like to use and which
DABs features would be safe to deprecate.

## Tests
Unit and acceptance tests. 

Also manually verified that the telemetry upload works:
```
(artifact-playground) ➜  cli git:(sync-logger) cli selftest send-telemetry --debug
15:58:20 Info: start pid=40386 version=0.0.0-dev+a2825ca89a23 args="cli, selftest, send-telemetry, --debug"
15:58:20 Debug: Loading DEFAULT profile from /Users/shreyas.goenka/.databrickscfg pid=40386 sdk=true
15:58:20 Info: completed execution pid=40386 exit_code=0
15:58:21 Debug: POST /telemetry-ext
> {
>   "items": null,
>   "protoLogs": [
>     "{\"frontend_log_event_id\":\"82d29b3a-d5ff-48f3-8a21-dae6e08d2999\",\"entry\":{\"databricks_cli_log\":{\"... (232 more bytes)",
>     "{\"frontend_log_event_id\":\"d6be8220-7db8-45d9-97d6-4c09c25e2664\",\"entry\":{\"databricks_cli_log\":{\"... (232 more bytes)"
>   ],
>   "uploadTime": 1741186700967
> }
< HTTP/2.0 200 OK
< {
<   "errors": null,
<   "numProtoSuccess": 2,
<   "numSuccess": 0
< } pid=40386 sdk=true
```
2025-03-12 13:05:10 +00:00
..
auth Add the `auth.ProcessEnv` function (#2404) 2025-03-04 14:47:11 +00:00
cmdgroup build(deps): bump github.com/spf13/cobra from 1.8.1 to 1.9.1 (#2358) 2025-02-25 20:26:11 +00:00
cmdio Synchronize logging in cmdio (#2418) 2025-03-03 13:42:43 +00:00
command Add library to store cmd-exec-id in context (#2439) 2025-03-10 13:11:24 +00:00
daemon Do not pass parent pid to child daemon process (#2376) 2025-02-26 17:39:45 +05:30
databrickscfg Refactor `bundle init` (#2074) 2025-01-20 12:09:28 +00:00
dbr Store DBR version in context (#2438) 2025-03-06 13:01:43 +00:00
diag Encourage the use of root_path in production to ensure single deployment (#1712) 2025-01-13 12:19:12 +00:00
dyn Add warning when variable interpolation is used for auth fields (#2399) 2025-02-27 15:58:48 +00:00
env Add acceptance tests (#2081) 2025-01-08 12:41:08 +00:00
errs Enable perfsprint linter and apply autofix (#2071) 2025-01-07 10:49:23 +00:00
exec exec(test): Do not clear PATH; this breaks coverage on Windows (#2150) 2025-01-15 12:05:46 +01:00
fakefs Enable perfsprint linter and apply autofix (#2071) 2025-01-07 10:49:23 +00:00
filer Move `WorkspaceClient` to `libs/command` (#2444) 2025-03-07 16:47:19 +00:00
fileset Enable testifylint and fix the issues (#2065) 2025-01-02 12:03:41 +01:00
flags Always print warnings and errors; clean up format (#2213) 2025-02-07 11:29:40 +00:00
folders Enable testifylint and fix the issues (#2065) 2025-01-02 12:03:41 +01:00
git Do not modify/create .gitignore in bundle root (#2429) 2025-03-05 10:57:05 +00:00
iamutil Move utility functions dealing with IAM to libs/iamutil (#1820) 2024-10-10 13:02:25 +00:00
jsonschema Output deprecated annotations in the JSON schema (#2422) 2025-03-05 11:17:03 +00:00
locker Enable perfsprint linter and apply autofix (#2071) 2025-01-07 10:49:23 +00:00
log Always print warnings and errors; clean up format (#2213) 2025-02-07 11:29:40 +00:00
notebook Format Python code with ruff (#2166) 2025-01-17 07:38:47 +00:00
patchwheel Add libs/patchwheel: insert dynamic version in whl (#2427) 2025-03-06 10:28:30 +00:00
process Enable perfsprint linter and apply autofix (#2071) 2025-01-07 10:49:23 +00:00
python libs/python: Remove DetectInterpreters (#2234) 2025-01-27 13:22:08 +00:00
set Show actionable errors for collaborative deployment scenarios (#1386) 2024-10-10 11:18:23 +00:00
sync Do not modify/create .gitignore in bundle root (#2429) 2025-03-05 10:57:05 +00:00
tags Enable perfsprint linter and apply autofix (#2071) 2025-01-07 10:49:23 +00:00
telemetry Add synchronous logger for telemetry (#2432) 2025-03-12 13:05:10 +00:00
template Fix uv in experimental-jobs-as-code template (#2476) 2025-03-12 10:47:38 +00:00
terraform Move to a single prompt during bundle destroy (#1583) 2024-07-24 13:02:19 +00:00
testdiff Add ability to record headers in acceptance tests (#2296) 2025-02-05 09:32:15 +00:00
testfile Refactor and cover edge cases in sync integration tests (#160) 2023-01-10 13:16:30 +01:00
testserver Make fake_workspace create all parent folders exist when importing a file (#2465) 2025-03-11 09:13:31 +00:00
textutil Enable gofumpt and goimports in golangci-lint (#1999) 2024-12-12 10:28:42 +01:00
vfs Enable testifylint and fix the issues (#2065) 2025-01-02 12:03:41 +01:00