diff --git a/posthog/hogql_queries/error_tracking_query_runner.py b/posthog/hogql_queries/error_tracking_query_runner.py index 091665bf7caba..591257a414623 100644 --- a/posthog/hogql_queries/error_tracking_query_runner.py +++ b/posthog/hogql_queries/error_tracking_query_runner.py @@ -138,19 +138,20 @@ def where(self): return ast.And(exprs=exprs) def calculate(self): - query_result = self.paginator.execute_hogql_query( - query=self.to_query(), - team=self.team, - query_type="ErrorTrackingQuery", - timings=self.timings, - modifiers=self.modifiers, - limit_context=self.limit_context, - filters=HogQLFilters( - dateRange=self.query.dateRange, - filterTestAccounts=self.query.filterTestAccounts, - properties=self.properties, - ), - ) + with self.timings.measure("error_tracking_query_hogql_execute"): + query_result = self.paginator.execute_hogql_query( + query=self.to_query(), + team=self.team, + query_type="ErrorTrackingQuery", + timings=self.timings, + modifiers=self.modifiers, + limit_context=self.limit_context, + filters=HogQLFilters( + dateRange=self.query.dateRange, + filterTestAccounts=self.query.filterTestAccounts, + properties=self.properties, + ), + ) columns: list[str] = query_result.columns or [] results = self.results(columns, query_result.results) @@ -169,18 +170,23 @@ def results(self, columns: list[str], query_results: list): mapped_results = [dict(zip(columns, value)) for value in query_results] issue_ids = [result["id"] for result in mapped_results] - issues = self.error_tracking_issues(issue_ids) - - for result_dict in mapped_results: - issue = issues.get(result_dict["id"]) - if issue: - results.append(issue | result_dict | {"assignee": self.query.assignee, "id": str(result_dict["id"])}) - else: - logger.error( - "error tracking issue not found", - issue_id=result_dict["id"], - exc_info=True, - ) + + with self.timings.measure("issue_fetching_execute"): + issues = self.error_tracking_issues(issue_ids) + + with self.timings.measure("issue_resolution"): + for result_dict in mapped_results: + issue = issues.get(result_dict["id"]) + if issue: + results.append( + issue | result_dict | {"assignee": self.query.assignee, "id": str(result_dict["id"])} + ) + else: + logger.error( + "error tracking issue not found", + issue_id=result_dict["id"], + exc_info=True, + ) return results