Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions libbeat/outputs/logstash/async.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ func (c *asyncClient) sendEvents(ref *msgRef, events []publisher.Event) error {
window[i] = &events[i].Content
}
ref.count.Inc()
return client.Send(ref.callback, window)
return client.Send(ref.customizedCallback(), window)
}

func (c *asyncClient) getClient() *v2.AsyncClient {
Expand All @@ -229,7 +229,15 @@ func (c *asyncClient) getClient() *v2.AsyncClient {
return client
}

func (r *msgRef) callback(seq uint32, err error) {
func (r *msgRef) customizedCallback() func(uint32, error) {
start := time.Now()

return func(n uint32, err error) {
r.callback(start, n, err)
}
}

func (r *msgRef) callback(start time.Time, n uint32, err error) {
if err != nil {
r.fail(seq, err)
} else {
Expand All @@ -243,6 +251,11 @@ func (r *msgRef) done(n uint32) {
if r.win != nil {
r.win.tryGrowWindow(r.batchSize)
}

// Report the latency for the batch of events
duration := time.Since(start)
r.client.observer.ReportLatency(duration)

r.dec()
}

Expand Down
Loading