Merge pull request #45 from navi-ppl/TP-5555/log-remove
TP-5555 | ignore pattern module
This commit is contained in:
@@ -1,7 +1,14 @@
|
||||
package constants
|
||||
|
||||
import "regexp"
|
||||
|
||||
const (
|
||||
SESSION_HEADER_NAME = "x-session-token"
|
||||
EMAIL_HEADER_NAME = "x-user-email"
|
||||
ISSUE_ID_HEADER_NAME = "x-issue-id"
|
||||
)
|
||||
|
||||
var IgnorePatterns = []*regexp.Regexp{
|
||||
regexp.MustCompile(`\[mobx-state-tree\]`),
|
||||
regexp.MustCompile(`Object captured as exception with keys: code, message`),
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user