本文整理汇总了Python中sentry.digests.notifications.event_to_record函数的典型用法代码示例。如果您正苦于以下问题:Python event_to_record函数的具体用法?Python event_to_record怎么用?Python event_to_record使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了event_to_record函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_notify_digest
def test_notify_digest(self, send, notify):
project = self.event.project
rule = project.rule_set.all()[0]
digest = build_digest(
project,
(
event_to_record(self.create_event(group=self.create_group()), (rule,)),
event_to_record(self.event, (rule,)),
),
)
self.plugin.notify_digest(project, digest)
assert send.call_count is 1
assert notify.call_count is 0
示例2: rule_notify
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)
示例3: rule_notify
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)
示例4: test_notify_digest
def test_notify_digest(self, has, send, notify):
has.side_effect = lambda label, *a, **k: {
'projects:digests:deliver': True,
}.get(label, False)
project = self.event.project
rule = project.rule_set.all()[0]
digest = build_digest(
project,
(
event_to_record(self.create_event(group=self.create_group()), (rule,)),
event_to_record(self.event, (rule,)),
),
)
self.plugin.notify_digest(project, digest)
assert send.call_count is 1
assert notify.call_count is 0
示例5: test_notify_digest_subject_prefix
def test_notify_digest_subject_prefix(self):
project = self.event.project
rule = project.rule_set.all()[0]
digest = build_digest(
project,
(
event_to_record(self.create_event(group=self.create_group()), (rule,)),
event_to_record(self.event, (rule,)),
),
)
self.plugin.notify_digest(project, digest)
assert len(mail.outbox) == 1
msg = mail.outbox[0]
assert msg.subject.startswith('[Example prefix] [foo Bar]')
示例6: test_notify_digest_single_record
def test_notify_digest_single_record(self, send_async, notify):
project = self.event.project
rule = project.rule_set.all()[0]
digest = build_digest(
project,
(event_to_record(self.event, (rule, )), ),
)
self.plugin.notify_digest(project, digest)
assert send_async.call_count is 1
assert notify.call_count is 1
示例7: test_notify_digest
def test_notify_digest(self, notify):
project = self.event.project
rule = project.rule_set.all()[0]
digest = build_digest(
project,
(
event_to_record(self.create_event(group=self.create_group()), (rule, )),
event_to_record(self.event, (rule, )),
),
)
with self.tasks():
self.plugin.notify_digest(project, digest)
assert notify.call_count is 0
assert len(mail.outbox) == 1
message = mail.outbox[0]
assert 'List-ID' in message.message()
示例8: test_simple
def test_simple(self):
rule = self.project.rule_set.all()[0]
records = [event_to_record(event, (rule, ))
for event in self.team1_events + self.team2_events + self.user4_events]
digest = build_digest(self.project, sort_records(records))
expected_result = {
self.user1.id: set(self.team1_events),
self.user2.id: set(self.team2_events),
self.user3.id: set(self.team1_events + self.team2_events),
self.user4.id: set(self.user4_events),
}
self.assert_get_personalized_digests(self.project, digest, self.user_ids, expected_result)
示例9: rule_notify
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)
示例10: test_everyone_with_owners
def test_everyone_with_owners(self):
rule = self.project.rule_set.all()[0]
events = self.create_events(
timezone.now(), self.project, [
'hello.moz', 'goodbye.moz', 'hola.moz', 'adios.moz'])
records = [event_to_record(event, (rule, )) for event in events + self.team1_events]
digest = build_digest(self.project, sort_records(records))
expected_result = {
self.user1.id: set(events + self.team1_events),
self.user2.id: set(events),
self.user3.id: set(events + self.team1_events),
self.user4.id: set(events),
self.user5.id: set(events),
}
self.assert_get_personalized_digests(self.project, digest, self.user_ids, expected_result)
示例11: rule_notify
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)
示例12: rule_notify
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)
示例13: test_get_event_from_groups_in_digest
def test_get_event_from_groups_in_digest(self):
project = self.create_project()
rule = project.rule_set.all()[0]
same_group = self.create_group(project=project)
events = [
self.create_event(group=same_group),
self.create_event(group=same_group),
self.create_event(group=self.create_group(project=project)),
self.create_event(group=self.create_group(project=project)),
self.create_event(group=self.create_group(project=project)),
self.create_event(group=self.create_group(project=project)),
]
digest = build_digest(
project,
sort_records([event_to_record(event, (rule, )) for event in events]),
)
events.pop(0) # remove event with same group
assert get_event_from_groups_in_digest(digest) == set(events)
示例14: test_team_without_members
def test_team_without_members(self):
team = self.create_team()
project = self.create_project(teams=[team])
ProjectOwnership.objects.create(
project_id=project.id,
schema=dump_schema([
Rule(Matcher('path', '*.cpp'), [
Owner('team', team.slug),
]),
]),
fallthrough=True,
)
rule = project.rule_set.all()[0]
records = [
event_to_record(event, (rule, )) for event in self.create_events(timezone.now(), project, [
'hello.py', 'goodbye.py', 'hola.py', 'adios.py'])
]
digest = build_digest(project, sort_records(records))
user_ids = [member.user_id for member in team.member_set]
assert not user_ids
for user_id, user_digest in get_personalized_digests(project.id, digest, user_ids):
assert False # no users in this team no digests should be processed
示例15: record
def record(self):
return event_to_record(self.event, (self.rule,))