示例#1
0
    def _process_response(self, json):
        source_names = {source["id"]: source.get("name") for source in self.sources}
        source_names[INTERNAL_SOURCE_NAME] = "Sentry"

        for module in json.get("modules") or ():
            for candidate in module.get("candidates") or ():
                if candidate.get("source"):
                    candidate["source_name"] = source_names.get(candidate["source"])

        return json
示例#2
0
    def _process(self, create_task):
        task_id = default_cache.get(self.task_id_cache_key)
        json = None

        with self.sess:
            try:
                if task_id:
                    # Processing has already started and we need to poll
                    # symbolicator for an update. This in turn may put us back into
                    # the queue.
                    json = self.sess.query_task(task_id)

                if json is None:
                    # This is a new task, so we compute all request parameters
                    # (potentially expensive if we need to pull minidumps), and then
                    # upload all information to symbolicator. It will likely not
                    # have a response ready immediately, so we start polling after
                    # some timeout.
                    json = create_task()
            except ServiceUnavailable:
                # 503 can indicate that symbolicator is restarting. Wait for a
                # reboot, then try again. This overrides the default behavior of
                # retrying after just a second.
                #
                # If there is no response attached, it's a connection error.
                raise RetrySymbolication(retry_after=10)

            metrics.incr(
                "events.symbolicator.response",
                tags={
                    "response": json.get("status") or "null",
                    "project_id": self.sess.project_id
                },
            )

            # Symbolication is still in progress. Bail out and try again
            # after some timeout. Symbolicator keeps the response for the
            # first one to poll it.
            if json["status"] == "pending":
                default_cache.set(self.task_id_cache_key, json["request_id"],
                                  REQUEST_CACHE_TIMEOUT)
                raise RetrySymbolication(retry_after=json["retry_after"])
            else:
                # Once we arrive here, we are done processing. Clean up the
                # task id from the cache.
                default_cache.delete(self.task_id_cache_key)
                return json
示例#3
0
    def _process_response(self, json):
        """Post-processes the JSON repsonse.

        This modifies the candidates list from Symbolicator responses to undo aliased
        sources, hide information about unknown sources and add names to sources rather then
        just have their IDs.
        """
        for module in json.get("modules") or ():
            for candidate in module.get("candidates") or ():
                # Reverse internal source aliases from the response.
                source_id = candidate["source"]
                original_source_id = self.reverse_source_aliases.get(source_id)
                if original_source_id is not None:
                    candidate["source"] = original_source_id
                    source_id = original_source_id

                # Add a "source_name" field to save the UI a lookup.
                candidate["source_name"] = self.source_names.get(source_id, "unknown")

        redact_internal_sources(json)
        return json