Skip to content

Commit

Permalink
chore: error tracking timings (#27433)
Browse files Browse the repository at this point in the history
  • Loading branch information
daibhin authored Jan 10, 2025
1 parent caacec4 commit b94a4a3
Showing 1 changed file with 31 additions and 25 deletions.
56 changes: 31 additions & 25 deletions posthog/hogql_queries/error_tracking_query_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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

Expand Down

0 comments on commit b94a4a3

Please sign in to comment.