Skip to content

feat(storage): add OpenTelemetry tracing for OAuth2 token source - #20376

Open
sahusneha2004 wants to merge 6 commits into
googleapis:mainfrom
sahusneha2004:feat/otel-auth-refresh-token
Open

feat(storage): add OpenTelemetry tracing for OAuth2 token source#20376
sahusneha2004 wants to merge 6 commits into
googleapis:mainfrom
sahusneha2004:feat/otel-auth-refresh-token

Conversation

@sahusneha2004

@sahusneha2004 sahusneha2004 commented Aug 12, 2026

Copy link
Copy Markdown

Description

This PR introduces OpenTelemetry tracing support for authentication token refreshes (Auth.RefreshAccessToken) to fulfill the T5 internal operations telemetry specification for the Google Cloud Storage Go client.

Background & Architectural Context

In the Go Cloud SDKs, default credential resolution (Application Default Credentials) and background token lifecycle management are handled deep within the shared transport layer (google.golang.org/api/transport and cloud.google.com/go/auth).

To provide Auth.RefreshAccessToken span recording within the storage module without modifying upstream shared transport dependencies, this PR introduces TracedTokenSource as a non-intrusive decorator around oauth2.TokenSource.

Includes unit test TestTracedTokenSourceSpan in storage/trace_test.go.

Usage Example

Callers or integrations supplying a custom oauth2.TokenSource can wrap it with NewTracedTokenSource:

ts := storage.NewTracedTokenSource(customTokenSource)
client, err := storage.NewClient(ctx, option.WithTokenSource(ts))

@sahusneha2004
sahusneha2004 requested review from a team as code owners August 12, 2026 17:12
@product-auto-label product-auto-label Bot added the api: storage Issues related to the Cloud Storage API. label Aug 12, 2026

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

Copy link
Copy Markdown
Contributor

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 TracedTokenSource, which wraps an oauth2.TokenSource to record OpenTelemetry spans for authentication token refreshes, along with corresponding unit tests. The feedback highlights a critical compilation error in Token() where a context.Context is incorrectly passed to endSpan instead of a trace.Span, and notes that the new TracedTokenSource is not yet integrated into the client initialization path.

Comment thread storage/trace.go Outdated
Comment thread storage/trace.go
@sahusneha2004
sahusneha2004 force-pushed the feat/otel-auth-refresh-token branch 2 times, most recently from c5c9a8f to ad3f1ed Compare August 13, 2026 06:39
@sahusneha2004
sahusneha2004 force-pushed the feat/otel-auth-refresh-token branch from ad3f1ed to b347cf4 Compare August 17, 2026 10:16
@sahusneha2004
sahusneha2004 force-pushed the feat/otel-auth-refresh-token branch from b347cf4 to 3a45573 Compare August 20, 2026 05:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: storage Issues related to the Cloud Storage API.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant