pierDipi / sacura

Detect CloudEvents loss
Apache License 2.0
0 stars 2 forks source link

Lost count #11

Closed slinkydeveloper closed 3 years ago

slinkydeveloper commented 3 years ago

It would be nice to have a log, before logging the state of received events, to log the number of lost events, that is accepted events (e.g. received a 202) but that were never received.

In order to do that I think you need to record the uuids of each succeded res https://github.com/pierDipi/sacura/blob/main/attacker.go#L26 and then add a new channel in the state https://github.com/pierDipi/sacura/blob/main/state.go

So at the end of the day you'll just need:

func (s *StateManager) LostCount() int {
    received := s.received.List()
    sent := s.sent.List()

    return sets.NewString(sent...).Delete(received...).Len()
}
slinkydeveloper commented 3 years ago

It would also be nice to have not accepted events, but this can be inferred easily from other metrics (the non 202 status codes are obv not accepted :smile: )

pierDipi commented 3 years ago

Definitely!

pierDipi commented 3 years ago

Do you want to provide a PR? :)

slinkydeveloper commented 3 years ago

Lemme draft something :smile: but be aware, it requires to move around some code