Skip to content

Commit

Permalink
uploader: reduce garbage logging
Browse files Browse the repository at this point in the history
  • Loading branch information
absorbb committed Feb 17, 2024
1 parent b937d72 commit bebfa13
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
12 changes: 8 additions & 4 deletions server/logfiles/uploader.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,15 @@ func (u *PeriodicUploader) Start() {
logging.SystemErrorf("Error processing file %s. Cant parse file date: %s", filePath, fileDate)
return
}

if timestamp.Now().Sub(fileDate) > time.Hour*24*time.Duration(u.reprocessDays) {
fileAge := timestamp.Now().Sub(fileDate)
if fileAge > time.Hour*24*time.Duration(u.reprocessDays) {
logging.Debugf("Skipping file %s. File is more than %d days old: %s", filePath, u.reprocessDays, fileDate)
return
}
logFunc := logging.Warnf
if fileAge > time.Hour*24 {
logFunc = logging.Debugf
}

//get token from filename
regexResult = logging.TokenIDExtractRegexp.FindStringSubmatch(fileName)
Expand All @@ -136,7 +140,7 @@ func (u *PeriodicUploader) Start() {
}
allStorageProxies := u.destinationService.GetBatchStorages(tokenID)
if len(allStorageProxies) == 0 {
logging.Warnf("Destination storages weren't found for file [%s] and token [%s]", filePath, tokenID)
logFunc("Destination storages weren't found for file [%s] and token [%s]", filePath, tokenID)
return
}
storageProxies := make([]storages.StorageProxy, 0, len(allStorageProxies))
Expand All @@ -147,7 +151,7 @@ func (u *PeriodicUploader) Start() {
}
}
if len(storageProxies) == 0 {
logging.Warnf("Alive destination storages weren't found for file [%s] and token [%s]", filePath, tokenID)
logFunc("Alive destination storages weren't found for file [%s] and token [%s]", filePath, tokenID)
return
}

Expand Down
16 changes: 8 additions & 8 deletions server/users/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ import (
const useIdentifiedCacheAfterMin = time.Minute * 1
const sysErrFreqSec = 10

//RecognitionService has a thread pool under the hood
//saves anonymous events in meta storage
//rewrites recognized events
// RecognitionService has a thread pool under the hood
// saves anonymous events in meta storage
// rewrites recognized events
type RecognitionService struct {
storage Storage
destinationService *destinations.Service
Expand All @@ -44,7 +44,7 @@ type RecognitionService struct {
configuration *storages.UserRecognitionConfiguration
}

//NewRecognitionService creates a new RecognitionService if metaStorage configuration exists
// NewRecognitionService creates a new RecognitionService if metaStorage configuration exists
func NewRecognitionService(storage Storage, destinationService *destinations.Service, configuration *config.UsersRecognition, userAgentPath string) (*RecognitionService, error) {
if !configuration.IsEnabled() {
logging.Info("❌ Users recognition is not enabled. Read how to enable them: https://jitsu.com/docs/other-features/retroactive-user-recognition")
Expand Down Expand Up @@ -244,7 +244,7 @@ func (rs *RecognitionService) startAggregatedIdentifiedObserver(queue *Queue) {
}
}

//Event consumes events.Event and put it to the recognition queue
// Event consumes events.Event and put it to the recognition queue
func (rs *RecognitionService) Event(event events.Event, eventID string, destinationIDs []string, tokenID string) {
if rs.closed.Load() {
return
Expand Down Expand Up @@ -283,7 +283,7 @@ func (rs *RecognitionService) extractPayload(event events.Event, eventID string,

storage, ok := storageProxy.Get()
if !ok {
logging.Errorf("Error recognizing user: Destination [%s] hasn't been initialized yet", destinationID)
logging.Debugf("Error recognizing user: Destination [%s] hasn't been initialized yet", destinationID)
continue
}

Expand Down Expand Up @@ -374,8 +374,8 @@ func (rs *RecognitionService) reprocessAnonymousEvents(eventsKey EventKey, ident
return nil
}

//Close sets closed flag = true (stop goroutines)
//closes the queue
// Close sets closed flag = true (stop goroutines)
// closes the queue
func (rs *RecognitionService) Close() (multiErr error) {
rs.closed.Store(true)

Expand Down

0 comments on commit bebfa13

Please sign in to comment.