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 should_notify(self, group, event): project = event.project if not self.is_configured(project=project): return False # If the plugin doesn't support digests or they are not enabled, # perform rate limit checks to support backwards compatibility with # older plugins. if not ( hasattr(self, "notify_digest") and digests.enabled(project) ) and self.__is_rate_limited(group, event): logger = logging.getLogger(f"sentry.plugins.{self.get_conf_key()}") logger.info("notification.rate_limited", extra={"project_id": project.id}) return False return True
def should_notify(self, group, event): project = event.project if not self.is_configured(project=project): return False if group.is_ignored(): return False # If the plugin doesn't support digests or they are not enabled, # perform rate limit checks to support backwards compatibility with # older plugins. if not (hasattr(self, 'notify_digest') and digests.enabled(project)) and self.__is_rate_limited(group, event): logger = logging.getLogger('sentry.plugins.{0}'.format(self.get_conf_key())) logger.info('notification.rate_limited', extra={'project_id': project.id}) return False return True
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)