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

View File

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

View File

@ -7,3 +7,11 @@ Response.Body = '''
}
'''
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
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
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 (
"encoding/json"
"fmt"
"os"
"github.com/databricks/cli/libs/cmdio"
"github.com/databricks/cli/libs/log"
"github.com/databricks/cli/libs/telemetry"
"github.com/spf13/cobra"
)
@ -22,15 +23,15 @@ func newTelemetryUpload() *cobra.Command {
resp, err := telemetry.Upload(ctx)
if err != nil {
fmt.Fprintf(os.Stderr, "error: %s\n", err)
log.Error(ctx, err.Error())
os.Exit(1)
}
fmt.Printf("Telemetry logs uploaded successfully\n")
fmt.Println("Response:")
cmdio.LogString(ctx, "Telemetry logs uploaded successfully")
cmdio.LogString(ctx, "Response:")
b, err := json.Marshal(resp)
if err == nil {
fmt.Println(string(b))
cmdio.LogString(ctx, string(b))
}
},
}