mirror of https://github.com/databricks/cli.git
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
This commit is contained in:
parent
ddc0237468
commit
089bebc92f
|
@ -9,6 +9,15 @@ import (
|
||||||
"github.com/databricks/databricks-sdk-go/service/pipelines"
|
"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
|
type ProgressEvent pipelines.PipelineEvent
|
||||||
|
|
||||||
func (event *ProgressEvent) String() string {
|
func (event *ProgressEvent) String() string {
|
||||||
|
@ -21,8 +30,8 @@ func (event *ProgressEvent) String() string {
|
||||||
result.WriteString(event.Level.String() + " ")
|
result.WriteString(event.Level.String() + " ")
|
||||||
result.WriteString(fmt.Sprintf(`"%s"`, event.Message))
|
result.WriteString(fmt.Sprintf(`"%s"`, event.Message))
|
||||||
|
|
||||||
// construct error string
|
// construct error string if level=`Error`
|
||||||
if event.Error != nil {
|
if event.Level == pipelines.EventLevelError && event.Error != nil {
|
||||||
for _, exception := range event.Error.Exceptions {
|
for _, exception := range event.Error.Exceptions {
|
||||||
result.WriteString(fmt.Sprintf("\n%s", exception.Message))
|
result.WriteString(fmt.Sprintf("\n%s", exception.Message))
|
||||||
}
|
}
|
||||||
|
|
|
@ -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())
|
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())
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue