本文整理汇总了Python中sentry.event_manager.EventManager.normalize方法的典型用法代码示例。如果您正苦于以下问题:Python EventManager.normalize方法的具体用法?Python EventManager.normalize怎么用?Python EventManager.normalize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sentry.event_manager.EventManager
的用法示例。
在下文中一共展示了EventManager.normalize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_long_transaction
# 需要导入模块: from sentry.event_manager import EventManager [as 别名]
# 或者: from sentry.event_manager.EventManager import normalize [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
示例2: test_invalid_environment
# 需要导入模块: from sentry.event_manager import EventManager [as 别名]
# 或者: from sentry.event_manager.EventManager import normalize [as 别名]
def test_invalid_environment(self):
manager = EventManager(make_event(**{
'environment': 'bad/name',
}))
manager.normalize()
event = manager.save(self.project.id)
assert dict(event.tags).get('environment') is None
示例3: test_updates_group
# 需要导入模块: from sentry.event_manager import EventManager [as 别名]
# 或者: from sentry.event_manager.EventManager import normalize [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',
}
示例4: test_does_not_unresolve_group
# 需要导入模块: from sentry.event_manager import EventManager [as 别名]
# 或者: from sentry.event_manager.EventManager import normalize [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.
plugin_is_regression.return_value = False
manager = EventManager(
make_event(
event_id='a' * 32,
checksum='a' * 32,
timestamp=1403007314,
)
)
with self.tasks():
manager.normalize()
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=1403007315,
)
)
manager.normalize()
event2 = manager.save(1)
assert event.group_id == event2.group_id
group = Group.objects.get(id=group.id)
assert group.is_resolved()
示例5: test_long_culprit
# 需要导入模块: from sentry.event_manager import EventManager [as 别名]
# 或者: from sentry.event_manager.EventManager import normalize [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
示例6: test_moves_stacktrace_to_exception
# 需要导入模块: from sentry.event_manager import EventManager [as 别名]
# 或者: from sentry.event_manager.EventManager import normalize [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
示例7: test_event_user
# 需要导入模块: from sentry.event_manager import EventManager [as 别名]
# 或者: from sentry.event_manager.EventManager import normalize [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)
示例8: test_group_release_with_env
# 需要导入模块: from sentry.event_manager import EventManager [as 别名]
# 或者: from sentry.event_manager.EventManager import normalize [as 别名]
def test_group_release_with_env(self):
manager = EventManager(
make_event(release='1.0', environment='prod', event_id='a' * 32)
)
manager.normalize()
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(
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()
示例9: test_user_report_gets_environment
# 需要导入模块: from sentry.event_manager import EventManager [as 别名]
# 或者: from sentry.event_manager.EventManager import normalize [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
示例10: create_event
# 需要导入模块: from sentry.event_manager import EventManager [as 别名]
# 或者: from sentry.event_manager.EventManager import normalize [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: test
# 需要导入模块: from sentry.event_manager import EventManager [as 别名]
# 或者: from sentry.event_manager.EventManager import normalize [as 别名]
def test(self, mock_delay_index_event_tags, mock_eventstream_insert):
now = datetime.utcnow()
def _get_event_count():
return snuba.query(
start=now - timedelta(days=1),
end=now + timedelta(days=1),
groupby=['project_id'],
filter_keys={'project_id': [self.project.id]},
).get(self.project.id, 0)
assert _get_event_count() == 0
raw_event = {
'event_id': 'a' * 32,
'message': 'foo',
'timestamp': time.mktime(now.timetuple()),
'level': logging.ERROR,
'logger': 'default',
'tags': [],
}
manager = EventManager(raw_event)
manager.normalize()
event = manager.save(self.project.id)
# verify eventstream was called by EventManager
insert_args, insert_kwargs = list(mock_eventstream_insert.call_args)
assert not insert_args
assert insert_kwargs == {
'event': event,
'group': event.group,
'is_new_group_environment': True,
'is_new': True,
'is_regression': False,
'is_sample': False,
'primary_hash': 'acbd18db4cc2f85cedef654fccc4a4d8',
'skip_consume': False
}
assert mock_delay_index_event_tags.call_count == 1
# pass arguments on to Kafka EventManager
self.kafka_eventstream.insert(*insert_args, **insert_kwargs)
produce_args, produce_kwargs = list(self.kafka_eventstream.producer.produce.call_args)
assert not produce_args
assert produce_kwargs['topic'] == 'events'
assert produce_kwargs['key'] == six.text_type(self.project.id)
version, type_, payload1, payload2 = json.loads(produce_kwargs['value'])
assert version == 2
assert type_ == 'insert'
# insert what would have been the Kafka payload directly
# into Snuba, expect an HTTP 200 and for the event to now exist
snuba_eventstream = SnubaEventStream()
snuba_eventstream._send(self.project.id, 'insert', (payload1, payload2))
assert _get_event_count() == 1
示例12: test_culprit_is_not_transaction
# 需要导入模块: from sentry.event_manager import EventManager [as 别名]
# 或者: from sentry.event_manager.EventManager import normalize [as 别名]
def test_culprit_is_not_transaction(self):
manager = EventManager(make_event(
culprit='foobar',
))
manager.normalize()
event1 = manager.save(1)
assert event1.transaction is None
assert event1.culprit == 'foobar'
示例13: inner
# 需要导入模块: from sentry.event_manager import EventManager [as 别名]
# 或者: from sentry.event_manager.EventManager import normalize [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()
})
示例14: test_invalid_transaction
# 需要导入模块: from sentry.event_manager import EventManager [as 别名]
# 或者: from sentry.event_manager.EventManager import normalize [as 别名]
def test_invalid_transaction(self):
dict_input = {'messages': 'foo'}
manager = EventManager(self.make_event(
transaction=dict_input,
))
manager.normalize()
event = manager.save(1)
assert event.transaction is None
示例15: test_transaction_as_culprit
# 需要导入模块: from sentry.event_manager import EventManager [as 别名]
# 或者: from sentry.event_manager.EventManager import normalize [as 别名]
def test_transaction_as_culprit(self):
manager = EventManager(make_event(
transaction='foobar',
))
manager.normalize()
event = manager.save(1)
assert event.transaction == 'foobar'
assert event.culprit == 'foobar'