Skip to content

[Telemetry] Refactor getModules method to use cached standard modules from firestore#5570

Merged
kadupoornima merged 3 commits into
GoogleCloudPlatform:developfrom
kadupoornima:telemetry-15
Apr 29, 2026
Merged

[Telemetry] Refactor getModules method to use cached standard modules from firestore#5570
kadupoornima merged 3 commits into
GoogleCloudPlatform:developfrom
kadupoornima:telemetry-15

Conversation

@kadupoornima

@kadupoornima kadupoornima commented Apr 29, 2026

Copy link
Copy Markdown
Contributor

This pull request refactors the telemetry module retrieval process to rely on cached data from Firestore for getting pre-defined (standard) modules rather than performing live network requests to the GitHub API. This change improves the reliability and speed of the telemetry collection process by reducing external dependencies and leveraging pre-cached release metadata.

Changes:

  • Firestore Integration: Refactored module retrieval to fetch standard modules from Firestore instead of querying the GitHub API directly.
  • Code Cleanup: Removed obsolete GitHub API client code and associated tests in the config and telemetry packages.
  • Metadata Caching: Implemented a new mechanism to load release metadata into the Viper registry for improved performance and reliability.

@kadupoornima kadupoornima added the release-improvements Added to release notes under the "Improvements" heading. label Apr 29, 2026
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request refactors the telemetry module retrieval process to rely on cached data from Firestore rather than performing live network requests to the GitHub API. This change improves the reliability and speed of the telemetry collection process by reducing external dependencies and leveraging pre-cached release metadata.

Highlights

  • Firestore Integration: Refactored module retrieval to fetch standard modules from Firestore instead of querying the GitHub API directly.
  • Code Cleanup: Removed obsolete GitHub API client code and associated tests in the config and telemetry packages.
  • Metadata Caching: Implemented a new mechanism to load release metadata into the Viper registry for improved performance and reliability.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request replaces the GitHub-based module discovery logic with a Firestore-backed approach, updating the telemetry collector to fetch standard module metadata from a database instead of the Git tree. Feedback highlights the need to restore test coverage for telemetry sanitization and suggests optimizing the metadata loading process to avoid redundant network requests and improve testability.

I am having trouble creating individual review comments. Click here to see my feedback.

pkg/telemetry/collector_test.go (1037-1126)

high

The removal of TestGetModules eliminates the test coverage for the telemetry sanitization logic. This logic is critical for ensuring that user privacy is maintained by masking custom module paths with the "Custom" label. While the previous implementation relied on mocking HTTP requests to GitHub, the test should be restored and updated to mock the getStandardModules function (provided it is refactored to be a variable as suggested).

pkg/telemetry/collector_util.go (92-98)

medium

The getStandardModules function currently triggers a network request to Firestore via loadReleaseMetadata on every call. This is inefficient. Consider checking if the data is already present in viper before calling loadReleaseMetadata, and refactor the function into a variable to allow mocking in tests. Note that as a package-level variable used for mocking, it must include a comment explaining its purpose.

// getStandardModules is a package-level variable to allow mocking in unit tests.
var getStandardModules = func() []string {
	if viper.IsSet("standard_modules") {
		return viper.GetStringSlice("standard_modules")
	}
	if err := loadReleaseMetadata(); err != nil {
		return []string{}
	}
	return viper.GetStringSlice("standard_modules")
}
References
  1. When adding a package-level variable, ensure it has a brief comment explaining its purpose, especially if it's for mocking in unit tests, to adhere to documentation standards.

@kadupoornima kadupoornima marked this pull request as ready for review April 29, 2026 05:17
@kadupoornima kadupoornima requested a review from a team as a code owner April 29, 2026 05:17
@kadupoornima kadupoornima enabled auto-merge (squash) April 29, 2026 05:17
@kadupoornima

Copy link
Copy Markdown
Contributor Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request replaces the GitHub-based module discovery mechanism with a Firestore-backed metadata cache. It removes the GetPredefinedModules function from pkg/config and introduces loadReleaseMetadata in pkg/telemetry, which fetches and stores standard module lists in the global Viper registry. Feedback was provided regarding the getStandardModules implementation to avoid redundant network calls by checking the cache before triggering a fetch.

Comment thread pkg/telemetry/collector_util.go

@SwarnaBharathiMantena SwarnaBharathiMantena left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM!

Comment thread pkg/telemetry/collector_util.go
auto-merge was automatically disabled April 29, 2026 11:40

Repository rule violations found

@kadupoornima kadupoornima merged commit 2f352a0 into GoogleCloudPlatform:develop Apr 29, 2026
14 of 73 checks passed
@kadupoornima kadupoornima deleted the telemetry-15 branch April 29, 2026 11:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release-improvements Added to release notes under the "Improvements" heading.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants