Skip to content

Commit

Permalink
Add a "NotOK" counter
Browse files Browse the repository at this point in the history
Fixes #4
  • Loading branch information
Lars Ekman committed Dec 26, 2020
1 parent 0abe0b9 commit 2338101
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion cmd/kahttp/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,6 @@ func (c *config) client(ctx context.Context, wg *sync.WaitGroup, s *statistics)

s.failedConnection(1)
}

}

func monitor(s *statistics) {
Expand Down Expand Up @@ -379,6 +378,10 @@ func (c *httpConn) Run(ctx context.Context, s *statistics) error {
return err
}

if resp.StatusCode != 200 {
s.notok(1)
}

s.received(1)
}

Expand Down Expand Up @@ -494,6 +497,7 @@ type statistics struct {
FailedConnects uint
mutex sync.Mutex
Hosts map[string]int `json:",omitempty"`
NotOK uint32
}

type sample struct {
Expand Down Expand Up @@ -534,6 +538,9 @@ func (s *statistics) dropped(n uint32) {
func (s *statistics) failedConnection(n uint32) {
atomic.AddUint32(&s.FailedConnections, n)
}
func (s *statistics) notok(n uint32) {
atomic.AddUint32(&s.NotOK, n)
}

func (s *statistics) reportStats() {
s.Duration = time.Now().Sub(s.Started)
Expand Down

0 comments on commit 2338101

Please sign in to comment.