本文整理汇总了Python中sentry.event_manager.EventManager.save方法的典型用法代码示例。如果您正苦于以下问题:Python EventManager.save方法的具体用法?Python EventManager.save怎么用?Python EventManager.save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sentry.event_manager.EventManager
的用法示例。
在下文中一共展示了EventManager.save方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_group_release_with_env
# 需要导入模块: from sentry.event_manager import EventManager [as 别名]
# 或者: from sentry.event_manager.EventManager import save [as 别名]
def test_group_release_with_env(self):
manager = EventManager(self.make_event(
release='1.0', environment='prod',
event_id='a' * 32))
event = manager.save(1)
release = Release.objects.get(version='1.0', projects=event.project_id)
assert GroupRelease.objects.filter(
release_id=release.id,
group_id=event.group_id,
environment='prod',
).exists()
manager = EventManager(self.make_event(
release='1.0', environment='staging',
event_id='b' * 32))
event = manager.save(1)
release = Release.objects.get(version='1.0', projects=event.project_id)
assert GroupRelease.objects.filter(
release_id=release.id,
group_id=event.group_id,
environment='staging',
).exists()
示例2: test_user_report_gets_environment
# 需要导入模块: from sentry.event_manager import EventManager [as 别名]
# 或者: from sentry.event_manager.EventManager import save [as 别名]
def test_user_report_gets_environment(self):
project = self.create_project()
environment = Environment.objects.create(
project_id=project.id,
organization_id=project.organization_id,
name='production',
)
environment.add_project(project)
event_id = 'a' * 32
group = self.create_group(project=project)
UserReport.objects.create(
group=group,
project=project,
event_id=event_id,
name='foo',
email='[email protected]',
comments='It Broke!!!',
)
manager = EventManager(
self.make_event(
environment=environment.name,
event_id=event_id,
group=group))
manager.normalize()
manager.save(project.id)
assert UserReport.objects.get(event_id=event_id).environment == environment
示例3: test_unresolves_group_with_auto_resolve
# 需要导入模块: from sentry.event_manager import EventManager [as 别名]
# 或者: from sentry.event_manager.EventManager import save [as 别名]
def test_unresolves_group_with_auto_resolve(self, mock_is_resolved):
mock_is_resolved.return_value = False
manager = EventManager(
self.make_event(
event_id='a' * 32,
checksum='a' * 32,
timestamp=1403007314,
)
)
with self.tasks():
event = manager.save(1)
mock_is_resolved.return_value = True
manager = EventManager(
self.make_event(
event_id='b' * 32,
checksum='a' * 32,
timestamp=1403007414,
)
)
with self.tasks():
event2 = manager.save(1)
assert event.group_id == event2.group_id
group = Group.objects.get(id=event.group.id)
assert group.active_at == event2.datetime != event.datetime
示例4: test_saves_event_mapping_when_sampled
# 需要导入模块: from sentry.event_manager import EventManager [as 别名]
# 或者: from sentry.event_manager.EventManager import save [as 别名]
def test_saves_event_mapping_when_sampled(self, should_sample):
should_sample.return_value = True
event_id = 'a' * 32
manager = EventManager(self.make_event(event_id=event_id))
event = manager.save(1)
# This is a brand new event, so it is actually saved.
# In this case, we don't need an EventMapping, but we
# do need the Event.
assert not EventMapping.objects.filter(
group_id=event.group_id,
event_id=event_id,
).exists()
assert Event.objects.filter(
event_id=event_id,
).exists()
event_id = 'b' * 32
manager = EventManager(self.make_event(event_id=event_id))
event = manager.save(1)
# This second is a dupe, so should be sampled
# For a sample, we want to store the EventMapping,
# but don't need to store the Event
assert EventMapping.objects.filter(
group_id=event.group_id,
event_id=event_id,
).exists()
assert not Event.objects.filter(
event_id=event_id,
).exists()
示例5: test_updates_group
# 需要导入模块: from sentry.event_manager import EventManager [as 别名]
# 或者: from sentry.event_manager.EventManager import save [as 别名]
def test_updates_group(self):
manager = EventManager(
self.make_event(
message='foo',
event_id='a' * 32,
checksum='a' * 32,
)
)
event = manager.save(1)
manager = EventManager(
self.make_event(
message='foo bar',
event_id='b' * 32,
checksum='a' * 32,
)
)
with self.tasks():
event2 = manager.save(1)
group = Group.objects.get(id=event.group_id)
assert group.times_seen == 2
assert group.last_seen.replace(microsecond=0) == event.datetime.replace(microsecond=0)
assert group.message == event2.message
assert group.data.get('type') == 'default'
assert group.data.get('metadata') == {
'title': 'foo bar',
}
示例6: test_updates_group_with_fingerprint
# 需要导入模块: from sentry.event_manager import EventManager [as 别名]
# 或者: from sentry.event_manager.EventManager import save [as 别名]
def test_updates_group_with_fingerprint(self):
manager = EventManager(
self.make_event(
message='foo',
event_id='a' * 32,
fingerprint=['a' * 32],
)
)
with self.tasks():
event = manager.save(1)
manager = EventManager(
self.make_event(
message='foo bar',
event_id='b' * 32,
fingerprint=['a' * 32],
)
)
with self.tasks():
event2 = manager.save(1)
group = Group.objects.get(id=event.group_id)
assert group.times_seen == 2
assert group.last_seen.replace(microsecond=0) == event.datetime.replace(microsecond=0)
assert group.message == event2.message
示例7: test_unresolves_group_with_auto_resolve
# 需要导入模块: from sentry.event_manager import EventManager [as 别名]
# 或者: from sentry.event_manager.EventManager import save [as 别名]
def test_unresolves_group_with_auto_resolve(self, mock_is_resolved):
ts = time() - 100
mock_is_resolved.return_value = False
manager = EventManager(
make_event(
event_id='a' * 32,
checksum='a' * 32,
timestamp=ts,
)
)
with self.tasks():
event = manager.save(1)
mock_is_resolved.return_value = True
manager = EventManager(
make_event(
event_id='b' * 32,
checksum='a' * 32,
timestamp=ts + 100,
)
)
with self.tasks():
event2 = manager.save(1)
assert event.group_id == event2.group_id
group = Group.objects.get(id=event.group.id)
assert group.active_at.replace(second=0) == event2.datetime.replace(second=0)
assert group.active_at.replace(second=0) != event.datetime.replace(second=0)
示例8: test_event_user
# 需要导入模块: from sentry.event_manager import EventManager [as 别名]
# 或者: from sentry.event_manager.EventManager import save [as 别名]
def test_event_user(self):
manager = EventManager(self.make_event(**{
'sentry.interfaces.User': {
'id': '1',
}
}))
manager.normalize()
event = manager.save(self.project.id)
assert EventUser.objects.filter(
project=self.project,
ident='1',
).exists()
assert 'sentry:user' in dict(event.tags)
# ensure event user is mapped to tags in second attempt
manager = EventManager(self.make_event(**{
'sentry.interfaces.User': {
'id': '1',
}
}))
manager.normalize()
event = manager.save(self.project.id)
assert EventUser.objects.filter(
project=self.project,
ident='1',
).exists()
assert 'sentry:user' in dict(event.tags)
示例9: test_unresolves_group
# 需要导入模块: from sentry.event_manager import EventManager [as 别名]
# 或者: from sentry.event_manager.EventManager import save [as 别名]
def test_unresolves_group(self):
ts = time() - 300
# N.B. EventManager won't unresolve the group unless the event2 has a
# later timestamp than event1.
manager = EventManager(
make_event(
event_id='a' * 32,
checksum='a' * 32,
timestamp=ts,
)
)
with self.tasks():
event = manager.save(1)
group = Group.objects.get(id=event.group_id)
group.status = GroupStatus.RESOLVED
group.save()
assert group.is_resolved()
manager = EventManager(
make_event(
event_id='b' * 32,
checksum='a' * 32,
timestamp=ts + 50,
)
)
event2 = manager.save(1)
assert event.group_id == event2.group_id
group = Group.objects.get(id=group.id)
assert not group.is_resolved()
示例10: test_updates_group_with_fingerprint
# 需要导入模块: from sentry.event_manager import EventManager [as 别名]
# 或者: from sentry.event_manager.EventManager import save [as 别名]
def test_updates_group_with_fingerprint(self):
ts = time() - 200
manager = EventManager(
make_event(
message='foo',
event_id='a' * 32,
fingerprint=['a' * 32],
timestamp=ts,
)
)
with self.tasks():
event = manager.save(1)
manager = EventManager(
make_event(
message='foo bar',
event_id='b' * 32,
fingerprint=['a' * 32],
timestamp=ts,
)
)
with self.tasks():
event2 = manager.save(1)
group = Group.objects.get(id=event.group_id)
assert group.times_seen == 2
assert group.last_seen == event.datetime
assert group.message == event2.message
示例11: test_updates_group
# 需要导入模块: from sentry.event_manager import EventManager [as 别名]
# 或者: from sentry.event_manager.EventManager import save [as 别名]
def test_updates_group(self):
timestamp = time() - 300
manager = EventManager(
make_event(
message='foo',
event_id='a' * 32,
checksum='a' * 32,
timestamp=timestamp,
)
)
manager.normalize()
event = manager.save(1)
manager = EventManager(
make_event(
message='foo bar',
event_id='b' * 32,
checksum='a' * 32,
timestamp=timestamp + 2.0,
)
)
manager.normalize()
with self.tasks():
event2 = manager.save(1)
group = Group.objects.get(id=event.group_id)
assert group.times_seen == 2
assert group.last_seen == event2.datetime
assert group.message == event2.message
assert group.data.get('type') == 'default'
assert group.data.get('metadata') == {
'title': 'foo bar',
}
示例12: save_event
# 需要导入模块: from sentry.event_manager import EventManager [as 别名]
# 或者: from sentry.event_manager.EventManager import save [as 别名]
def save_event(cache_key=None, data=None, start_time=None, event_id=None, **kwargs):
"""
Saves an event to the database.
"""
from sentry.event_manager import EventManager
if cache_key:
data = default_cache.get(cache_key)
if event_id is None and data is not None:
event_id = data['event_id']
if data is None:
metrics.incr('events.failed', tags={'reason': 'cache', 'stage': 'post'})
return
project = data.pop('project')
delete_raw_event(project, event_id)
Raven.tags_context({
'project': project,
})
try:
manager = EventManager(data)
manager.save(project)
finally:
if cache_key:
default_cache.delete(cache_key)
if start_time:
metrics.timing('events.time-to-process', time() - start_time,
instance=data['platform'])
示例13: test_does_not_unresolve_group
# 需要导入模块: from sentry.event_manager import EventManager [as 别名]
# 或者: from sentry.event_manager.EventManager import save [as 别名]
def test_does_not_unresolve_group(self, plugin_is_regression):
# N.B. EventManager won't unresolve the group unless the event2 has a
# later timestamp than event1. MySQL doesn't support microseconds.
plugin_is_regression.return_value = False
manager = EventManager(self.make_event(
event_id='a' * 32, checksum='a' * 32,
timestamp=1403007314,
))
with self.tasks():
event = manager.save(1)
group = Group.objects.get(id=event.group_id)
group.status = GroupStatus.RESOLVED
group.save()
assert group.is_resolved()
manager = EventManager(self.make_event(
event_id='b' * 32, checksum='a' * 32,
timestamp=1403007315,
))
event2 = manager.save(1)
assert event.group_id == event2.group_id
group = Group.objects.get(id=group.id)
assert group.is_resolved()
示例14: test_event_user_unicode_identifier
# 需要导入模块: from sentry.event_manager import EventManager [as 别名]
# 或者: from sentry.event_manager.EventManager import save [as 别名]
def test_event_user_unicode_identifier(self):
manager = EventManager(self.make_event(**{'sentry.interfaces.User': {'username': u'foô'}}))
manager.normalize()
with self.tasks():
manager.save(self.project.id)
euser = EventUser.objects.get(
project_id=self.project.id,
)
assert euser.username == u'foô'
示例15: test_similar_message_prefix_doesnt_group
# 需要导入模块: from sentry.event_manager import EventManager [as 别名]
# 或者: from sentry.event_manager.EventManager import save [as 别名]
def test_similar_message_prefix_doesnt_group(self):
# we had a regression which caused the default hash to just be
# 'event.message' instead of '[event.message]' which caused it to
# generate a hash per letter
manager = EventManager(self.make_event(message='foo bar'))
event1 = manager.save(1)
manager = EventManager(self.make_event(message='foo baz'))
event2 = manager.save(1)
assert event1.group_id != event2.group_id