From 90faa7d681e0267aa3da051d3fbbbcfed3e0c08a Mon Sep 17 00:00:00 2001 From: mountain Date: Thu, 11 Sep 2025 18:37:56 +0900 Subject: [PATCH] =?UTF-8?q?=EB=A1=9C=EA=B7=B8=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- opensearch/client.go | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/opensearch/client.go b/opensearch/client.go index e7db124..fa29ea9 100644 --- a/opensearch/client.go +++ b/opensearch/client.go @@ -220,13 +220,26 @@ func (c *Client) sendLoop(ctx context.Context) { var retry []*singleLogMarshaller for i, item := range respbody.Items { - if item.Create.Status < 400 { - // 재시도 + if item.Create.Status < 300 { + continue + } + + if item.Create.Status == 429 || item.Create.Status >= 500 { + logger.Println("[LogStream] send bulk failed but retry. status :", item.Create.Status) retry = append(retry, logs[i]) + } else if item.Create.Status == 400 { + // 구문 오류. 재시도 불가 + if i < len(logs) { + logger.Println("[LogStream] send bulk failed. status 400 :", string(logs[i].content)) + } else { + logger.Println("[LogStream] send bulk failed. status 400 but out of index :", i, len(logs)) + } + } else { + // 일단 로그만 + logger.Println("[LogStream] send bulk failed but no retry. status :", item.Create.Status) } } - logger.Println("[LogStream] send bulk failed. retry :", len(retry), len(logs), respbody.Items) if len(retry) > 0 { failChan <- retry }