-
Notifications
You must be signed in to change notification settings - Fork 764
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Gracefully shutdown analytics module/runner #3335
Changes from all commits
a5f43ce
4452580
e558c26
9651ffc
179ff41
d3374fb
0c135fb
33a4a16
1c75891
ed06458
f9e25ff
55b6592
74833f5
47d39df
e1083fe
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -129,6 +129,13 @@ func (ea enabledAnalytics) LogNotificationEventObject(ne *analytics.Notification | |
} | ||
} | ||
|
||
// Shutdown - correctly shutdown all analytics modules and wait for them to finish | ||
func (ea enabledAnalytics) Shutdown() { | ||
for _, module := range ea { | ||
module.Shutdown() | ||
} | ||
} | ||
Comment on lines
+133
to
+137
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This code block isn't covered by tests, can you update this? |
||
|
||
func evaluateActivities(rw *openrtb_ext.RequestWrapper, ac privacy.ActivityControl, componentName string) (bool, *openrtb_ext.RequestWrapper) { | ||
// returned nil request wrapper means that request wrapper was not modified by activities and doesn't have to be changed in analytics object | ||
// it is needed in order to use one function for all analytics objects with RequestWrapper | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,8 @@ import ( | |
"bytes" | ||
"fmt" | ||
|
||
"github.com/chasex/glog" | ||
cglog "github.com/chasex/glog" | ||
"github.com/golang/glog" | ||
"github.com/prebid/openrtb/v20/openrtb2" | ||
"github.com/prebid/prebid-server/v2/analytics" | ||
"github.com/prebid/prebid-server/v2/util/jsonutil" | ||
|
@@ -21,9 +22,14 @@ const ( | |
NOTIFICATION_EVENT RequestType = "/event" | ||
) | ||
|
||
type Logger interface { | ||
Debug(v ...interface{}) | ||
Flush() | ||
} | ||
|
||
// Module that can perform transactional logging | ||
type FileLogger struct { | ||
Logger *glog.Logger | ||
Logger Logger | ||
} | ||
|
||
// Writes AuctionObject to file | ||
|
@@ -85,15 +91,22 @@ func (f *FileLogger) LogNotificationEventObject(ne *analytics.NotificationEvent) | |
f.Logger.Flush() | ||
} | ||
|
||
// Shutdown the logger | ||
func (f *FileLogger) Shutdown() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you add test to cover these line? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @AlexBVolcy updated unit test for it |
||
// clear all pending buffered data in case there is any | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just to follow the same pattern of the agma module, should we
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. there is no additional args to template the log message, so |
||
glog.Info("[FileLogger] Shutdown, trying to flush buffer") | ||
f.Logger.Flush() | ||
} | ||
|
||
// Method to initialize the analytic module | ||
func NewFileLogger(filename string) (analytics.Module, error) { | ||
options := glog.LogOptions{ | ||
options := cglog.LogOptions{ | ||
File: filename, | ||
Flag: glog.LstdFlags, | ||
Level: glog.Ldebug, | ||
Mode: glog.R_Day, | ||
Flag: cglog.LstdFlags, | ||
Level: cglog.Ldebug, | ||
Mode: cglog.R_Day, | ||
} | ||
if logger, err := glog.New(options); err == nil { | ||
if logger, err := cglog.New(options); err == nil { | ||
return &FileLogger{ | ||
logger, | ||
}, nil | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to add tests to cover these lines
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@AlexBVolcy updated the unit test for it