Skip to content

Conversation

@luispater
Copy link

No description provided.

altamash and others added 6 commits December 23, 2025 18:41
…pare in hasModelMappingsChanged; removed boolTo01.

   •  Performance: pre-allocate map and regex slice capacities in UpdateMappings.
   •  Verified with amp module tests (all passing)
feat: regex support for model-mappings
feat(logging): implement request ID tracking and propagation
@gemini-code-assist
Copy link

Summary of Changes

Hello @luispater, 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 observability and flexibility of the API by implementing a comprehensive request ID tracking system and extending the model mapping capabilities. The new request ID feature provides end-to-end traceability for AI API calls, while the addition of regular expression support for AMP model mappings allows for more dynamic and sophisticated routing configurations. These changes collectively improve debugging, monitoring, and model management within the system.

Highlights

  • Request ID Tracking: Introduced a new RequestID field in RequestInfo to uniquely identify API requests. Request IDs are generated for AI API paths and are propagated through the Gin context and context.Context for consistent tracking across the application.
  • Enhanced Logging: The Gin logger now includes the RequestID in its output for AI API requests, improving traceability. The file request logger also incorporates the RequestID into log filenames, making it easier to locate specific request logs. The global logger formatter has been updated to display the RequestID.
  • Regex Support for AMP Model Mapping: The AmpModelMapping configuration now supports a Regex boolean field. When set to true, the From field is interpreted as a regular expression, allowing for more flexible and powerful model routing rules. Exact matches are prioritized over regex matches.
  • Context Propagation for Request IDs: The RequestID is now properly propagated into the context.Context within API handlers, ensuring that downstream functions and services can access and utilize the request identifier for logging and debugging purposes.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

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.

Copy link

@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 introduces two main enhancements: request ID tracking for improved logging and traceability of AI API requests, and support for regex-based model mappings in the AMP module. The changes span across logging, middleware, and module-specific logic to integrate these features. The request ID is now generated for specific API paths and propagated through the request context, appearing in both console logs and request log files. The AMP model mapper can now use regular expressions for more flexible model routing. Overall, the changes are well-implemented. I have one suggestion to improve logging consistency.

Comment on lines +1612 to +1620
func logEntryWithRequestID(ctx context.Context) *log.Entry {
if ctx == nil {
return log.NewEntry(log.StandardLogger())
}
if reqID := logging.GetRequestID(ctx); reqID != "" {
return log.WithField("request_id", reqID)
}
return log.NewEntry(log.StandardLogger())
}

Choose a reason for hiding this comment

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

medium

For consistency with the Gin logger, which uses a '--------' placeholder for requests without a request ID, this function should also add a placeholder. This ensures all log lines have a consistent structure, making them easier to parse and read.

Suggested change
func logEntryWithRequestID(ctx context.Context) *log.Entry {
if ctx == nil {
return log.NewEntry(log.StandardLogger())
}
if reqID := logging.GetRequestID(ctx); reqID != "" {
return log.WithField("request_id", reqID)
}
return log.NewEntry(log.StandardLogger())
}
func logEntryWithRequestID(ctx context.Context) *log.Entry {
reqID := "--------"
if ctx != nil {
if id := logging.GetRequestID(ctx); id != "" {
reqID = id
}
}
return log.WithField("request_id", reqID)
}

@luispater
Copy link
Author

该 PR 无法直接解决冲突,我已在 #60 重新合并并完成冲突解决(状态为 CLEAN,可直接合并)。建议合并 #60 以替代本 PR。

@luispater luispater closed this Dec 24, 2025
luispater added a commit that referenced this pull request Dec 24, 2025
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