-
Notifications
You must be signed in to change notification settings - Fork 71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add async logger for telemetry #2278
base: main
Are you sure you want to change the base?
Conversation
@@ -0,0 +1 @@ | |||
{"method":"POST","path":"/telemetry-ext","body":{"uploadTime":"UNIX_TIME_MILLIS","items":[],"protoLogs":["{\"frontend_log_event_id\":\"[UUID]\",\"entry\":{\"databricks_cli_log\":{\"execution_context\":{\"cmd_exec_id\":\"[UUID]\",\"version\":\"[DEV_VERSION]\",\"command\":\"telemetry_dummy\",\"operating_system\":\"OS\",\"execution_time_ms\":\"SMALL_INT\",\"exit_code\":0},\"cli_test_event\":{\"name\":\"VALUE1\"}}}}","{\"frontend_log_event_id\":\"[UUID]\",\"entry\":{\"databricks_cli_log\":{\"execution_context\":{\"cmd_exec_id\":\"[UUID]\",\"version\":\"[DEV_VERSION]\",\"command\":\"telemetry_dummy\",\"operating_system\":\"OS\",\"execution_time_ms\":\"SMALL_INT\",\"exit_code\":0},\"cli_test_event\":{\"name\":\"VALUE2\"}}}}"]}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#2329 will make this easier to review.
// | ||
// This is a precaution to avoid conflicting auth configurations being passed | ||
// to the child telemetry process. | ||
for _, v := range base { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: Go SDK normally errors when conflicting auth is configured, but this is a precaution to sanitize the environment just in case.
This is done because telemetry is not in the happy path of user interaction. So we won't get a precise signal (i.e. issues reported) if we stop logging telemetry in some cases, so it's prudent to be more conservative here.
Changes
This PR adds an asynchronous logger for uploading telemetry. Now, at the end of every command's execution, the CLI (in the
root.Execute
function) checks if there are any logs to upload. If there are, a new process is spawned to upload the logs.Why do we spawn a new process?
Because it offers the best UX. It adds negligible end-user latency and is mostly invisible to the end user.
Why do we detect the upload command in
main.go
rather than making it a part of the Cobra framework?Because then the call graph gets circular. We want to upload logs at the common ancestor of all CLI commands which is the
root.Execute
function. However, if we have atelemetry worker
CLI command and someone accidentally logs something from that command then we'll have infinite spawning of the worker process recursively.Why do we pass the authentication credentials as environment variables?
Because that's how we do it for Terraform as well. There's no other good way to pass credentials today since the Go SDK does not offer a serializable format for passing credentials via stdin.
Tests
New acceptance and unit tests.