Example #1
0
    def handle_data(self, request, organization, project_ids, results):
        if not results:
            return results

        first_row = results[0]

        # TODO(mark) move all of this result formatting into discover.query()
        # once those APIs are used across the application.
        if "transaction.status" in first_row:
            for row in results:
                row["transaction.status"] = SPAN_STATUS_CODE_TO_NAME.get(
                    row["transaction.status"])

        fields = request.GET.getlist("field")
        has_issues = "issue" in fields
        if has_issues:  # Look up the short ID and return that in the results
            if has_issues:
                issue_ids = set(row.get("issue.id") for row in results)
                issues = Group.issues_mapping(issue_ids, project_ids,
                                              organization)
            for result in results:
                if has_issues and "issue.id" in result:
                    result["issue"] = issues.get(result["issue.id"], "unknown")

        if not ("project.id" in first_row or "projectid" in first_row):
            return results

        for result in results:
            for key in ("projectid", "project.id"):
                if key in result:
                    if key not in fields:
                        del result[key]

        return results
 def handle_issues(self, results: Sequence[Any], project_ids: Sequence[int],
                   organization: Organization) -> None:
     issue_ids = {row.get("issue.id") for row in results}
     issues = Group.issues_mapping(issue_ids, project_ids, organization)
     for result in results:
         if "issue.id" in result:
             result["issue"] = issues.get(result["issue.id"], "unknown")
Example #3
0
    def handle_data(self, request, organization, project_ids, results, omit_nan=False):
        if not results:
            return results

        first_row = results[0]

        # TODO(mark) move all of this result formatting into discover.query()
        # once those APIs are used across the application.
        if "transaction.status" in first_row:
            for row in results:
                row["transaction.status"] = SPAN_STATUS_CODE_TO_NAME.get(row["transaction.status"])

        fields = request.GET.getlist("field")
        has_issues = "issue" in fields
        if has_issues or omit_nan:  # Look up the short ID and return that in the results
            if has_issues:
                issue_ids = set(row.get("issue.id") for row in results)
                issues = Group.issues_mapping(issue_ids, project_ids, organization)
            for result in results:
                if has_issues and "issue.id" in result:
                    result["issue"] = issues.get(result["issue.id"], "unknown")
                # Remove any potential NaN or Inf cause python json accepts either, but js doesn't
                if omit_nan:
                    for key in result.keys():
                        if isinstance(result[key], float) and (
                            math.isnan(result[key]) or math.isinf(result[key])
                        ):
                            result[key] = None

        if not ("project.id" in first_row or "projectid" in first_row):
            return results

        for result in results:
            for key in ("projectid", "project.id"):
                if key in result:
                    if key not in fields:
                        del result[key]

        return results
Example #4
0
 def handle_issues(self, results, project_ids, organization):
     issue_ids = {row.get("issue.id") for row in results}
     issues = Group.issues_mapping(issue_ids, project_ids, organization)
     for result in results:
         if "issue.id" in result:
             result["issue"] = issues.get(result["issue.id"], "unknown")