Skip to content

[Telemetry] Add Viper-based User config backed by Firestore DB#5478

Merged
kadupoornima merged 8 commits into
GoogleCloudPlatform:developfrom
kadupoornima:telemetry-f-2
Apr 13, 2026
Merged

[Telemetry] Add Viper-based User config backed by Firestore DB#5478
kadupoornima merged 8 commits into
GoogleCloudPlatform:developfrom
kadupoornima:telemetry-f-2

Conversation

@kadupoornima

@kadupoornima kadupoornima commented Apr 9, 2026

Copy link
Copy Markdown
Contributor

Overview
This PR adds a persistent, privacy-preserving Viper-based user config backed by Firestore and updates the telemetry collector to attach pseudonymous client installation IDs to events.

Key Changes

  • User Configuration & Identity (pkg/config/user_config.go):
    • Added generateUniqueID() which creates a stable, 24-character hex hash based on the hostname and user to serve as an anonymous identifier while avoiding PII leaks.
    • Added SaveToFirestore() to persist user configurations (like user_id and telemetry_enabled) into a Firestore database in the hpc-toolkit-gsc GCP project using the Firestore API.
    • Added Viper integration to manage local settings defaults and sync with Firestore.
  • Telemetry Collector Updates (pkg/telemetry/collector.go):
    • Updated BuildConcordEvent() to include ClientInstallId by fetching the ID from the persistent user config.
  • Documentation (pkg/telemetry/README.md):
    • Added a detailed README outlining the architecture and execution flow of the telemetry lifecycle (Initialization, Metrics Collection, Event Construction, Payload Building, and Uploading).
    • Included user instructions on how to disable telemetry.
  • Dependencies (go.mod & go.sum):
    • Added cloud.google.com/go/firestore, github.com/spf13/viper, and their related transitive dependencies.
  • Testing (pkg/config/user_config_test.go & pkg/telemetry/collector_test.go):
    • Added tests to verify that generateUniqueID() is deterministic and correctly hashed to a 24-character string.
    • Added tests for fetching the client install ID under different Viper config states.

KINDLY NOTE THAT TELEMETRY DATA IS NOT BEING COLLECTED YET.

@kadupoornima kadupoornima changed the title [Telemetry] Add persistent, privacy-preserving user config backed by Firestore [Telemetry] Add Viper-based User config methods backed by Firestore DB Apr 9, 2026
@kadupoornima kadupoornima changed the title [Telemetry] Add Viper-based User config methods backed by Firestore DB [Telemetry] Add Viper-based User config backed by Firestore DB Apr 9, 2026
@kadupoornima kadupoornima marked this pull request as ready for review April 9, 2026 10:12
@kadupoornima kadupoornima requested review from a team and samskillman as code owners April 9, 2026 10:12
@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 introduces a new system for managing persistent, privacy-preserving user configurations, primarily to support telemetry. It establishes a unique, anonymous client identifier, stores user preferences (like telemetry opt-in status) in Firestore, and integrates these settings into the telemetry collection process to improve usage tracking while maintaining user privacy.

Highlights

  • User Configuration Management: Implemented a mechanism to generate a stable, pseudonymous user ID and persist user settings (e.g., telemetry preferences) to Firestore.
  • Telemetry Integration: Updated the telemetry collector to attach the newly generated pseudonymous client installation IDs to events, enhancing usage tracking while preserving privacy.
  • Configuration System: Integrated Viper for local configuration management, allowing for default settings and remote synchronization with Firestore.
  • Comprehensive Documentation: Added a detailed README for the telemetry package, explaining its architecture, execution flow, and instructions for users to disable telemetry.
  • Dependency Updates: Incorporated new Go modules for Firestore and Viper, along with their transitive dependencies.
  • Robust Testing: Included new unit tests to ensure the determinism of unique ID generation and correct fetching of client installation IDs under various configuration states.
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.

@kadupoornima kadupoornima added the release-improvements Added to release notes under the "Improvements" heading. label Apr 9, 2026

@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 introduces a new pkg/config package to manage user-specific configurations, including a unique user ID and telemetry settings, persisted via Firestore. It also integrates this user ID into telemetry events within the pkg/telemetry package and updates Go module dependencies. The review highlights several critical issues: unhandled errors in unique ID generation, inefficient and potentially non-functional remote configuration loading, a security risk of exposing sensitive data by saving all Viper settings to Firestore, and the absence of timeouts for Firestore operations, which could lead to CLI hangs. Additionally, the current implementation inefficiently creates and closes Firestore clients for each operation.

Comment thread pkg/config/user_config.go Outdated
Comment thread pkg/config/user_config.go Outdated
Comment thread pkg/config/user_config.go Outdated
Comment thread pkg/config/user_config.go Outdated
Comment thread pkg/config/user_config.go Outdated

@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!

(Discussed offline.)

@kadupoornima kadupoornima enabled auto-merge (squash) April 13, 2026 06:03
@kadupoornima kadupoornima merged commit e07b3ea into GoogleCloudPlatform:develop Apr 13, 2026
16 of 73 checks passed
@kadupoornima kadupoornima deleted the telemetry-f-2 branch April 17, 2026 04:51
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