Skip to content

feat(notification-center): Add LogEvent notification #204

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

Merged
merged 33 commits into from
Oct 4, 2019

Conversation

mnoman09
Copy link
Contributor

Summary

  • Adds LogEvent notification in NotificationCenter.
  • Integrated it in BatchEventDispatcher.

Test plan

  • Added unit tests.

@mnoman09 mnoman09 requested a review from a team as a code owner August 20, 2019 15:34
@coveralls
Copy link

coveralls commented Aug 21, 2019

Coverage Status

Coverage increased (+0.01%) to 97.689% when pulling 9ebf1a4 on mnoman/log_event_notification into 498db55 on mnoman/AddBatchEP.

@@ -219,6 +235,7 @@ def test_clear_all_notification_listeners(self):
test_notification_center.clear_all_notification_listeners()

for notification_type in notification_center.NOTIFICATION_TYPES:
print(notification_type)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove

@@ -23,7 +23,7 @@
from optimizely import logger as _logging
from optimizely.closeable import Closeable
from optimizely.event_dispatcher import EventDispatcher as default_event_dispatcher
from optimizely.helpers import validator
from optimizely.helpers import validator, enums
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit. I'd recommend splitting up imports into separate lines. Just a conventional thing.

@@ -60,7 +61,8 @@ def __init__(self,
event_queue=None,
batch_size=None,
flush_interval=None,
timeout_interval=None):
timeout_interval=None,
notification_center=None):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add some good explanations for all the fields here. Something like: https://github.com/optimizely/python-sdk/blob/master/optimizely/optimizely.py#L42-L59

Copy link
Contributor

@aliabbasrizvi aliabbasrizvi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need some better documentation.

@msohailhussain
Copy link
Contributor

this PR is getting failed on travis. Need to check.

@msohailhussain msohailhussain added the wip Work in progress label Sep 12, 2019
@oakbani oakbani removed the wip Work in progress label Sep 13, 2019
Args:
event_dispatcher: Provides a dispatch_event method which if given a URL and params sends a request to it.
logger: Provides a log method to log messages. By default nothing would be logged.
default_start: Optional boolean param which starts the consumer thread if set to True.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not entirely sure on this variable name. How about start_on_init?

batch_size: Optional param which defines the upper limit of the number of events in event_queue after which
the event_queue will be flushed.
flush_interval: Optional param which defines the time in milliseconds after which event_queue will be flushed.
timeout_interval: Optional param which defines the time in milliseconds before joining the consumer
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like for us to have any time intervals in seconds like we already have for datafile management.

# Conflicts:
#	optimizely/event/event_processor.py
…/python-sdk into mnoman/log_event_notification
@@ -195,6 +200,12 @@ def _flush_queue(self):

log_event = EventFactory.create_log_event(to_process_batch, self.logger)

if self.notification_center is not None:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we be validating that notification_center is an instance of notification_center.NotificationCenter or does that happen elsewhere?

@@ -371,3 +375,29 @@ def test_init__NaN_timeout_interval(self):
# default timeout interval is 5s.
self.assertEqual(self._event_processor.timeout_interval, timedelta(seconds=5))
mock_config_logging.info.assert_called_with('Using default value for timeout_interval.')

def test_notification_center(self):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit. test_notification_center__on_log_event

@aliabbasrizvi aliabbasrizvi merged commit 7d291fe into mnoman/AddBatchEP Oct 4, 2019
aliabbasrizvi added a commit that referenced this pull request Oct 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants