def rule_notify(self, event, futures): rules = [] for future in futures: rules.append(future.rule) if not future.kwargs: continue raise NotImplementedError('The default behavior for notification de-duplication does not support args') if self.__can_be_digested(event): digests.add( unsplit_key(self, event.group.project), # TODO: Improve this abstraction. event_to_record(event, rules), ) else: notification = Notification(event=event, rules=rules) self.notify(notification)
def rule_notify(self, event, futures): rules = [] for future in futures: rules.append(future.rule) if not future.kwargs: continue raise NotImplementedError('The default behavior for notification de-duplication does not support args') project = event.group.project if hasattr(self, 'notify_digest') and digests.enabled(project): get_digest_option = lambda key: ProjectOption.objects.get_value( project, get_digest_option_key(self.get_conf_key(), key), ) digest_key = unsplit_key(self, event.group.project) immediate_delivery = digests.add( digest_key, event_to_record(event, rules), increment_delay=get_digest_option('increment_delay'), maximum_delay=get_digest_option('maximum_delay'), ) if immediate_delivery: deliver_digest.delay(digest_key) else: notification = Notification( event=event, rules=rules, ) self.notify(notification)
def rule_notify(self, event, futures): rules = [] for future in futures: rules.append(future.rule) if not future.kwargs: continue raise NotImplementedError( 'The default behavior for notification de-duplication does not support args' ) project = event.group.project if hasattr(self, 'notify_digest') and digests.enabled(project): get_digest_option = lambda key: ProjectOption.objects.get_value( project, get_digest_option_key(self.get_conf_key(), key), ) digest_key = unsplit_key(self, event.group.project) immediate_delivery = digests.add( digest_key, event_to_record(event, rules), increment_delay=get_digest_option('increment_delay'), maximum_delay=get_digest_option('maximum_delay'), ) if immediate_delivery: deliver_digest.delay(digest_key) else: notification = Notification(event=event, rules=rules) self.notify(notification)
def rule_notify(self, event, futures): rules = [] for future in futures: rules.append(future.rule) if not future.kwargs: continue raise NotImplementedError('The default behavior for notification de-duplication does not support args') if hasattr(self, 'notify_digest'): project = event.group.project # If digest delivery is disabled, we still need to send a # notification -- we also need to check rate limits, since # ``should_notify`` skips this step if the plugin supports digests. if not features.has('projects:digests:deliver', project): if self.__is_rate_limited(event.group, event): logger = logging.getLogger('sentry.plugins.{0}'.format(self.get_conf_key())) logger.info('Notification for project %r dropped due to rate limiting', project) return notification = Notification(event=event, rules=rules) self.notify(notification) if features.has('projects:digests:store', project): key = unsplit_key(self, event.group.project) if digests.add(key, event_to_record(event, rules)): deliver_digest.delay(key) else: notification = Notification(event=event, rules=rules) self.notify(notification)
def rule_notify(self, event, futures): rules = [] for future in futures: rules.append(future.rule) if not future.kwargs: continue raise NotImplementedError( 'The default behavior for notification de-duplication does not support args' ) if self.__can_be_digested(event): digests.add( unsplit_key( self, event.group.project), # TODO: Improve this abstraction. event_to_record(event, rules), ) else: notification = Notification(event=event, rules=rules) self.notify(notification)
def rule_notify(self, event, futures): rules = [] for future in futures: rules.append(future.rule) if not future.kwargs: continue raise NotImplementedError('The default behavior for notification de-duplication does not support args') if self.__can_be_digested(event): key = unsplit_key(self, event.group.project) if digests.add(key, event_to_record(event, rules)): deliver_digest.delay(key) else: notification = Notification(event=event, rules=rules) self.notify(notification)
def rule_notify(self, event, futures): rules = [] for future in futures: rules.append(future.rule) if not future.kwargs: continue raise NotImplementedError( 'The default behavior for notification de-duplication does not support args' ) if self.__can_be_digested(event): key = unsplit_key(self, event.group.project) if digests.add(key, event_to_record(event, rules)): deliver_digest.delay(key) else: notification = Notification(event=event, rules=rules) self.notify(notification)
def rule_notify(self, event, futures): rules = [] for future in futures: rules.append(future.rule) if not future.kwargs: continue raise NotImplementedError( 'The default behavior for notification de-duplication does not support args' ) if hasattr(self, 'notify_digest'): project = event.group.project # If digest delivery is disabled, we still need to send a # notification -- we also need to check rate limits, since # ``should_notify`` skips this step if the plugin supports digests. if not features.has('projects:digests:deliver', project): if self.__is_rate_limited(event.group, event): logger = logging.getLogger('sentry.plugins.{0}'.format( self.get_conf_key())) logger.info( 'Notification for project %r dropped due to rate limiting', project) return notification = Notification(event=event, rules=rules) self.notify(notification) if features.has('projects:digests:store', project): get_digest_option = lambda key: ProjectOption.objects.get_value( project, '{0}:digests:{1}'.format(self.get_conf_key(), key), ) digest_key = unsplit_key(self, event.group.project) immediate_delivery = digests.add( digest_key, event_to_record(event, rules), increment_delay=get_digest_option('increment_delay'), maximum_delay=get_digest_option('maximum_delay'), ) if immediate_delivery: deliver_digest.delay(digest_key) else: notification = Notification(event=event, rules=rules) self.notify(notification)
def rule_notify(self, event, futures): rules = [] extra = { 'event_id': event.id, 'group_id': event.group_id, 'plugin': self.slug, } log_event = 'dispatched' for future in futures: rules.append(future.rule) extra['rule_id'] = future.rule.id if not future.kwargs: continue raise NotImplementedError( 'The default behavior for notification de-duplication does not support args' ) project = event.group.project extra['project_id'] = project.id if hasattr(self, 'notify_digest') and digests.enabled(project): get_digest_option = lambda key: ProjectOption.objects.get_value( project, get_digest_option_key(self.get_conf_key(), key), ) digest_key = unsplit_key(self, event.group.project) extra['digest_key'] = digest_key immediate_delivery = digests.add( digest_key, event_to_record(event, rules), increment_delay=get_digest_option('increment_delay'), maximum_delay=get_digest_option('maximum_delay'), ) if immediate_delivery: deliver_digest.delay(digest_key) else: log_event = 'digested' else: notification = Notification( event=event, rules=rules, ) self.notify(notification) self.logger.info('notification.%s' % log_event, extra=extra)
def rule_notify(self, event, futures): rules = [] extra = { 'event_id': event.id, 'group_id': event.group_id, 'plugin': self.slug, } log_event = 'dispatched' for future in futures: rules.append(future.rule) extra['rule_id'] = future.rule.id if not future.kwargs: continue raise NotImplementedError('The default behavior for notification de-duplication does not support args') project = event.group.project extra['project_id'] = project.id if hasattr(self, 'notify_digest') and digests.enabled(project): get_digest_option = lambda key: ProjectOption.objects.get_value( project, get_digest_option_key(self.get_conf_key(), key), ) digest_key = unsplit_key(self, event.group.project) extra['digest_key'] = digest_key immediate_delivery = digests.add( digest_key, event_to_record(event, rules), increment_delay=get_digest_option('increment_delay'), maximum_delay=get_digest_option('maximum_delay'), ) if immediate_delivery: deliver_digest.delay(digest_key) else: log_event = 'digested' else: notification = Notification( event=event, rules=rules, ) self.notify(notification) self.logger.info('notification.%s' % log_event, extra=extra)