-
Notifications
You must be signed in to change notification settings - Fork 202
Expose per-query structured evaluator logs #1186
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,6 +34,8 @@ import { DatabaseManager } from './databases'; | |
import { registerQueryHistoryScubber } from './query-history-scrubber'; | ||
import { QueryStatus } from './query-status'; | ||
import { slurpQueryHistory, splatQueryHistory } from './query-serialization'; | ||
import * as fs from 'fs-extra'; | ||
import { CliVersionConstraint } from './cli'; | ||
|
||
/** | ||
* query-history.ts | ||
|
@@ -406,6 +408,18 @@ export class QueryHistoryManager extends DisposableObject { | |
this.handleOpenQueryDirectory.bind(this) | ||
) | ||
); | ||
this.push( | ||
commandRunner( | ||
'codeQLQueryHistory.showEvalLog', | ||
this.handleShowEvalLog.bind(this) | ||
) | ||
); | ||
this.push( | ||
commandRunner( | ||
'codeQLQueryHistory.showEvalLogSummary', | ||
this.handleShowEvalLogSummary.bind(this) | ||
) | ||
); | ||
this.push( | ||
commandRunner( | ||
'codeQLQueryHistory.cancel', | ||
|
@@ -744,6 +758,49 @@ export class QueryHistoryManager extends DisposableObject { | |
} | ||
} | ||
} | ||
|
||
private warnNoEvalLog() { | ||
void showAndLogWarningMessage('No evaluator log is available for this run. Perhaps it failed before evaluation, or you are running with a version of CodeQL before ' + CliVersionConstraint.CLI_VERSION_WITH_PER_QUERY_EVAL_LOG + '?'); | ||
} | ||
|
||
async handleShowEvalLog( | ||
singleItem: QueryHistoryInfo, | ||
multiSelect: QueryHistoryInfo[] | ||
) { | ||
const { finalSingleItem, finalMultiSelect } = this.determineSelection(singleItem, multiSelect); | ||
|
||
// Only applicable to an individual local query | ||
if (!this.assertSingleQuery(finalMultiSelect) || !finalSingleItem || finalSingleItem.t !== 'local') { | ||
return; | ||
Comment on lines
+773
to
+774
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should this situation also result in some kind of error message? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm, good question. I followed what @aeisenberg did above for other similar drop downs. Any particular reason you went with just a |
||
} | ||
|
||
if (finalSingleItem.evalLogLocation) { | ||
await this.tryOpenExternalFile(finalSingleItem.evalLogLocation); | ||
} else { | ||
this.warnNoEvalLog(); | ||
} | ||
} | ||
|
||
async handleShowEvalLogSummary( | ||
singleItem: QueryHistoryInfo, | ||
multiSelect: QueryHistoryInfo[] | ||
) { | ||
const { finalSingleItem, finalMultiSelect } = this.determineSelection(singleItem, multiSelect); | ||
|
||
// Only applicable to an individual local query | ||
if (!this.assertSingleQuery(finalMultiSelect) || !finalSingleItem || finalSingleItem.t !== 'local') { | ||
return; | ||
Comment on lines
+791
to
+792
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same comment as above. |
||
} | ||
|
||
if (finalSingleItem.evalLogLocation) { | ||
if (!fs.existsSync(finalSingleItem.evalLogSummaryLocation)) { | ||
await this.qs.cliServer.generateLogSummary(finalSingleItem.evalLogLocation, finalSingleItem.evalLogSummaryLocation); | ||
} | ||
await this.tryOpenExternalFile(finalSingleItem.evalLogSummaryLocation); | ||
} else { | ||
this.warnNoEvalLog(); | ||
} | ||
} | ||
|
||
async handleCancel( | ||
singleItem: QueryHistoryInfo, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -146,7 +146,7 @@ export class QueryServerClient extends DisposableObject { | |
args.push('--require-db-registration'); | ||
} | ||
|
||
if (await this.cliServer.cliConstraints.supportsOldEvalStats()) { | ||
if (await this.cliServer.cliConstraints.supportsOldEvalStats() && !(await this.cliServer.cliConstraints.supportsPerQueryEvalLog())) { | ||
args.push('--old-eval-stats'); | ||
} | ||
|
||
|
@@ -258,3 +258,7 @@ export class QueryServerClient extends DisposableObject { | |
export function findQueryLogFile(resultPath: string): string { | ||
return path.join(resultPath, 'query.log'); | ||
} | ||
|
||
export function findQueryStructLogFile(resultPath: string): string { | ||
return path.join(resultPath, 'evaluator-log.jsonl'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just making sure this isn't a typo and it should be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is not a typo - |
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, these logs are specific to a dataset, not a query?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In a sense, yes. We rotate the logs when new queries are started, but if there are multiple concurrent queries running then events from the evaluator will end up in the latest query to be started.