TP-5555 | elastic error handling

This commit is contained in:
varnit goyal
2024-11-18 15:52:38 +05:30
parent b4cca04ad3
commit 4a98f36a28
2 changed files with 9 additions and 3 deletions

View File

@@ -34,12 +34,14 @@ func NewElasticClient(elasticConfig configs.ElasticConfig) (*ElasticSearchClient
}, err
}
func (el *ElasticSearchClient) IndexDocument(document interface{}) {
func (el *ElasticSearchClient) IndexDocument(document interface{}) error {
_, err := el.client.Index("cybertron").
Request(document).
Do(context.Background())
if err != nil {
log.Printf("Error ingesting the doc: %s", err)
log.Printf("Error ingesting the doc: %v", err)
return err
}
return nil
}

View File

@@ -196,5 +196,9 @@ func (ep *ErrorProcessor) ProcessError(error []byte) {
Extra: payload.Extra,
Request: payload.Request,
}
ep.elasticSearchClient.IndexDocument(errorDocument)
elastic_err := ep.elasticSearchClient.IndexDocument(errorDocument)
if elastic_err != nil {
ep.logger.Info("error occured in elasticsearch", zap.Error(elastic_err))
return
}
}