本文整理汇总了Python中sentry.event_manager.EventManager.get_data方法的典型用法代码示例。如果您正苦于以下问题:Python EventManager.get_data方法的具体用法?Python EventManager.get_data怎么用?Python EventManager.get_data使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sentry.event_manager.EventManager
的用法示例。
在下文中一共展示了EventManager.get_data方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_returns_cannonical_dict
# 需要导入模块: from sentry.event_manager import EventManager [as 别名]
# 或者: from sentry.event_manager.EventManager import get_data [as 别名]
def test_returns_cannonical_dict():
from sentry.utils.canonical import CanonicalKeyDict
event = make_event()
manager = EventManager(event)
assert isinstance(manager.get_data(), CanonicalKeyDict)
manager.normalize()
assert isinstance(manager.get_data(), CanonicalKeyDict)
示例2: test_invalid_tags
# 需要导入模块: from sentry.event_manager import EventManager [as 别名]
# 或者: from sentry.event_manager.EventManager import get_data [as 别名]
def test_invalid_tags(self):
manager = EventManager(make_event(**{
'tags': [42],
}))
manager.normalize()
assert None in manager.get_data().get('tags', [])
assert 42 not in manager.get_data().get('tags', [])
event = manager.save(self.project.id)
assert 42 not in event.tags
assert None not in event.tags
示例3: test_logger
# 需要导入模块: from sentry.event_manager import EventManager [as 别名]
# 或者: from sentry.event_manager.EventManager import get_data [as 别名]
def test_logger():
manager = EventManager(make_event(logger="foo\nbar"))
manager.normalize()
data = manager.get_data()
assert data['logger'] == DEFAULT_LOGGER_NAME
manager = EventManager(make_event(logger=""))
manager.normalize()
data = manager.get_data()
assert data['logger'] == DEFAULT_LOGGER_NAME
示例4: test_logger
# 需要导入模块: from sentry.event_manager import EventManager [as 别名]
# 或者: from sentry.event_manager.EventManager import get_data [as 别名]
def test_logger():
manager = EventManager(make_event(logger="foo\nbar"))
manager.normalize()
data = manager.get_data()
assert data['logger'] == DEFAULT_LOGGER_NAME
manager = EventManager(make_event(logger=""))
manager.normalize()
data = manager.get_data()
assert data['logger'] == DEFAULT_LOGGER_NAME
assert not any(e.get('name') == 'logger' for e in data['errors'])
示例5: get
# 需要导入模块: from sentry.event_manager import EventManager [as 别名]
# 或者: from sentry.event_manager.EventManager import get_data [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'),
}
)
示例6: test_event_id_lowercase
# 需要导入模块: from sentry.event_manager import EventManager [as 别名]
# 或者: from sentry.event_manager.EventManager import get_data [as 别名]
def test_event_id_lowercase():
manager = EventManager(make_event(event_id='1234ABCD' * 4))
manager.normalize()
data = manager.get_data()
assert data['event_id'] == '1234abcd' * 4
manager = EventManager(make_event(event_id=u'1234ABCD' * 4))
manager.normalize()
data = manager.get_data()
assert data['event_id'] == '1234abcd' * 4
示例7: test_long_culprit
# 需要导入模块: from sentry.event_manager import EventManager [as 别名]
# 或者: from sentry.event_manager.EventManager import get_data [as 别名]
def test_long_culprit():
manager = EventManager(make_event(
culprit='x' * (MAX_CULPRIT_LENGTH + 1),
))
manager.normalize()
data = manager.get_data()
assert len(data['culprit']) == MAX_CULPRIT_LENGTH
示例8: test_long_transaction
# 需要导入模块: from sentry.event_manager import EventManager [as 别名]
# 或者: from sentry.event_manager.EventManager import get_data [as 别名]
def test_long_transaction():
manager = EventManager(make_event(
transaction='x' * (MAX_CULPRIT_LENGTH + 1),
))
manager.normalize()
data = manager.get_data()
assert len(data['transaction']) == MAX_CULPRIT_LENGTH
示例9: test_moves_stacktrace_to_exception
# 需要导入模块: from sentry.event_manager import EventManager [as 别名]
# 或者: from sentry.event_manager.EventManager import get_data [as 别名]
def test_moves_stacktrace_to_exception():
manager = EventManager(
make_event(
exception={
'type': 'MyException',
},
stacktrace={
'frames': [
{
'lineno': 1,
'filename': 'foo.py',
}, {
'lineno': 1,
'filename': 'bar.py',
}
]
}
)
)
manager.normalize()
data = manager.get_data()
frames = data['exception']['values'][0]['stacktrace']['frames']
assert frames[0]['lineno'] == 1
assert frames[0]['filename'] == 'foo.py'
assert frames[1]['lineno'] == 1
assert frames[1]['filename'] == 'bar.py'
assert 'stacktrace' not in data
示例10: create_event
# 需要导入模块: from sentry.event_manager import EventManager [as 别名]
# 或者: from sentry.event_manager.EventManager import get_data [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
示例11: inner
# 需要导入模块: from sentry.event_manager import EventManager [as 别名]
# 或者: from sentry.event_manager.EventManager import get_data [as 别名]
def inner(data):
mgr = EventManager(data={"sdk": data})
mgr.normalize()
evt = Event(data=mgr.get_data())
insta_snapshot({
'errors': evt.data.get('errors'),
'to_json': evt.interfaces.get('sdk').to_json()
})
示例12: test_removes_some_empty_containers
# 需要导入模块: from sentry.event_manager import EventManager [as 别名]
# 或者: from sentry.event_manager.EventManager import get_data [as 别名]
def test_removes_some_empty_containers(key, value):
event = make_event()
event[key] = value
manager = EventManager(event)
manager.normalize()
data = manager.get_data()
assert key not in data
示例13: inner
# 需要导入模块: from sentry.event_manager import EventManager [as 别名]
# 或者: from sentry.event_manager.EventManager import get_data [as 别名]
def inner(data):
mgr = EventManager(data={"debug_meta": data})
mgr.normalize()
evt = Event(data=mgr.get_data())
interface = evt.interfaces.get('debug_meta')
insta_snapshot({
'errors': evt.data.get('errors'),
'to_json': interface and interface.to_json()
})
示例14: create_event
# 需要导入模块: from sentry.event_manager import EventManager [as 别名]
# 或者: from sentry.event_manager.EventManager import get_data [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
示例15: test_deprecated_attrs
# 需要导入模块: from sentry.event_manager import EventManager [as 别名]
# 或者: from sentry.event_manager.EventManager import get_data [as 别名]
def test_deprecated_attrs(key):
event = make_event()
event[key] = "some value"
manager = EventManager(event)
manager.normalize()
data = manager.get_data()
assert key not in data
assert not data.get('errors')