Skip to content

Fix metrics - #372

Merged
lukehinds merged 1 commit into
mainfrom
fix-metrics
Oct 14, 2025
Merged

Fix metrics#372
lukehinds merged 1 commit into
mainfrom
fix-metrics

Conversation

@lukehinds

Copy link
Copy Markdown
Collaborator

No description provided.

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @lukehinds, 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 overhauls the application's telemetry system, making it more robust, debuggable, and informative. It introduces a new method for generating and persisting anonymous user IDs, enhances the data collected for various operational events, and provides a CLI-driven debug option for metrics. These changes aim to improve the reliability and utility of usage analytics while maintaining user privacy.

Highlights

  • Metrics System Refactor: The core metrics system has been significantly refactored to improve user ID persistence and error handling. User IDs are now generated as UUIDs and stored on disk, replacing the previous machine-characteristic-based hashing. The system also includes better logging for telemetry failures and a new debug mode.
  • Enhanced Metrics Data Collection: Various trace events across generator.py, graph.py, and tree.py now include additional context such as provider, model_name, and conversation_type. This provides richer data for analytics, offering more insight into how different components are being used.
  • CLI Debugging for Metrics: A new set_trace_debug function has been introduced and integrated into the CLI's generate command. This allows users to enable debug output for metrics directly from the command line, making it easier to troubleshoot and verify telemetry events.
  • Improved Failure Summary Reporting: The DataSetGenerator's failure summary logic has been updated. Instead of storing failure examples in a dictionary keyed by category, they are now appended to a list, and the display logic has been adjusted to safely retrieve these examples.
  • Version Update: The deepfabric package version has been incremented from 2.10.0 to 2.11.0 in the uv.lock file, reflecting the changes introduced in this pull request.
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.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

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.

@lukehinds
lukehinds merged commit 5883751 into main Oct 14, 2025
3 checks passed
@lukehinds
lukehinds deleted the fix-metrics branch October 14, 2025 20:13

@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 significantly improves the metrics system by refactoring how user identity is handled, making it more robust and privacy-conscious. It also enriches the telemetry data by adding more context to the tracked events. However, I've found a critical issue in deepfabric/generator.py within the failure summarization logic that will cause a runtime error. My review focuses on fixing this bug.

Comment thread deepfabric/generator.py
Comment on lines +424 to +435
for _category, failures in self.failure_analysis.items():
if failures:
# Get up to 3 examples for each category
examples = failures[:3]
summary["failure_examples"][category] = [
summary["failure_examples"].append(
(
str(ex)[:200] + "..."
if len(str(ex)) > 200 # noqa: PLR2004
else str(ex) # noqa: PLR2004
) # noqa: PLR2004
else str(ex)
)
for ex in examples
]
)

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.

critical

There's a bug in this logic that will cause a runtime error. The summary["failure_examples"] variable is initialized as a dictionary, but this code attempts to call .append() on it, which is a list method. This will raise an AttributeError.

Additionally, the loop variable category was renamed to _category and is now unused, but it's required to correctly associate failure examples with their category in the dictionary. The original logic of assigning a list of examples to a dictionary key was correct.

I've provided a suggestion to fix this by restoring the correct dictionary assignment logic.

Suggested change
for _category, failures in self.failure_analysis.items():
if failures:
# Get up to 3 examples for each category
examples = failures[:3]
summary["failure_examples"][category] = [
summary["failure_examples"].append(
(
str(ex)[:200] + "..."
if len(str(ex)) > 200 # noqa: PLR2004
else str(ex) # noqa: PLR2004
) # noqa: PLR2004
else str(ex)
)
for ex in examples
]
)
for category, failures in self.failure_analysis.items():
if failures:
# Get up to 3 examples for each category
examples = failures[:3]
summary["failure_examples"][category] = [
(
str(ex)[:200] + "..."
if len(str(ex)) > 200
else str(ex)
)
for ex in examples
]

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.

1 participant