From 089bebc92f07715342ec909308ca437a83c61b27 Mon Sep 17 00:00:00 2001 From: shreyas-goenka <88374338+shreyas-goenka@users.noreply.github.com> Date: Wed, 19 Apr 2023 22:11:05 +0200 Subject: [PATCH] Do not print exceptions for non ERROR events (#347) ## Changes Adds a check to not print exceptions trace for dlt events with a level < ERROR ## Tests Unit test --- bundle/run/progress/pipeline.go | 13 +++++++++++-- bundle/run/progress/pipeline_test.go | 21 +++++++++++++++++++++ 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/bundle/run/progress/pipeline.go b/bundle/run/progress/pipeline.go index 1372c627..72d82a47 100644 --- a/bundle/run/progress/pipeline.go +++ b/bundle/run/progress/pipeline.go @@ -9,6 +9,15 @@ import ( "github.com/databricks/databricks-sdk-go/service/pipelines" ) +// The dlt backend computes events for pipeline runs which are accessable through +// the 2.0/pipelines/{pipeline_id}/events API +// +// There are 4 levels for these events: ("ERROR", "WARN", "INFO", "METRICS") +// +// Here's short introduction to a few important events we display on the console: +// +// 1. `update_progress`: A state transition occured for the entire pipeline update +// 2. `flow_progress`: A state transition occured for a single flow in the pipeine type ProgressEvent pipelines.PipelineEvent func (event *ProgressEvent) String() string { @@ -21,8 +30,8 @@ func (event *ProgressEvent) String() string { result.WriteString(event.Level.String() + " ") result.WriteString(fmt.Sprintf(`"%s"`, event.Message)) - // construct error string - if event.Error != nil { + // construct error string if level=`Error` + if event.Level == pipelines.EventLevelError && event.Error != nil { for _, exception := range event.Error.Exceptions { result.WriteString(fmt.Sprintf("\n%s", exception.Message)) } diff --git a/bundle/run/progress/pipeline_test.go b/bundle/run/progress/pipeline_test.go index 6f5665bb..ba4213ac 100644 --- a/bundle/run/progress/pipeline_test.go +++ b/bundle/run/progress/pipeline_test.go @@ -55,3 +55,24 @@ func TestUpdateErrorEventToString(t *testing.T) { } assert.Equal(t, "2023-03-27T23:30:36.122Z update_progress ERROR \"failed to update pipeline\"\nparsing error", event.String()) } + +func TestUpdateErrorIgnoredForWarnEvents(t *testing.T) { + event := ProgressEvent{ + EventType: "update_progress", + Message: "failed to update pipeline", + Level: pipelines.EventLevelWarn, + Origin: &pipelines.Origin{ + FlowName: "my_flow", + PipelineName: "my_pipeline", + }, + Timestamp: "2023-03-27T23:30:36.122Z", + Error: &pipelines.ErrorDetail{ + Exceptions: []pipelines.SerializedException{ + { + Message: "THIS IS IGNORED", + }, + }, + }, + } + assert.Equal(t, "2023-03-27T23:30:36.122Z update_progress WARN \"failed to update pipeline\"", event.String()) +}