This commit is contained in:
Shreyas Goenka 2024-12-20 12:16:22 +05:30
parent 1912ebd8f6
commit bb9747e1e2
No known key found for this signature in database
GPG Key ID: 92A07DF49CCB0622
2 changed files with 6 additions and 3 deletions

View File

@ -40,20 +40,22 @@ func TestTelemetryLogger(t *testing.T) {
})
// Log some events.
telemetry.Log(ctx, telemetry.FrontendLogEntry{
err := telemetry.Log(ctx, telemetry.FrontendLogEntry{
DatabricksCliLog: telemetry.DatabricksCliLog{
CliTestEvent: telemetry.CliTestEvent{
Name: telemetry.DummyCliEnumValue1,
},
},
})
telemetry.Log(ctx, telemetry.FrontendLogEntry{
require.NoError(t, err)
err = telemetry.Log(ctx, telemetry.FrontendLogEntry{
DatabricksCliLog: telemetry.DatabricksCliLog{
CliTestEvent: telemetry.CliTestEvent{
Name: telemetry.DummyCliEnumValue2,
},
},
})
require.NoError(t, err)
apiClient, err := client.New(w.W.Config)
require.NoError(t, err)

View File

@ -54,7 +54,8 @@ var MaxAdditionalWaitTime = 2 * time.Second
// batching the logs across multiple API calls.
func Flush(ctx context.Context, apiClient DatabricksApiClient) {
// Set a maximum time to wait for the telemetry event to flush.
ctx, _ = context.WithTimeout(ctx, MaxAdditionalWaitTime)
ctx, cancel := context.WithTimeout(ctx, MaxAdditionalWaitTime)
defer cancel()
l := fromContext(ctx)
// We pass the API client as an arg to mock it in unit tests.