TP-5555 | ignore pattern module

This commit is contained in:
varnit goyal
2024-11-19 11:10:35 +05:30
parent 697b105fe1
commit 383204605a
2 changed files with 20 additions and 0 deletions

View File

@@ -3,6 +3,7 @@ package service
import (
"bufio"
"cybertron/configs"
"cybertron/constants"
"cybertron/models/db"
"cybertron/models/instrumentation"
inPodCache "cybertron/pkg/cache"
@@ -59,6 +60,15 @@ type Payload struct {
Extra interface{} `json:"extra"`
}
func isIgnored(value string) bool {
for _, pattern := range constants.IgnorePatterns {
if pattern.MatchString(value) {
return true
}
}
return false
}
func NewExceptionService(logger *log.Logger, dbClient *gorm.DB, kafkaProducer producer.KProducer, cache *inPodCache.Cache, kafkaConfig configs.KafkaConfig) *ExceptionService {
return &ExceptionService{
logger: logger,
@@ -110,6 +120,9 @@ func (exceptionService *ExceptionService) CatchErrors(c *gin.Context) {
metrics.PublishErrorConsumptionMetric(instrumentation.ErrorConsumptionMetric{ProjectId: projectID})
for _, errorItem := range jsonData.Exception.Values {
if isIgnored(errorItem.Value) {
continue
}
errorItem.ProjectId = projectID
errorItem.Breadcrumbs = jsonData.Breadcrumbs
errorItem.Extra = jsonData.Extra