diff --git a/opensearch/client.go b/opensearch/client.go index 938dbef..c2c5fba 100644 --- a/opensearch/client.go +++ b/opensearch/client.go @@ -64,7 +64,7 @@ func (c *Client) Send(ld *LogDocument) { serialized, _ := json.Marshal(ld) go func(serialized []byte) { sending := atomic.AddInt32(&c.sendingCount, 1) - atomic.AddInt32(&c.sendingCount, -1) + defer atomic.AddInt32(&c.sendingCount, -1) if sending > 100 { logger.Println("sending log bottleneck :", sending) @@ -102,7 +102,7 @@ func (c *Client) SendBulk(ds map[string]*LogDocument) { go func(contents string) { sending := atomic.AddInt32(&c.sendingCount, 1) - atomic.AddInt32(&c.sendingCount, -1) + defer atomic.AddInt32(&c.sendingCount, -1) if sending > 100 { logger.Println("sending log bottleneck :", sending)