Skip to content

Conversation

@DEVMANISHOFFL
Copy link

Description

This PR addresses the issue where the Dev UI becomes cluttered with internal HTTP traces (e.g., standard net/http client calls) that are not relevant to the developer's AI flows.

I implemented a filteringExporter middleware for the OpenTelemetry TracerProvider. This ensures that only spans explicitly containing genkit attributes are exported to the Dev UI, filtering out background noise while preserving all relevant AI traces.

Issues Resolved

Fixes #3984

Checklist (if applicable):

Signed-off-by: devmanishofficial <devmanishofficial@gmail.com>
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @DEVMANISHOFFL, 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 addresses a usability issue in the Dev UI where internal HTTP traces were cluttering the display, making it difficult to focus on relevant AI flow traces. The solution involves introducing a filtering layer for OpenTelemetry spans, ensuring that only traces directly related to genkit operations are processed and displayed, thereby enhancing the clarity and utility of the Dev UI for developers.

Highlights

  • Filtering OpenTelemetry Traces: A new filteringExporter has been introduced to selectively export OpenTelemetry spans, ensuring only relevant traces are processed.
  • Improved Dev UI Clarity: This exporter specifically filters for spans containing genkit attributes, significantly reducing clutter from irrelevant internal HTTP traces in the Dev UI.
  • Integration with TracerProvider: The filteringExporter is now integrated into both immediate and batch telemetry writing processes by wrapping the existing TelemetryServerExporter.

🧠 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
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 introduces a filteringExporter to filter out non-genkit traces from the dev UI, which is a great improvement for reducing noise. The implementation is clear and effectively solves the issue. I've added a couple of suggestions to improve performance and maintainability by pre-allocating a slice and using an existing constant instead of a magic string. Overall, this is a solid contribution.

}

func (e *filteringExporter) ExportSpans(ctx context.Context, spans []sdktrace.ReadOnlySpan) error {
var genkitSpans []sdktrace.ReadOnlySpan
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

For better performance and to avoid potential reallocations within the loop, it's a good practice to pre-allocate the slice with a known capacity. This ensures that the backing array for the slice is allocated only once.

Suggested change
var genkitSpans []sdktrace.ReadOnlySpan
genkitSpans := make([]sdktrace.ReadOnlySpan, 0, len(spans))


func isGenkitSpan(span sdktrace.ReadOnlySpan) bool {
for _, attr := range span.Attributes() {
if strings.HasPrefix(string(attr.Key), "genkit") {
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

To improve maintainability and avoid magic strings, please use the existing attrPrefix constant instead of the hardcoded string "genkit".

Suggested change
if strings.HasPrefix(string(attr.Key), "genkit") {
if strings.HasPrefix(string(attr.Key), attrPrefix) {

@hugoaguirre hugoaguirre self-requested a review December 29, 2025 18:22
@DEVMANISHOFFL
Copy link
Author

@google-gemini-code-assist Thanks for the review!

I have applied the suggested fixes:

  • Removed unused imports in go/MIDDLEWARE.md.
  • Fixed the typo in go/README.md.
  • Applied the slice pre-allocation optimization in go/core/tracing/tracing.go.

Note on CI:
The tests are failing in go/ai (TestResolveFormat), which I have not touched. go vet ./core/... and go test ./core/... pass cleanly locally.

@gemini-code-assist
Copy link
Contributor

Thanks for the update, @DEVMANISHOFFL! I appreciate you addressing the suggestions.

Regarding the CI failure in go/ai (TestResolveFormat), since you haven't touched that part of the codebase, it's likely an unrelated issue. It might be a pre-existing flake or an issue introduced by another change. Could you please check if this failure is new to this PR or if it's reproducible on main? My review focused on the changes introduced in this pull request, and this CI issue appears to be external to those modifications.

Let me know if you need any further assistance!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

[Go] Traces in Dev UI show non-Genkit library traces like HTTP GET for traces

1 participant