Skip to content

Conversation

@thrivikram-karur-g
Copy link
Contributor

Description

Fix context loss and propagation issues to ensure trace context is propagated in gcsx client readers.

Link to the issue in case of a bug fix.

b/473678121

Testing details

  1. Manual - NA
  2. Unit tests - NA
  3. Integration tests - NA

Any backward incompatible change? If so, please explain.

@thrivikram-karur-g thrivikram-karur-g requested a review from a team as a code owner January 6, 2026 05:59
@github-actions github-actions bot added the remind-reviewers Auto remind reviewers in attention set for review post 24hrs of inactivity on PR. label Jan 6, 2026
@thrivikram-karur-g thrivikram-karur-g removed the request for review from vadlakondaswetha January 6, 2026 05:59
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @thrivikram-karur-g, 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 critical issues related to trace context propagation within the GCSFuse client readers. By introducing a dedicated tracing package and integrating its utilities across various file system and GCS interaction components, it ensures that OpenTelemetry trace information is consistently carried through operations, even when new Go contexts are spawned. This enhancement is crucial for maintaining end-to-end visibility and accurate monitoring of request flows, particularly in scenarios involving background reads and interrupt handling.

Highlights

  • Centralized Tracing Utilities: Introduced a new tracing package with a shared OpenTelemetry tracer and a utility function (MaybePropagateTraceContext) for consistent context propagation.
  • Improved Context Propagation: Modified internal/fs, internal/gcsx/client_readers, internal/gcsx/multi_range_downloader_wrapper, and internal/gcsx/random_reader to correctly propagate trace contexts, especially when new contexts are created (e.g., for interruptless operations or background reads).
  • Standardized Span Naming: Replaced hardcoded string literals for FUSE operation names in internal/fs/wrappers/tracing.go with constants defined in the new tracing/span_names.go file, promoting consistency and reducing potential for typos.

🧠 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 effectively addresses trace context propagation issues by introducing a centralized tracing package and refactoring existing code to use it. This improves maintainability by using constants for span names and ensuring trace context is not lost, especially in background operations within GCS client readers.

I've found one area for improvement regarding context cancellation handling in the multi_range_downloader_wrapper, where the IgnoreInterrupts flag is not being respected, potentially making an operation non-cancellable. My specific comment provides a suggestion to align its behavior with the rest of the codebase.

// LOCK_REQUIRED(mrdWrapper.mu.RLock)
func (mrdWrapper *MultiRangeDownloaderWrapper) ensureMultiRangeDownloader(forceRecreateMRD bool) (err error) {
func (mrdWrapper *MultiRangeDownloaderWrapper) ensureMultiRangeDownloader(ctx context.Context, forceRecreateMRD bool) (err error) {
ctx = tracing.MaybePropagateTraceContext(context.Background(), ctx, cfg.IsTracingEnabled(mrdWrapper.config))
Copy link
Contributor

Choose a reason for hiding this comment

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

high

The current implementation creates a new non-cancellable context for NewMultiRangeDownloader, effectively ignoring cancellation from the parent context regardless of the IgnoreInterrupts flag. This is inconsistent with how interrupts are handled elsewhere (e.g., in fs.go#getInterruptlessContext or in other readers like range_reader.go), which respect the FileSystem.IgnoreInterrupts config flag. If NewMultiRangeDownloader is a long-running operation (e.g., due to network issues), it will not be cancellable.

The context for NewMultiRangeDownloader should be cancellable if IgnoreInterrupts is false. You can achieve this by conditionally creating a new background context only when IgnoreInterrupts is true.

	if mrdWrapper.config != nil && mrdWrapper.config.FileSystem.IgnoreInterrupts {
		ctx = tracing.MaybePropagateTraceContext(context.Background(), ctx, cfg.IsTracingEnabled(mrdWrapper.config))
	}

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

Labels

remind-reviewers Auto remind reviewers in attention set for review post 24hrs of inactivity on PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant