Skip to content

Overlay: report telemetry #2975

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

Overlay: report telemetry #2975

wants to merge 4 commits into from

Conversation

cklin
Copy link
Contributor

@cklin cklin commented Jul 17, 2025

This PR adds telemetry fields for overlay analysis.

  • analysis_is_overlay
  • analysis_builds_overlay_base_database
  • overlay_base_database_download_size_bytes
  • overlay_base_database_download_duration_ms

Merge / deployment checklist

  • Confirm this change is backwards compatible with existing workflows.
  • Confirm the readme has been updated if necessary.
  • Confirm the changelog has been updated if necessary.

@cklin cklin marked this pull request as ready for review July 17, 2025 18:13
@Copilot Copilot AI review requested due to automatic review settings July 17, 2025 18:13
@cklin cklin requested a review from a team as a code owner July 17, 2025 18:13
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds telemetry tracking for overlay database analysis operations. The changes enable the CodeQL Action to collect and report statistics about overlay-base database downloads and analysis modes.

  • Modified the download function to return telemetry statistics instead of a boolean
  • Added new telemetry fields to track download size, duration, and analysis modes
  • Expanded test coverage for the updated download function behavior

Reviewed Changes

Copilot reviewed 8 out of 12 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/overlay-database-utils.ts Updated download function to return telemetry stats and measure database size/download time
src/overlay-database-utils.test.ts Added comprehensive test cases for the modified download function
src/init-action.ts Updated to capture and pass overlay database stats to telemetry reporting
src/analyze.ts Added telemetry flags to track overlay vs overlay-base analysis modes
lib/* Generated JavaScript files reflecting the TypeScript changes

@cklin cklin force-pushed the cklin/overlay-telemetry branch from 76a1b2d to 2b3bae6 Compare July 17, 2025 18:21
@cklin cklin requested a review from mbg July 17, 2025 19:03
Copy link
Member

@mbg mbg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This generally looks good, assuming all the necessary backend work is also done to support this. Thanks also for including some tests.

There are no blocking issues. I flagged up a couple points that might be good to deal with before merging this though, as well as some other trivial points.

src/analyze.ts Outdated
Comment on lines 639 to 643
} else if (
config.augmentationProperties.overlayDatabaseMode ===
OverlayDatabaseMode.OverlayBase
) {
statusReport.analysis_builds_overlay_base_database = true;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor: perhaps this would be slightly nicer as, similar to what we already have for analysis_is_diff_informed:

Suggested change
} else if (
config.augmentationProperties.overlayDatabaseMode ===
OverlayDatabaseMode.OverlayBase
) {
statusReport.analysis_builds_overlay_base_database = true;
}
statusReport.analysis_builds_overlay_base_database =
config.augmentationProperties.overlayDatabaseMode ===
OverlayDatabaseMode.OverlayBase;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks—I implemented the suggestion.

@@ -235,41 +235,47 @@ export async function uploadOverlayBaseDatabaseToCache(
return true;
}

export interface OverlayBaseDatabaseDownloadStats {
databaseSizeBytes: number;
databaseDownloadDurationMillis: number;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor: elsewhere we use Ms as suffix rather than Millis. Might be nicer to use that for consistency.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks—I implemented the suggestion.

*/
export async function downloadOverlayBaseDatabaseFromCache(
codeql: CodeQL,
config: Config,
logger: Logger,
): Promise<boolean> {
): Promise<undefined | OverlayBaseDatabaseDownloadStats> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor: Conventionally the undefined seems to come last. There's nothing wrong with this I think, but it's just a bit unusual. I see we have this order in a couple of other places in the codebase though.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A bigger question here is probably why the return type is used to indicate failure at all. Wouldn't it be better to have this as Promise<OverlayBaseDatabaseDownloadStats> and reject if the download was either not performed or failed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I moved undefined to the last.

The question of using a rejected promise instead of promise of undefined is interesting. There are three cases:

  1. We are not supposed to download, so we didn't
  2. We are supposed to download, but something went wrong
  3. We are supposed to download, and the download completed successfully

The caller does not care about the distinction between 1 and 2, and the function returns undefined for both of these cases. We could use a rejected promise for both 1 and 2, and it would work, but the control flow would be a bit strange—it is like throwing an exception (and then catch it gracefully) to skip a feature that is disabled by flag.

An alternative is return undefined for 1 and a rejected promise for 2. That avoids the aforementioned awkwardness, at the cost of making the caller more complicated, having to check for both undefined and add a catch block and do the same thing in both cases.

I think the current implementation is better than these two alternatives, but I can be persuaded otherwise.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could use a rejected promise with different values for 1 and 2 respectively that the caller can then check for (these can be arbitrary values). It is indeed a bit odd to handle such cases with catch, although you could have something as simple as .catch(console.debug) (or similar) after the call to downloadOverlayBaseDatabaseFromCache if there are appropriate messages given to throw.

Alternatively, the feature check could be moved out from downloadOverlayBaseDatabaseFromCache to the caller.

I don't feel strongly about this though and am be happy for it to stay as-is.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In that case, let's keep the current code.

Comment on lines 331 to 333
logger.warning(
"Filesystem error while accessing downloaded overlay-base database",
);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tryGetFolderBytes will log a warning (since you don't set quiet=true) before returning undefined, so this will always lead to two warnings for the same problem, which I believe will show up as separate workflow annotations.

I'd suggest either removing this warning or setting quiet=true in the tryGetFolderBytes call.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think both messages are worth preserving because they tell the user different things.

  • The warning from tryGetFolderBytes explains what went wrong. This is important if the user were to fix the underlying technical problem.
  • The warning here in downloadOverlayBaseDatabaseFromCache explains the consequence of the failure (that the downloaded overlay-base database cannot be accessed) so that the user can assess the severity and impact of the problem.

That said, I agree that they do not both have to be warnings. I downgraded this message to info.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps it would be reasonable for tryGetFolderBytes to return the error rather than undefined and then leave it up to the caller to decide what to do with that (e.g. include it in a combined log message with the consequence + underlying problem).

Not something you need to act on if you're happy to downgrade this to an info-level message.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. I already downgraded the log from warning and info, and I am happy with that change.

// unable to determine the size of the database. Rather, it is that we
// encountered a filesystem error while accessing the database, which
// indicates that an overlay analysis will likely fail.
logger.warning("Downloaded overlay-base database is invalid");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similarly here: it would be better to merge this into the previous .warning call if you want both messages. Otherwise, maybe remove the previous one or make it a .debug level message?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this extra warning call is an oversight on my part, and it should not be here. I have removed it.

Thanks for catching this!

@cklin cklin force-pushed the cklin/overlay-telemetry branch from 2b3bae6 to 39b0524 Compare July 18, 2025 15:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy