def rule_notify( self, event: Any, futures: Sequence[Any], target_type: ActionTargetType, target_identifier: Optional[int] = None, ) -> None: metrics.incr("mail_adapter.rule_notify") rules = [] extra = { "event_id": event.event_id, "group_id": event.group_id, "is_from_mail_action_adapter": True, "target_type": target_type.value, "target_identifier": target_identifier, } 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 digests.enabled(project): def get_digest_option(key): return ProjectOption.objects.get_value( project, get_digest_option_key("mail", key)) digest_key = unsplit_key(event.group.project, target_type, target_identifier) 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, target_type, target_identifier) logger.info("mail.adapter.notification.%s" % log_event, extra=extra)
def rule_notify(self, event, futures): from sentry.models import ProjectOption # Django 1.9 setup issue 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): def get_digest_option(key): return 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): def get_digest_option(key): return 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.event_id, "group_id": event.group_id, "plugin": "mail" } 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 digests.enabled(project): def get_digest_option(key): return ProjectOption.objects.get_value( project, get_digest_option_key("mail", 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) logger.info("mail.notification.%s" % log_event, extra=extra)