• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python event_manager.EventManager类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中sentry.event_manager.EventManager的典型用法代码示例。如果您正苦于以下问题:Python EventManager类的具体用法?Python EventManager怎么用?Python EventManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: send

    def send(self, **kwargs):
        # TODO(dcramer): this should respect rate limits/etc and use the normal
        # pipeline
        from sentry.app import tsdb
        from sentry.coreapi import insert_data_to_database
        from sentry.event_manager import EventManager
        from sentry.models import Project

        try:
            project = Project.objects.get_from_cache(id=settings.SENTRY_PROJECT)
        except Project.DoesNotExist:
            self.error_logger.error('Internal project (id=%s) does not exist',
                                    settings.SENTRY_PROJECT)
            return

        metrics.incr('events.total', 1)

        kwargs['project'] = project.id
        try:
            manager = EventManager(kwargs)
            data = manager.normalize()
            tsdb.incr_multi([
                (tsdb.models.project_total_received, project.id),
                (tsdb.models.organization_total_received, project.organization_id),
            ])
            insert_data_to_database(data)
        except Exception as e:
            if self.raise_send_errors:
                raise
            self.error_logger.error(
                'Unable to record event: %s\nEvent was: %r', e,
                kwargs['message'], exc_info=True)
开发者ID:Crystalnix,项目名称:sentry,代码行数:32,代码来源:raven.py


示例2: process_event_from_kafka

def process_event_from_kafka(message):
    project = Project.objects.get_from_cache(pk=message['project_id'])

    remote_addr = message['remote_addr']
    helper = ClientApiHelper(
        agent=message['agent'],
        project_id=project.id,
        ip_address=remote_addr,
    )
    helper.context.bind_project(project)

    auth = Auth(message['auth'], message['auth'].pop('is_public'))
    helper.context.bind_auth(auth)

    key = helper.project_key_from_auth(auth)
    data = message['data']
    version = data['version']

    event_manager = EventManager(
        data,
        project=project,
        key=key,
        auth=auth,
        client_ip=remote_addr,
        user_agent=helper.context.agent,
        version=version,
    )
    event_manager._normalized = True
    del data

    return process_event(event_manager, project, key,
                         remote_addr, helper, attachments=None)
开发者ID:Kayle009,项目名称:sentry,代码行数:32,代码来源:event_consumer.py


示例3: test_unresolves_group_with_auto_resolve

    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
开发者ID:hosmelq,项目名称:sentry,代码行数:26,代码来源:test_event_manager.py


示例4: test_platform_is_saved

    def test_platform_is_saved(self):
        manager = EventManager(self.make_event(platform='python'))
        event = manager.save(1)

        group = event.group
        assert group.platform == 'python'
        assert event.platform == 'python'
开发者ID:botp,项目名称:sentry,代码行数:7,代码来源:test_event_manager.py


示例5: test_group_release_with_env

    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()
开发者ID:duanshuaimin,项目名称:sentry,代码行数:26,代码来源:test_event_manager.py


示例6: test_saves_event_mapping_when_sampled

    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()
开发者ID:hosmelq,项目名称:sentry,代码行数:35,代码来源:test_event_manager.py


示例7: test_long_message

 def test_long_message(self):
     manager = EventManager(self.make_event(
         message='x' * (settings.SENTRY_MAX_MESSAGE_LENGTH + 1),
     ))
     data = manager.normalize()
     assert len(data['sentry.interfaces.Message']['message']) == \
         settings.SENTRY_MAX_MESSAGE_LENGTH
开发者ID:duanshuaimin,项目名称:sentry,代码行数:7,代码来源:test_event_manager.py


示例8: test_updates_group_with_fingerprint

    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
开发者ID:yaoqi,项目名称:sentry,代码行数:29,代码来源:test_event_manager.py


示例9: test_user_report_gets_environment

    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
开发者ID:hosmelq,项目名称:sentry,代码行数:27,代码来源:test_event_manager.py


示例10: test_does_not_unresolve_group

    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()
开发者ID:AnjaneyuluBatta505,项目名称:sentry,代码行数:26,代码来源:test_event_manager.py


示例11: test_moves_stacktrace_to_exception

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
开发者ID:Kayle009,项目名称:sentry,代码行数:28,代码来源:test_normalization.py


示例12: test_updates_group

    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',
        }
开发者ID:hosmelq,项目名称:sentry,代码行数:29,代码来源:test_event_manager.py


示例13: test_updates_group_with_fingerprint

    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
开发者ID:hosmelq,项目名称:sentry,代码行数:26,代码来源:test_event_manager.py


示例14: test_ephemral_interfaces_removed_on_save

    def test_ephemral_interfaces_removed_on_save(self):
        manager = EventManager(self.make_event(platform='python'))
        event = manager.save(1)

        group = event.group
        assert group.platform == 'python'
        assert event.platform == 'python'
开发者ID:JackSparrovs,项目名称:sentry,代码行数:7,代码来源:test_event_manager.py


示例15: test_invalid_environment

 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
开发者ID:yaoqi,项目名称:sentry,代码行数:7,代码来源:test_event_manager.py


示例16: test_long_culprit

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
开发者ID:Kayle009,项目名称:sentry,代码行数:7,代码来源:test_normalization.py


示例17: test_unresolves_group_with_auto_resolve

    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)
开发者ID:yaoqi,项目名称:sentry,代码行数:28,代码来源:test_event_manager.py


示例18: test_unresolves_group

    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()
开发者ID:yaoqi,项目名称:sentry,代码行数:32,代码来源:test_event_manager.py


示例19: save_event

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'])
开发者ID:rlugojr,项目名称:sentry,代码行数:33,代码来源:store.py


示例20: test_long_transaction

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
开发者ID:Kayle009,项目名称:sentry,代码行数:7,代码来源:test_normalization.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python eventtypes.get函数代码示例发布时间:2022-05-27
下一篇:
Python event_manager.get_hashes_from_fingerprint函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap