Skip to content

Commit

Permalink
Move LastOK onto Check instead of Event
Browse files Browse the repository at this point in the history
Signed-off-by: Zach Bintliff <zbintliff@gmail.com>
  • Loading branch information
zbintliff committed Feb 23, 2018
1 parent bb999a1 commit d9b1ca5
Show file tree
Hide file tree
Showing 9 changed files with 133 additions and 132 deletions.
1 change: 0 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ set when importing legacy settings.
- Add event metrics type, implementing the Sensu Metrics Format.
- Added non-functional selections for resolving and silencing to web ui
- Add LastOk to event type. This will be updated to reflect the last timestamp of a succesful event
- Add LastOK to event type. This will be updated to reflect the last timestamp of a succesful event

### Changed
- Refactor Check data structure to not depend on CheckConfig. This is a breaking
Expand Down
1 change: 0 additions & 1 deletion backend/eventd/eventd.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,6 @@ func (e *Eventd) handleMessage(msg interface{}) error {
}

event.Check.MergeWith(prevEvent.Check)
event.LastOK = prevEvent.LastOK
}

// Calculate percent state change for this check's history
Expand Down
2 changes: 1 addition & 1 deletion backend/eventd/eventd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func TestEventHandling(t *testing.T) {

// Make sure the event has been marked with the proper state
assert.Equal(t, types.EventPassingState, event.Check.State)
assert.Equal(t, badEvent.Timestamp, event.LastOK)
assert.Equal(t, event.Timestamp, event.Check.LastOK)
}

func TestEventMonitor(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion backend/eventd/flapping.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func state(event *types.Event) {
event.Check.State = types.EventFlappingState
} else if event.Check.Status == 0 {
event.Check.State = types.EventPassingState
event.LastOK = event.Timestamp
event.Check.LastOK = event.Timestamp
} else {
event.Check.State = types.EventFailingState
}
Expand Down
1 change: 1 addition & 0 deletions types/check.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ func (c *Check) MergeWith(chk *Check) {
}

c.History = history
c.LastOK = chk.LastOK
}

// FixtureCheckRequest returns a fixture for a CheckRequest object.
Expand Down
167 changes: 107 additions & 60 deletions types/check.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions types/check.proto
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,9 @@ message Check {
// check's history
uint32 total_state_change = 29;

// LastOK displays last time this check was ok; if event status is 0 this is set to timestamp
int64 last_ok = 30 [(gogoproto.customname) = "LastOK"];

// ExtendedAttributes store serialized arbitrary JSON-encoded data
bytes ExtendedAttributes = 99 [(gogoproto.jsontag) = "-"];
}
Expand Down
Loading

0 comments on commit d9b1ca5

Please sign in to comment.