Skip to content

[Part 3/6] feat(telemetry): enhance metrics with performance monitoring APIs#8113

Merged
joshualitt merged 3 commits intogoogle-gemini:mainfrom
eLyiN:split/metrics-enhancements
Sep 25, 2025
Merged

[Part 3/6] feat(telemetry): enhance metrics with performance monitoring APIs#8113
joshualitt merged 3 commits intogoogle-gemini:mainfrom
eLyiN:split/metrics-enhancements

Conversation

@eLyiN
Copy link
Copy Markdown
Contributor

@eLyiN eLyiN commented Sep 9, 2025

Summary

Enhances the telemetry metrics system with 12 new performance monitoring metrics, advanced recording functions, and performance monitoring configuration. This provides comprehensive instrumentation for startup timing, memory usage, CPU tracking, and performance analysis.

Dependencies

⚠️ This PR depends on:

Review Order: Please review Parts 1-2 first (#8110, #8111), then this PR.

Related PRs - Enhanced Performance Monitoring Split

This is Part 3 of 6 in the split implementation of #2127:

Changes in This PR

Performance Metrics Constants (packages/core/src/telemetry/constants.ts)

Adds 12 new OpenTelemetry-compliant metric constants for comprehensive performance monitoring including startup timing, memory usage, CPU tracking, tool execution analysis, and performance regression detection.

Enhanced Metrics Recording (packages/core/src/telemetry/metrics.ts)

New Performance Recording Functions: 12 new functions covering startup performance, resource monitoring, tool execution analysis, API performance tracking, and performance analysis with rich attribution and OpenTelemetry integration.


Next Steps: After Parts 1-3 merge, Parts 4-6 will add memory monitoring, activity monitoring, and CLI integration using these enhanced metrics.

@eLyiN eLyiN requested a review from a team as a code owner September 9, 2025 20:35
Copy link
Copy Markdown
Contributor

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

Choose a reason for hiding this comment

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

Summary of Changes

Hello @eLyiN, 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 significantly enhances the existing telemetry system by integrating a robust performance monitoring framework. The primary goal is to capture and analyze various performance aspects of the application, such as startup times, resource utilization, and the efficiency of tool and API interactions. This foundational work provides the necessary instrumentation to identify performance bottlenecks and track improvements over time, without affecting runtime behavior unless explicitly enabled.

Highlights

  • Expanded Telemetry Metrics: Introduced comprehensive performance monitoring primitives including startup duration, memory/CPU usage, tool queue depth, and execution breakdowns.
  • New API Metrics: Added metrics for token efficiency, API request breakdowns, and performance scoring to provide deeper insights into API interactions.
  • Monitoring Utilities: Implemented utilities for regression/baseline recording and checks for performance monitoring state.
  • Performance-Related Constants: Incorporated new constants to ensure consistent thresholds and naming conventions for performance metrics.
  • Exported APIs and Enums: Exposed new performance metrics APIs and enums from the telemetry index for external use.
  • Inert Functions: Ensured that all new performance monitoring functions are inert unless explicitly called and guarded by isPerformanceMonitoringActive.
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 in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

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 issue 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.

Copy link
Copy Markdown
Contributor

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

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 enhances telemetry by adding a comprehensive suite of performance monitoring metrics. The implementation is robust, with new constants, metric functions, and thorough unit tests. I have a couple of suggestions to improve the maintainability and consistency of the new metric collection logic, primarily around simplifying memory usage tracking and ensuring consistent attributes for baseline comparison metrics. Overall, this is a great addition for performance analysis.

@gemini-cli gemini-cli bot added kind/enhancement priority/p2 Important but can be addressed in a future release. labels Sep 9, 2025
@eLyiN eLyiN changed the title feat(telemetry): enhance metrics and constants; export performance metrics APIs [Part 3/4] feat(telemetry): enhance metrics with performance monitoring APIs Sep 9, 2025
@eLyiN eLyiN marked this pull request as draft September 9, 2025 21:03
@eLyiN eLyiN changed the title [Part 3/4] feat(telemetry): enhance metrics with performance monitoring APIs [Part 3/6] feat(telemetry): enhance metrics with performance monitoring APIs Sep 9, 2025
@joshualitt
Copy link
Copy Markdown
Contributor

@eLyiN , this PR looks basically ready to go once the comments from Gemini are addressed. Please take a look, we'd love to land this ASAP.

@eLyiN
Copy link
Copy Markdown
Contributor Author

eLyiN commented Sep 19, 2025

@eLyiN , this PR looks basically ready to go once the comments from Gemini are addressed. Please take a look, we'd love to land this ASAP.

Hi @joshualitt , sorry didn't have much time this week, rebasing and solving conflicts now, will take a look on the weekend

@eLyiN eLyiN force-pushed the split/metrics-enhancements branch 2 times, most recently from c769380 to 91259ce Compare September 19, 2025 21:28
@eLyiN
Copy link
Copy Markdown
Contributor Author

eLyiN commented Sep 19, 2025

/gemini review

Copy link
Copy Markdown
Contributor

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

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 enhances the telemetry system by adding a comprehensive set of performance monitoring metrics. The changes include new metric constants, OpenTelemetry instruments, and recording functions for tracking startup time, resource usage, and other performance-related aspects. The implementation is well-structured, and it's accompanied by a thorough suite of tests covering various scenarios, including edge cases like zero baseline values.

My review focuses on ensuring the new telemetry code adheres to best practices for library development. I have one suggestion to improve logging consistency and prevent potential side effects for consumers of this package.

@eLyiN eLyiN marked this pull request as ready for review September 19, 2025 21:53
@eLyiN eLyiN requested a review from a team as a code owner September 19, 2025 21:53
@eLyiN eLyiN force-pushed the split/metrics-enhancements branch 2 times, most recently from e13ca52 to 089f8cf Compare September 21, 2025 19:38
Copy link
Copy Markdown
Contributor

@jacob314 jacob314 left a comment

Choose a reason for hiding this comment

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

lgtm

@eLyiN eLyiN force-pushed the split/metrics-enhancements branch 2 times, most recently from 082a4b0 to 32bc7f8 Compare September 24, 2025 09:33
@eLyiN
Copy link
Copy Markdown
Contributor Author

eLyiN commented Sep 24, 2025

@joshualitt, The conflicts have been resolved and it's ready to be merged, in my opinion. Thank you!

@eLyiN eLyiN requested a review from joshualitt September 24, 2025 09:35
…racking

- Remove duplicate memory metric constants and unified memory tracking
- Introduce dedicated regression percentage change histogram
- Consolidate memory recording to single histogram with memory_type attribute
- Separate regression percentage tracking from baseline comparison metrics
@eLyiN eLyiN force-pushed the split/metrics-enhancements branch from 32bc7f8 to 3a09ed4 Compare September 25, 2025 07:25
@joshualitt joshualitt added this pull request to the merge queue Sep 25, 2025
Merged via the queue into google-gemini:main with commit f80eb71 Sep 25, 2025
28 of 29 checks passed
bobcatfish added a commit that referenced this pull request Oct 2, 2025
The event constants are moving into types.ts as part of #10347, but
these were added in #8113 without actually being used. Looking at the
follow ups to #8113 I don't see anywhere these are actually going to be
used, so removing them.
bobcatfish added a commit that referenced this pull request Oct 3, 2025
The event constants are moving into types.ts as part of #10347, but
these were added in #8113 without actually being used. Looking at the
follow ups to #8113 I don't see anywhere these are actually going to be
used, so removing them.
bobcatfish added a commit that referenced this pull request Oct 7, 2025
The event constants are moving into types.ts as part of #10347, but
these were added in #8113 without actually being used. Looking at the
follow ups to #8113 I don't see anywhere these are actually going to be
used, so removing them.
bobcatfish added a commit that referenced this pull request Oct 9, 2025
The event constants are moving into types.ts as part of #10347, but
these were added in #8113 without actually being used. Looking at the
follow ups to #8113 I don't see anywhere these are actually going to be
used, so removing them.
giraffe-tree pushed a commit to giraffe-tree/gemini-cli that referenced this pull request Oct 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

priority/p2 Important but can be addressed in a future release.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants