use proper loggers

This commit is contained in:
Shreyas Goenka 2025-03-05 13:56:16 +01:00
parent 116c513e15
commit 9e29462562
No known key found for this signature in database
GPG Key ID: 92A07DF49CCB0622
6 changed files with 35 additions and 26 deletions

View File

@ -1,5 +1,5 @@
13:45:02 Info: start pid=73585 version=[DEV_VERSION] args="[CLI], telemetry, upload, --log-level=debug" HH:MM:SS Info: start pid=PID version=[DEV_VERSION] args="[CLI], telemetry, upload, --log-level=debug"
13:45:02 Debug: POST /telemetry-ext HH:MM:SS Debug: POST /telemetry-ext
> { > {
> "items": null, > "items": null,
> "protoLogs": [ > "protoLogs": [
@ -12,11 +12,11 @@
< { < {
< "error_code": "ERROR_CODE", < "error_code": "ERROR_CODE",
< "message": "Endpoint not implemented." < "message": "Endpoint not implemented."
< } pid=73585 sdk=true < } pid=PID sdk=true
13:45:02 Debug: non-retriable error: Endpoint not implemented. pid=73585 sdk=true HH:MM:SS Debug: non-retriable error: Endpoint not implemented. pid=PID sdk=true
13:45:02 Warn: Attempt 0 failed due to a server side error. Retrying status code: 501 HH:MM:SS Warn: Attempt 0 failed due to a server side error. Retrying status code: 501
pid=73585 pid=PID
13:45:04 Debug: POST /telemetry-ext HH:MM:SS Debug: POST /telemetry-ext
> { > {
> "items": null, > "items": null,
> "protoLogs": [ > "protoLogs": [
@ -29,11 +29,11 @@
< { < {
< "error_code": "ERROR_CODE", < "error_code": "ERROR_CODE",
< "message": "Endpoint not implemented." < "message": "Endpoint not implemented."
< } pid=73585 sdk=true < } pid=PID sdk=true
13:45:04 Debug: non-retriable error: Endpoint not implemented. pid=73585 sdk=true HH:MM:SS Debug: non-retriable error: Endpoint not implemented. pid=PID sdk=true
13:45:04 Warn: Attempt 1 failed due to a server side error. Retrying status code: 501 HH:MM:SS Warn: Attempt 1 failed due to a server side error. Retrying status code: 501
pid=73585 pid=PID
13:45:06 Debug: POST /telemetry-ext HH:MM:SS Debug: POST /telemetry-ext
> { > {
> "items": null, > "items": null,
> "protoLogs": [ > "protoLogs": [
@ -46,8 +46,8 @@
< { < {
< "error_code": "ERROR_CODE", < "error_code": "ERROR_CODE",
< "message": "Endpoint not implemented." < "message": "Endpoint not implemented."
< } pid=73585 sdk=true < } pid=PID sdk=true
13:45:06 Debug: non-retriable error: Endpoint not implemented. pid=73585 sdk=true HH:MM:SS Debug: non-retriable error: Endpoint not implemented. pid=PID sdk=true
13:45:06 Warn: Attempt 2 failed due to a server side error. Retrying status code: 501 HH:MM:SS Warn: Attempt 2 failed due to a server side error. Retrying status code: 501
pid=73585 pid=PID
error: upload did not succeed after three attempts HH:MM:SS Error: upload did not succeed after three attempts pid=PID

View File

@ -1,5 +1,5 @@
>>> [CLI] selftest send-telemetry --debug >>> [CLI] selftest send-telemetry --debug
13:45:02 Info: start pid=73578 version=[DEV_VERSION] args="[CLI], selftest, send-telemetry, --debug" HH:MM:SS Info: start pid=PID version=[DEV_VERSION] args="[CLI], selftest, send-telemetry, --debug"
13:45:02 Info: completed execution pid=73578 exit_code=0 HH:MM:SS Info: completed execution pid=PID exit_code=0
[wait_pid] process has ended [wait_pid] process has ended

View File

@ -7,3 +7,11 @@ Response.Body = '''
} }
''' '''
Response.StatusCode = 501 Response.StatusCode = 501
[[Repls]]
Old = "(?:[01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9]"
New = "HH:MM:SS"
[[Repls]]
Old = "pid=[0-9]+"
New = "pid=PID"

View File

@ -4,4 +4,4 @@ Warn: Attempt 1 failed due to a server side error. Retrying status code: 501
Warn: Attempt 2 failed due to a server side error. Retrying status code: 501 Warn: Attempt 2 failed due to a server side error. Retrying status code: 501
error: upload did not succeed after three attempts Error: upload did not succeed after three attempts

View File

@ -4,4 +4,4 @@ Warn: Attempt 1 was a partial success. Number of logs uploaded: 1 out of 2
Warn: Attempt 2 was a partial success. Number of logs uploaded: 1 out of 2 Warn: Attempt 2 was a partial success. Number of logs uploaded: 1 out of 2
error: upload did not succeed after three attempts Error: upload did not succeed after three attempts

View File

@ -2,9 +2,10 @@ package telemetry
import ( import (
"encoding/json" "encoding/json"
"fmt"
"os" "os"
"github.com/databricks/cli/libs/cmdio"
"github.com/databricks/cli/libs/log"
"github.com/databricks/cli/libs/telemetry" "github.com/databricks/cli/libs/telemetry"
"github.com/spf13/cobra" "github.com/spf13/cobra"
) )
@ -22,15 +23,15 @@ func newTelemetryUpload() *cobra.Command {
resp, err := telemetry.Upload(ctx) resp, err := telemetry.Upload(ctx)
if err != nil { if err != nil {
fmt.Fprintf(os.Stderr, "error: %s\n", err) log.Error(ctx, err.Error())
os.Exit(1) os.Exit(1)
} }
fmt.Printf("Telemetry logs uploaded successfully\n") cmdio.LogString(ctx, "Telemetry logs uploaded successfully")
fmt.Println("Response:") cmdio.LogString(ctx, "Response:")
b, err := json.Marshal(resp) b, err := json.Marshal(resp)
if err == nil { if err == nil {
fmt.Println(string(b)) cmdio.LogString(ctx, string(b))
} }
}, },
} }