Skip to content

Conversation

@pawel-maciejczek
Copy link
Contributor

@pawel-maciejczek pawel-maciejczek commented Feb 3, 2026

This PR refactors the telemetry implementation to centralize tracing logic and remove deprecated components.

Key changes:

  1. Removed the deprecated telemetry.RegisterLocalSpanProcessor method and its usage in server/adkrest.
  2. Cleaned up the internal/telemetry package by removing the local tracer provider implementation.
  3. Removed the dual Tracer setup and set the span in current context to create proper span tree.

Spans might not be ended in a proper place yet. Future PRs adding tracing based on semconv will address this issue.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @pawel-maciejczek, 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 focuses on a significant refactoring of the application's telemetry system, specifically migrating the OpenTelemetry tracing implementation to a new, dedicated adktrace package. This change centralizes the tracing logic, making it more modular and maintainable. It also introduces a mechanism to properly propagate tracing contexts throughout the invocation flow by enhancing the InvocationContext interface and its implementations. The overall impact is an improved and more robust tracing infrastructure for monitoring LLM and tool interactions.

Highlights

  • Tracing Refactoring: The existing OpenTelemetry tracing implementation has been refactored and moved into a new, dedicated adktrace package, centralizing tracing logic and improving modularity.
  • Context Propagation: The InvocationContext interface and its implementations now include a WithContext method, enabling proper propagation of tracing contexts throughout the application's invocation flow.
  • Integration of New Tracing: All LLM and tool call tracing within base_flow.go has been updated to utilize the new adktrace functions and the enhanced WithContext method for span management.

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

Changelog
  • agent/agent.go
    • Added a WithContext method to invocationContext to allow overriding the embedded context.
    • Added an interface compliance check for InvocationContext.
  • agent/agent_test.go
    • Imported the context package.
    • Added TestWithContext to validate the functionality of the new WithContext method.
  • agent/context.go
    • Added the WithContext(ctx context.Context) InvocationContext method to the InvocationContext interface, along with its documentation.
  • internal/context/context_test.go
    • Updated the copyright year from 2025 to 2026.
    • Imported context, github.com/google/go-cmp/cmp, and github.com/google/go-cmp/cmp/cmpopts.
    • Added TestWithContext to test the WithContext method for the InvocationContext type.
  • internal/context/invocation_context.go
    • Implemented the WithContext method for the concrete InvocationContext type.
    • Added an interface compliance check for agent.InvocationContext.
  • internal/llminternal/base_flow.go
    • Changed the import path for telemetry from internal/telemetry to internal/telemetry/adktrace.
    • Replaced all calls to the old telemetry tracing functions with the new adktrace functions.
    • Modified LLM and tool call tracing to use the new WithContext method for context propagation.
  • internal/telemetry/adktrace/adktrace.go
    • Added a new file and package adktrace to house the refactored OpenTelemetry tracing implementation.
    • Defined constants for OpenTelemetry attributes related to GenAI operations.
    • Provided StartTrace, TraceMergedToolCalls, TraceToolCall, and TraceLLMCall functions for tracing.
  • internal/telemetry/telemetry.go
    • Removed most of the tracing-related functions and constants, effectively deprecating the old tracing implementation in this file.
    • Retained only the SystemName constant.
Activity
  • No specific activity (comments, reviews, or progress updates) has been recorded for this pull request yet.
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 migrates the tracing implementation from an old internal provider to a new one based on OpenTelemetry standards. The changes introduce a new adktrace package and update the call sites. I've found a few critical issues related to incorrect span lifecycle management which could lead to panics, a high-severity issue with trace context propagation in loops, and some minor copy-paste errors in the new tracing package. Please address these to ensure the new tracing implementation is robust.

@pawel-maciejczek pawel-maciejczek force-pushed the feature/telemetry-unification branch from 7f0eb2e to 7bcdd15 Compare February 4, 2026 13:48
@pawel-maciejczek pawel-maciejczek changed the title feature: migrate the old tracing to new providers feat: switch the old tracing to single TracerProvider and add basic trace context propagation Feb 4, 2026
@pawel-maciejczek pawel-maciejczek force-pushed the feature/telemetry-unification branch 8 times, most recently from 5595c24 to 5a05047 Compare February 9, 2026 17:16
@pawel-maciejczek pawel-maciejczek force-pushed the feature/telemetry-unification branch from 5a05047 to 1476db6 Compare February 9, 2026 17:21
@pawel-maciejczek pawel-maciejczek marked this pull request as ready for review February 9, 2026 17:23
@dpasiukevich dpasiukevich merged commit d8eee22 into google:main Feb 9, 2026
4 checks passed
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