Skip to content

Commit

Permalink
Fix last_error field not being properly defined (kuskoman#98)
Browse files Browse the repository at this point in the history
  • Loading branch information
excalq authored Apr 21, 2023
1 parent 81dfaac commit af59030
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 21 deletions.
13 changes: 11 additions & 2 deletions fetcher/responses/__snapshots__/nodestats_response_test.snap
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ responses.NodeStatsResponse{
Outputs: {
},
},
Reloads: struct { LastFailureTimestamp interface {} "json:\"last_failure_timestamp\""; Successes int "json:\"successes\""; Failures int "json:\"failures\""; LastSuccessTimestamp interface {} "json:\"last_success_timestamp\""; LastError interface {} "json:\"last_error\"" }{},
Reloads: responses.PipelineReloadResponse{},
Queue: struct { Type string "json:\"type\""; EventsCount int "json:\"events_count\""; QueueSizeInBytes int "json:\"queue_size_in_bytes\""; MaxQueueSizeInBytes int "json:\"max_queue_size_in_bytes\"" }{},
Hash: "",
EphemeralID: "",
Expand Down Expand Up @@ -125,7 +125,16 @@ responses.NodeStatsResponse{
},
},
},
Reloads: struct { LastFailureTimestamp interface {} "json:\"last_failure_timestamp\""; Successes int "json:\"successes\""; Failures int "json:\"failures\""; LastSuccessTimestamp interface {} "json:\"last_success_timestamp\""; LastError interface {} "json:\"last_error\"" }{},
Reloads: responses.PipelineReloadResponse{
LastFailureTimestamp: time.Date(2023, time.April, 20, 20, 0, 32, 437218256, time.UTC),
Successes: 3,
Failures: 1,
LastSuccessTimestamp: time.Date(2023, time.April, 20, 22, 30, 32, 437218256, time.UTC),
LastError: responses.LastError{
Message: "No configuration found in the configured sources.",
Backtrace: {"org/logstash/execution/AbstractPipelineExt.java:151:in `reload_pipeline'", "/usr/share/logstash/logstash-core/lib/logstash/java_pipeline.rb:181:in `block in reload_pipeline'", "/usr/share/logstash/vendor/bundle/jruby/2.3.0/gems/stud-0.0.23/lib/stud/task.rb:24:in `block in initialize'"},
},
},
Queue: struct { Type string "json:\"type\""; EventsCount int "json:\"events_count\""; QueueSizeInBytes int "json:\"queue_size_in_bytes\""; MaxQueueSizeInBytes int "json:\"max_queue_size_in_bytes\"" }{Type:"memory", EventsCount:0, QueueSizeInBytes:0, MaxQueueSizeInBytes:0},
Hash: "a73729cc9c29203931db21553c5edba063820a7e40d16cb5053be75cc3811a17",
EphemeralID: "a5c63d09-1ba6-4d67-90a5-075f468a7ab0",
Expand Down
29 changes: 15 additions & 14 deletions fetcher/responses/nodestats_response.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,13 +159,7 @@ type SinglePipelineResponse struct {
} `json:"events"`
} `json:"outputs"`
} `json:"plugins"`
Reloads struct {
LastFailureTimestamp interface{} `json:"last_failure_timestamp"`
Successes int `json:"successes"`
Failures int `json:"failures"`
LastSuccessTimestamp interface{} `json:"last_success_timestamp"`
LastError interface{} `json:"last_error"`
} `json:"reloads"`
Reloads PipelineReloadResponse `json:"reloads"`
Queue struct {
Type string `json:"type"`
EventsCount int `json:"events_count"`
Expand Down Expand Up @@ -212,16 +206,23 @@ type PipelineLogstashMonitoringResponse struct {
Filters []interface{} `json:"filters"`
Outputs []interface{} `json:"outputs"`
} `json:"plugins"`
Reloads struct {
LastFailureTimestamp *time.Time `json:"last_failure_timestamp,omitempty"`
Successes int `json:"successes"`
Failures int `json:"failures"`
LastSuccessTimestamp *time.Time `json:"last_success_timestamp,omitempty"`
LastError string `json:"last_error,omitempty"`
} `json:"reloads"`
Reloads PipelineReloadResponse `json:"reloads"`
Queue interface{} `json:"queue,omitempty"`
}

type PipelineReloadResponse struct {
LastFailureTimestamp *time.Time `json:"last_failure_timestamp,omitempty"`
Successes int `json:"successes"`
Failures int `json:"failures"`
LastSuccessTimestamp *time.Time `json:"last_success_timestamp,omitempty"`
LastError LastError `json:"last_error,omitempty"`
}

type LastError struct {
Message string `json:"message"`
Backtrace []string `json:"backtrace"`
}

type ReloadResponse struct {
Successes int `json:"successes"`
Failures int `json:"failures"`
Expand Down
17 changes: 12 additions & 5 deletions fixtures/node_stats.json
Original file line number Diff line number Diff line change
Expand Up @@ -202,11 +202,18 @@
]
},
"reloads": {
"last_failure_timestamp": null,
"successes": 0,
"failures": 0,
"last_success_timestamp": null,
"last_error": null
"last_failure_timestamp": "2023-04-20T20:00:32.437218256Z",
"successes": 3,
"failures": 1,
"last_success_timestamp": "2023-04-20T22:30:32.437218256Z",
"last_error": {
"message": "No configuration found in the configured sources.",
"backtrace": [
"org/logstash/execution/AbstractPipelineExt.java:151:in `reload_pipeline'",
"/usr/share/logstash/logstash-core/lib/logstash/java_pipeline.rb:181:in `block in reload_pipeline'",
"/usr/share/logstash/vendor/bundle/jruby/2.3.0/gems/stud-0.0.23/lib/stud/task.rb:24:in `block in initialize'"
]
}
},
"queue": {
"type": "memory",
Expand Down

0 comments on commit af59030

Please sign in to comment.