コード例 #1
0
ファイル: test_unreal.py プロジェクト: rajib2k5/sentry
 def test_merge_unreal_logs_event(self):
     with open(get_unreal_crash_file(), 'rb') as f:
         event = {}
         unreal_crash = process_unreal_crash(f.read(), None, None, event)
         merge_unreal_logs_event(unreal_crash.get_logs(), event)
         breadcrumbs = event['breadcrumbs']['values']
         assert len(breadcrumbs) == 100
         assert breadcrumbs[0]['timestamp'] == '2018-11-20T11:47:14Z'
         assert breadcrumbs[0]['message'] == '   4. \'Parallels Display Adapter (WDDM)\' (P:0 D:0)'
         assert breadcrumbs[0]['category'] == 'LogWindows'
         assert breadcrumbs[99]['timestamp'] == '2018-11-20T11:47:15Z'
         assert breadcrumbs[99]['message'] == 'Texture pool size now 1000 MB'
         assert breadcrumbs[99]['category'] == 'LogContentStreaming'
コード例 #2
0
ファイル: test_unreal.py プロジェクト: zhangdinet/sentry
 def test_merge_unreal_logs_event(self):
     with open(get_unreal_crash_file(), "rb") as f:
         event = {"event_id": MOCK_EVENT_ID, "environment": None}
         unreal_crash = Unreal4Crash.from_bytes(f.read())
         merge_unreal_logs_event(unreal_crash.get_logs(), event)
         breadcrumbs = event["breadcrumbs"]["values"]
         assert len(breadcrumbs) == 100
         assert breadcrumbs[0]["timestamp"] == "2018-11-20T11:47:14Z"
         assert breadcrumbs[0]["message"] == "   4. 'Parallels Display Adapter (WDDM)' (P:0 D:0)"
         assert breadcrumbs[0]["category"] == "LogWindows"
         assert breadcrumbs[99]["timestamp"] == "2018-11-20T11:47:15Z"
         assert breadcrumbs[99]["message"] == "Texture pool size now 1000 MB"
         assert breadcrumbs[99]["category"] == "LogContentStreaming"
コード例 #3
0
ファイル: test_unreal.py プロジェクト: yaoqi/sentry
 def test_merge_unreal_logs_event(self):
     with open(get_unreal_crash_file(), 'rb') as f:
         event = {'event_id': MOCK_EVENT_ID}
         unreal_crash = process_unreal_crash(f.read(), None, None, event)
         merge_unreal_logs_event(unreal_crash.get_logs(), event)
         breadcrumbs = event['breadcrumbs']['values']
         assert len(breadcrumbs) == 100
         assert breadcrumbs[0]['timestamp'] == '2018-11-20T11:47:14Z'
         assert breadcrumbs[0]['message'] == '   4. \'Parallels Display Adapter (WDDM)\' (P:0 D:0)'
         assert breadcrumbs[0]['category'] == 'LogWindows'
         assert breadcrumbs[99]['timestamp'] == '2018-11-20T11:47:15Z'
         assert breadcrumbs[99]['message'] == 'Texture pool size now 1000 MB'
         assert breadcrumbs[99]['category'] == 'LogContentStreaming'
コード例 #4
0
ファイル: api.py プロジェクト: zhangdinet/sentry
    def post(self, request, project, project_config, **kwargs):
        attachments_enabled = features.has(
            "organizations:event-attachments", project.organization, actor=request.user
        )

        attachments = []
        event = {"event_id": uuid.uuid4().hex, "environment": request.GET.get("AppEnvironment")}

        user_id = request.GET.get("UserID")
        if user_id:
            merge_unreal_user(event, user_id)

        try:
            unreal = Unreal4Crash.from_bytes(request.body)
        except (ProcessMinidumpError, Unreal4Error) as e:
            minidumps_logger.exception(e)
            track_outcome(
                project_config.organization_id,
                project_config.project_id,
                None,
                Outcome.INVALID,
                "process_unreal",
            )
            raise APIError(e.message.split("\n", 1)[0])

        try:
            unreal_context = unreal.get_context()
        except Unreal4Error as e:
            # we'll continue without the context data
            unreal_context = None
            minidumps_logger.exception(e)
        else:
            if unreal_context is not None:
                merge_unreal_context_event(unreal_context, event, project)

        try:
            unreal_logs = unreal.get_logs()
        except Unreal4Error as e:
            # we'll continue without the breadcrumbs
            minidumps_logger.exception(e)
        else:
            if unreal_logs is not None:
                merge_unreal_logs_event(unreal_logs, event)

        is_minidump = False
        is_applecrashreport = False

        for file in unreal.files():
            # Known attachment: msgpack event
            if file.name == "__sentry-event":
                merge_attached_event(file.open_stream(), event)
                continue
            if file.name in ("__sentry-breadcrumb1", "__sentry-breadcrumb2"):
                merge_attached_breadcrumbs(file.open_stream(), event)
                continue

            if file.type == "minidump":
                is_minidump = True
            if file.type == "applecrashreport":
                is_applecrashreport = True

            # Always store attachments that can be processed, regardless of the
            # event-attachments feature.
            if file.type in self.required_attachments or attachments_enabled:
                attachments.append(
                    CachedAttachment(
                        name=file.name,
                        data=file.open_stream().read(),
                        type=unreal_attachment_type(file),
                    )
                )

        if is_minidump:
            write_minidump_placeholder(event)
        elif is_applecrashreport:
            write_applecrashreport_placeholder(event)

        event_id = self.process(
            request,
            attachments=attachments,
            data=event,
            project=project,
            project_config=project_config,
            **kwargs
        )

        # The return here is only useful for consistency
        # because the UE4 crash reporter doesn't care about it.
        return HttpResponse(six.text_type(uuid.UUID(event_id)), content_type="text/plain")
コード例 #5
0
    def post(self, request, project, **kwargs):
        attachments_enabled = features.has('organizations:event-attachments',
                                           project.organization,
                                           actor=request.user)

        attachments = []
        try:
            event = {}
            unreal = process_unreal_crash(request.body,
                                          request.GET.get('UserID'),
                                          request.GET.get('AppEnvironment'),
                                          event)
            process_state = unreal.process_minidump()
            if process_state:
                merge_process_state_event(event, process_state)
            else:
                apple_crash_report = unreal.get_apple_crash_report()
                if apple_crash_report:
                    merge_apple_crash_report(apple_crash_report, event)
                else:
                    raise APIError("missing minidump in unreal crash report")
        except (ProcessMinidumpError, Unreal4Error) as e:
            minidumps_logger.exception(e)
            raise APIError(e.message.split('\n', 1)[0])

        try:
            unreal_context = unreal.get_context()
            if unreal_context is not None:
                merge_unreal_context_event(unreal_context, event, project)
        except Unreal4Error as e:
            # we'll continue without the context data
            minidumps_logger.exception(e)

        try:
            unreal_logs = unreal.get_logs()
            if unreal_logs is not None:
                merge_unreal_logs_event(unreal_logs, event)
        except Unreal4Error as e:
            # we'll continue without the breadcrumbs
            minidumps_logger.exception(e)

        for file in unreal.files():
            # Always store the minidump in attachments so we can access it during
            # processing, regardless of the event-attachments feature. This will
            # allow us to stack walk again with CFI once symbols are loaded.
            if file.type == "minidump" or attachments_enabled:
                attachments.append(
                    CachedAttachment(
                        name=file.name,
                        data=file.open_stream().read(),
                        type=unreal_attachment_type(file),
                    ))

        response_or_event_id = self.process(request,
                                            attachments=attachments,
                                            data=event,
                                            project=project,
                                            **kwargs)

        # The return here is only useful for consistency
        # because the UE4 crash reporter doesn't care about it.
        if isinstance(response_or_event_id, HttpResponse):
            return response_or_event_id

        return HttpResponse(six.text_type(uuid.UUID(response_or_event_id)),
                            content_type='text/plain')
コード例 #6
0
ファイル: api.py プロジェクト: wangzhichuang/sentry
    def post(self, request, project, relay_config, **kwargs):
        attachments_enabled = features.has('organizations:event-attachments',
                                           project.organization,
                                           actor=request.user)

        is_apple_crash_report = False

        attachments = []
        event = {'event_id': uuid.uuid4().hex}
        try:
            unreal = process_unreal_crash(request.body,
                                          request.GET.get('UserID'),
                                          request.GET.get('AppEnvironment'),
                                          event)

            apple_crash_report = unreal.get_apple_crash_report()
            if apple_crash_report:
                merge_apple_crash_report(apple_crash_report, event)
                is_apple_crash_report = True
        except (ProcessMinidumpError, Unreal4Error) as e:
            minidumps_logger.exception(e)
            track_outcome(relay_config.organization_id,
                          relay_config.project_id, None, Outcome.INVALID,
                          "process_minidump_unreal")
            raise APIError(e.message.split('\n', 1)[0])

        try:
            unreal_context = unreal.get_context()
            if unreal_context is not None:
                merge_unreal_context_event(unreal_context, event, project)
        except Unreal4Error as e:
            # we'll continue without the context data
            minidumps_logger.exception(e)

        try:
            unreal_logs = unreal.get_logs()
            if unreal_logs is not None:
                merge_unreal_logs_event(unreal_logs, event)
        except Unreal4Error as e:
            # we'll continue without the breadcrumbs
            minidumps_logger.exception(e)

        is_minidump = False

        for file in unreal.files():
            # Known attachment: msgpack event
            if file.name == "__sentry-event":
                merge_attached_event(file.open_stream(), event)
                continue
            if file.name in ("__sentry-breadcrumb1", "__sentry-breadcrumb2"):
                merge_attached_breadcrumbs(file.open_stream(), event)
                continue

            if file.type == "minidump" and not is_apple_crash_report:
                is_minidump = True

            # Always store the minidump in attachments so we can access it during
            # processing, regardless of the event-attachments feature. This will
            # allow us to stack walk again with CFI once symbols are loaded.
            if file.type == "minidump" or attachments_enabled:
                attachments.append(
                    CachedAttachment(
                        name=file.name,
                        data=file.open_stream().read(),
                        type=unreal_attachment_type(file),
                    ))

        if is_minidump:
            write_minidump_placeholder(event)

        event_id = self.process(request,
                                attachments=attachments,
                                data=event,
                                project=project,
                                relay_config=relay_config,
                                **kwargs)

        # The return here is only useful for consistency
        # because the UE4 crash reporter doesn't care about it.
        return HttpResponse(six.text_type(uuid.UUID(event_id)),
                            content_type='text/plain')
コード例 #7
0
ファイル: api.py プロジェクト: Kayle009/sentry
    def post(self, request, project, **kwargs):
        attachments_enabled = features.has('organizations:event-attachments',
                                           project.organization, actor=request.user)

        event_id = uuid.uuid4().hex
        data = {
            'event_id': event_id,
            'environment': request.GET.get('AppEnvironment'),
        }
        user_id = request.GET.get('UserID')
        if user_id:
            data['user'] = {
                'id': user_id
            }

        attachments = []
        try:
            unreal = process_unreal_crash(request.body)
            process_state = unreal.process_minidump()
        except (ProcessMinidumpError, Unreal4Error) as e:
            minidumps_logger.exception(e)
            raise APIError(e.message.split('\n', 1)[0])

        if process_state:
            merge_process_state_event(data, process_state)
        else:
            raise APIError("missing minidump in unreal crash report")

        try:
            unreal_context = unreal.get_context()
            if unreal_context is not None:
                merge_unreal_context_event(unreal_context, data, project)
        except Unreal4Error as e:
            # we'll continue without the context data
            minidumps_logger.exception(e)

        try:
            unreal_logs = unreal.get_logs()
            if unreal_logs is not None:
                merge_unreal_logs_event(unreal_logs, data)
        except Unreal4Error as e:
            # we'll continue without the breadcrumbs
            minidumps_logger.exception(e)

        for file in unreal.files():
            # Always store the minidump in attachments so we can access it during
            # processing, regardless of the event-attachments feature. This will
            # allow us to stack walk again with CFI once symbols are loaded.
            if file.type == "minidump" or attachments_enabled:
                attachments.append(CachedAttachment(
                    name=file.name,
                    data=file.open_stream().read(),
                    type=unreal_attachment_type(file),
                ))

        response_or_event_id = self.process(
            request,
            attachments=attachments,
            data=data,
            project=project,
            **kwargs)

        # The return here is only useful for consistency
        # because the UE4 crash reporter doesn't care about it.
        if isinstance(response_or_event_id, HttpResponse):
            return response_or_event_id

        return HttpResponse(
            six.text_type(uuid.UUID(response_or_event_id)),
            content_type='text/plain'
        )
コード例 #8
0
ファイル: api.py プロジェクト: yaoqi/sentry
    def post(self, request, project, **kwargs):
        attachments_enabled = features.has('organizations:event-attachments',
                                           project.organization, actor=request.user)

        attachments = []
        event = {'event_id': uuid.uuid4().hex}
        try:
            unreal = process_unreal_crash(request.body, request.GET.get(
                'UserID'), request.GET.get('AppEnvironment'), event)
            process_state = unreal.process_minidump()
            if process_state:
                merge_process_state_event(event, process_state)
            else:
                apple_crash_report = unreal.get_apple_crash_report()
                if apple_crash_report:
                    merge_apple_crash_report(apple_crash_report, event)
                else:
                    track_outcome(project.organization_id, project.id, None,
                                  Outcome.INVALID, "missing_minidump_unreal")
                    raise APIError("missing minidump in unreal crash report")
        except (ProcessMinidumpError, Unreal4Error) as e:
            minidumps_logger.exception(e)
            track_outcome(
                project.organization_id,
                project.id,
                None,
                Outcome.INVALID,
                "process_minidump_unreal")
            raise APIError(e.message.split('\n', 1)[0])

        try:
            unreal_context = unreal.get_context()
            if unreal_context is not None:
                merge_unreal_context_event(unreal_context, event, project)
        except Unreal4Error as e:
            # we'll continue without the context data
            minidumps_logger.exception(e)

        try:
            unreal_logs = unreal.get_logs()
            if unreal_logs is not None:
                merge_unreal_logs_event(unreal_logs, event)
        except Unreal4Error as e:
            # we'll continue without the breadcrumbs
            minidumps_logger.exception(e)

        for file in unreal.files():
            # Known attachment: msgpack event
            if file.name == "__sentry-event":
                merge_attached_event(file.open_stream(), event)
                continue
            if file.name in ("__sentry-breadcrumb1", "__sentry-breadcrumb2"):
                merge_attached_breadcrumbs(file.open_stream(), event)
                continue

            # Always store the minidump in attachments so we can access it during
            # processing, regardless of the event-attachments feature. This will
            # allow us to stack walk again with CFI once symbols are loaded.
            if file.type == "minidump" or attachments_enabled:
                attachments.append(CachedAttachment(
                    name=file.name,
                    data=file.open_stream().read(),
                    type=unreal_attachment_type(file),
                ))

        event_id = self.process(
            request,
            attachments=attachments,
            data=event,
            project=project,
            **kwargs)

        # The return here is only useful for consistency
        # because the UE4 crash reporter doesn't care about it.
        return HttpResponse(
            six.text_type(uuid.UUID(event_id)),
            content_type='text/plain'
        )