当前位置: 首页>>代码示例>>Python>>正文


Python Event.generate_node_id方法代码示例

本文整理汇总了Python中sentry.models.Event.generate_node_id方法的典型用法代码示例。如果您正苦于以下问题:Python Event.generate_node_id方法的具体用法?Python Event.generate_node_id怎么用?Python Event.generate_node_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sentry.models.Event的用法示例。


在下文中一共展示了Event.generate_node_id方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: create_event

# 需要导入模块: from sentry.models import Event [as 别名]
# 或者: from sentry.models.Event import generate_node_id [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
开发者ID:yaoqi,项目名称:sentry,代码行数:61,代码来源:factories.py

示例2: _get_event_instance

# 需要导入模块: from sentry.models import Event [as 别名]
# 或者: from sentry.models.Event import generate_node_id [as 别名]
    def _get_event_instance(self, project_id=None):
        data = self._data
        event_id = data.get('event_id')
        platform = data.get('platform')

        recorded_timestamp = data.get('timestamp')
        date = datetime.fromtimestamp(recorded_timestamp)
        date = date.replace(tzinfo=timezone.utc)
        time_spent = data.get('time_spent')

        data['node_id'] = Event.generate_node_id(project_id, event_id)

        return Event(
            project_id=project_id or self._project.id,
            event_id=event_id,
            data=EventDict(data, skip_renormalization=True),
            time_spent=time_spent,
            datetime=date,
            platform=platform
        )
开发者ID:yaoqi,项目名称:sentry,代码行数:22,代码来源:event_manager.py


注:本文中的sentry.models.Event.generate_node_id方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。