-
Notifications
You must be signed in to change notification settings - Fork 6
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
Use microseconds in addition to PID. Use the sorted file list. #4
base: master
Are you sure you want to change the base?
Conversation
Needs some testing.
… in the right order
|
||
sorted_file_names = sorted(pd_file_names, key=file_timestamp) | ||
return pd_file_names | ||
sorted_file_names = sorted(pd_file_names, key=file_timestamp, reverse=True) |
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.
Oops - have we been sorting this wrong?! Can you show some example file names & sort results here from a python console run?
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.
When I was testing without reverse it seemed to always send them in the wrong order. I'll do some more concrete tests via the Python console.
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.
If you enqueue a few things & then either run this code by hand or run it with print/log statements, we should be able to see how the sorting goes. :)
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.
Q: were the tests for seconds version of the code + sends in the same second?
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.
I think due to the queued files and because I wasn't using the cronjob to flush the queue, I ended up sending the files wrong in the wrong order by name but they looked right when viewing the trigger/resolve API calls. I'll fix the ordering and make the few other changes.
Using time.time()'s already available microseconds
Updated with the suggestions from before. It looks like we weren't using the correct variable after sorting the file list. |
@@ -142,7 +142,7 @@ def file_timestamp(file_name): | |||
return int(re.search('pd_(\d+)_', file_name).group(1)) | |||
|
|||
sorted_file_names = sorted(pd_file_names, key=file_timestamp) | |||
return pd_file_names | |||
return sorted_file_names |
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.
:P
Looks good! |
(title of the PR a bit misleading now, but meh :) |
Fixed! |
Also, we try really hard to send the events in the right order. The latest code worked 6 out of 6 tries with 1/10th of a second between calls to pagerduty.py, which were run in the background.