本文整理汇总了Python中sentry.event_manager.EventManager.get_search_message方法的典型用法代码示例。如果您正苦于以下问题:Python EventManager.get_search_message方法的具体用法?Python EventManager.get_search_message怎么用?Python EventManager.get_search_message使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sentry.event_manager.EventManager
的用法示例。
在下文中一共展示了EventManager.get_search_message方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get
# 需要导入模块: from sentry.event_manager import EventManager [as 别名]
# 或者: from sentry.event_manager.EventManager import get_search_message [as 别名]
def get(self, request):
org = Organization(
id=1,
slug='organization',
name='My Company',
)
project = Project(
id=1,
organization=org,
slug='project',
name='My Project',
)
group = next(
make_group_generator(
get_random(request),
project,
),
)
data = dict(load_data('python'))
data['message'] = group.message
data.pop('logentry', None)
event_manager = EventManager(data)
event_manager.normalize()
data = event_manager.get_data()
event_type = event_manager.get_event_type()
group.message = event_manager.get_search_message()
group.data = {
'type': event_type.key,
'metadata': event_type.get_metadata(data),
}
event = Event(
id=1,
project=project,
message=event_manager.get_search_message(),
group=group,
datetime=datetime(2016, 6, 13, 3, 8, 24, tzinfo=timezone.utc),
data=event_manager.get_data()
)
activity = Activity(
group=event.group, project=event.project, **self.get_activity(request, event)
)
return render_to_response(
'sentry/debug/mail/preview.html', {
'preview': ActivityMailPreview(request, activity),
'format': request.GET.get('format'),
}
)
示例2: create_event
# 需要导入模块: from sentry.event_manager import EventManager [as 别名]
# 或者: from sentry.event_manager.EventManager import get_search_message [as 别名]
def create_event(group, event_id=None, normalize=True, **kwargs):
# XXX: Do not use this method for new tests! Prefer `store_event`.
if event_id is None:
event_id = uuid4().hex
kwargs.setdefault('project', group.project)
kwargs.setdefault('data', copy.deepcopy(DEFAULT_EVENT_DATA))
kwargs.setdefault('platform', kwargs['data'].get('platform', 'python'))
kwargs.setdefault('message', kwargs['data'].get('message', 'message'))
if kwargs.get('tags'):
tags = kwargs.pop('tags')
if isinstance(tags, dict):
tags = list(tags.items())
kwargs['data']['tags'] = tags
if kwargs.get('stacktrace'):
stacktrace = kwargs.pop('stacktrace')
kwargs['data']['stacktrace'] = stacktrace
user = kwargs.pop('user', None)
if user is not None:
kwargs['data']['user'] = user
kwargs['data'].setdefault(
'errors', [{
'type': EventError.INVALID_DATA,
'name': 'foobar',
}]
)
# maintain simple event Factories by supporting the legacy message
# parameter just like our API would
if 'logentry' not in kwargs['data']:
kwargs['data']['logentry'] = {
'message': kwargs['message'] or '<unlabeled event>',
}
if normalize:
manager = EventManager(CanonicalKeyDict(kwargs['data']))
manager.normalize()
kwargs['data'] = manager.get_data()
kwargs['data'].update(manager.materialize_metadata())
kwargs['message'] = manager.get_search_message()
# This is needed so that create_event saves the event in nodestore
# under the correct key. This is usually dont in EventManager.save()
kwargs['data'].setdefault(
'node_id',
Event.generate_node_id(kwargs['project'].id, event_id)
)
event = Event(event_id=event_id, group=group, **kwargs)
EventMapping.objects.create(
project_id=event.project.id,
event_id=event_id,
group=group,
)
# emulate EventManager refs
event.data.bind_ref(event)
event.save()
return event
示例3: create_event
# 需要导入模块: from sentry.event_manager import EventManager [as 别名]
# 或者: from sentry.event_manager.EventManager import get_search_message [as 别名]
def create_event(self, event_id=None, normalize=True, **kwargs):
if event_id is None:
event_id = uuid4().hex
if 'group' not in kwargs:
kwargs['group'] = self.group
kwargs.setdefault('project', kwargs['group'].project)
kwargs.setdefault('data', copy.deepcopy(DEFAULT_EVENT_DATA))
kwargs.setdefault('platform', kwargs['data'].get('platform', 'python'))
kwargs.setdefault('message', kwargs['data'].get('message', 'message'))
if kwargs.get('tags'):
tags = kwargs.pop('tags')
if isinstance(tags, dict):
tags = list(tags.items())
kwargs['data']['tags'] = tags
if kwargs.get('stacktrace'):
stacktrace = kwargs.pop('stacktrace')
kwargs['data']['stacktrace'] = stacktrace
user = kwargs.pop('user', None)
if user is not None:
kwargs['data']['user'] = user
kwargs['data'].setdefault(
'errors', [{
'type': EventError.INVALID_DATA,
'name': 'foobar',
}]
)
# maintain simple event fixtures by supporting the legacy message
# parameter just like our API would
if 'logentry' not in kwargs['data']:
kwargs['data']['logentry'] = {
'message': kwargs.get('message') or '<unlabeled event>',
}
if normalize:
manager = EventManager(CanonicalKeyDict(kwargs['data']),
for_store=False)
manager.normalize()
kwargs['data'] = manager.get_data()
kwargs['message'] = manager.get_search_message()
else:
assert 'message' not in kwargs, 'do not pass message this way'
event = Event(event_id=event_id, **kwargs)
EventMapping.objects.create(
project_id=event.project.id,
event_id=event_id,
group=event.group,
)
# emulate EventManager refs
event.data.bind_ref(event)
event.save()
return event
示例4: test_notify_users_does_email
# 需要导入模块: from sentry.event_manager import EventManager [as 别名]
# 或者: from sentry.event_manager.EventManager import get_search_message [as 别名]
def test_notify_users_does_email(self, _send_mail):
event_manager = EventManager({
'message': 'hello world',
'level': 'error',
})
event_manager.normalize()
event_data = event_manager.get_data()
event_type = event_manager.get_event_type()
group = Group(
id=2,
first_seen=timezone.now(),
last_seen=timezone.now(),
project=self.project,
message=event_manager.get_search_message(),
logger='root',
short_id=2,
data={
'type': event_type.key,
'metadata': event_type.get_metadata(),
}
)
event = Event(
group=group,
message=group.message,
project=self.project,
datetime=group.last_seen,
data=event_data
)
notification = Notification(event=event)
with self.options({'system.url-prefix': 'http://example.com'}):
self.plugin.notify(notification)
assert _send_mail.call_count is 1
args, kwargs = _send_mail.call_args
self.assertEquals(kwargs.get('project'), self.project)
self.assertEquals(kwargs.get('reference'), group)
assert kwargs.get('subject') == u'BAR-2 - hello world'
示例5: alert
# 需要导入模块: from sentry.event_manager import EventManager [as 别名]
# 或者: from sentry.event_manager.EventManager import get_search_message [as 别名]
def alert(request):
platform = request.GET.get('platform', 'python')
org = Organization(
id=1,
slug='example',
name='Example',
)
project = Project(
id=1,
slug='example',
name='Example',
organization=org,
)
random = get_random(request)
group = next(
make_group_generator(random, project),
)
data = dict(load_data(platform))
data['message'] = group.message
data.pop('logentry', None)
data['environment'] = 'prod'
data['tags'] = [
('logger', 'javascript'),
('environment', 'prod'),
('level', 'error'),
('device', 'Other')
]
event_manager = EventManager(data)
event_manager.normalize()
event_type = event_manager.get_event_type()
group.message = event_manager.get_search_message()
group.data = {
'type': event_type.key,
'metadata': event_type.get_metadata(),
}
event = Event(
id=1,
event_id='44f1419e73884cd2b45c79918f4b6dc4',
project=project,
group=group,
message=event_manager.get_search_message(),
data=event_manager.get_data(),
datetime=to_datetime(
random.randint(
to_timestamp(group.first_seen),
to_timestamp(group.last_seen),
),
),
)
rule = Rule(label="An example rule")
interface_list = []
for interface in six.itervalues(event.interfaces):
body = interface.to_email_html(event)
if not body:
continue
interface_list.append((interface.get_title(), mark_safe(body)))
return MailPreview(
html_template='sentry/emails/error.html',
text_template='sentry/emails/error.txt',
context={
'rule': rule,
'group': group,
'event': event,
'link': 'http://example.com/link',
'interfaces': interface_list,
'tags': event.get_tags(),
'project_label': project.slug,
'commits': [{
# TODO(dcramer): change to use serializer
"repository": {"status": "active", "name": "Example Repo", "url": "https://github.com/example/example", "dateCreated": "2018-02-28T23:39:22.402Z", "provider": {"id": "github", "name": "GitHub"}, "id": "1"},
"score": 2,
"subject": "feat: Do something to raven/base.py",
"message": "feat: Do something to raven/base.py\naptent vivamus vehicula tempus volutpat hac tortor",
"id": "1b17483ffc4a10609e7921ee21a8567bfe0ed006",
"shortId": "1b17483",
"author": {"username": "[email protected]", "isManaged": False, "lastActive": "2018-03-01T18:25:28.149Z", "id": "1", "isActive": True, "has2fa": False, "name": "[email protected]", "avatarUrl": "https://secure.gravatar.com/avatar/51567a4f786cd8a2c41c513b592de9f9?s=32&d=mm", "dateJoined": "2018-02-27T22:04:32.847Z", "emails": [{"is_verified": False, "id": "1", "email": "[email protected]"}], "avatar": {"avatarUuid": None, "avatarType": "letter_avatar"}, "lastLogin": "2018-02-27T22:04:32.847Z", "email": "[email protected]"}
}],
},
).render(request)