Skip to content

Commit

Permalink
ui: fix statement diag reports when min exec latency is null
Browse files Browse the repository at this point in the history
A bug in db console was resulting in statement diagnostics
reports to not work as intended. As a result, activating
diagnostics didn't result in the intended state change which
showed a user that a diagnostics report is running or downloadble.

This was happening in edge cases where reports "minExecutionLatency"
response field was null, but the db console expected it to be populated.
Now, db console should handle this edge case.

This commit also adds nanosecond granularity to the returned
StatementDiagnosticsResponse.min_execution_latency field. Previously only
the seconds portion of the statement's min_execution_latency was
converted into the returned objects duration, but often times this
latency will be sub 1 second, resulting in "O" to be returned.

Fixes: #139340
Epic: none
Release note (bug fix): Fixes a bug where sometimes activating
diagnostics for sql activity appears unresponsive, with no
state or status update upon activating. Now, the status should
always reflect that diagnosticsa are active or that a statement
bundle is downloadable.
  • Loading branch information
kyle-a-wong committed Jan 17, 2025
1 parent 93180aa commit b1d462d
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions pkg/ui/workspaces/cluster-ui/src/api/statementDiagnosticsApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,24 @@ export async function getStatementDiagnosticsReports(): Promise<StatementDiagnos
STATEMENT_DIAGNOSTICS_PATH,
);
return response.reports.map(report => {
const minExecutionLatency = report.min_execution_latency
? moment
.duration(report.min_execution_latency?.seconds.toNumber(), "seconds")
.add(
moment.duration(
report.min_execution_latency.nanos / 1e9,
"seconds",
),
)
: null;
return {
id: report.id.toString(),
statement_fingerprint: report.statement_fingerprint,
completed: report.completed,
statement_diagnostics_id: report.statement_diagnostics_id.toString(),
requested_at: moment.unix(report.requested_at.seconds.toNumber()),
min_execution_latency: moment.duration(
report.min_execution_latency.seconds.toNumber(),
"seconds",
),
expires_at: moment.unix(report.expires_at.seconds.toNumber()),
requested_at: moment.unix(report.requested_at?.seconds.toNumber()),
min_execution_latency: minExecutionLatency,
expires_at: moment.unix(report.expires_at?.seconds.toNumber()),
};
});
}
Expand Down

0 comments on commit b1d462d

Please sign in to comment.