Skip to content

stats: expose client authority in OutHeader - #9296

Open
aryansk wants to merge 4 commits into
grpc:masterfrom
aryansk:codex/issue-9235-stats-authority
Open

stats: expose client authority in OutHeader#9296
aryansk wants to merge 4 commits into
grpc:masterfrom
aryansk:codex/issue-9235-stats-authority

Conversation

@aryansk

@aryansk aryansk commented Aug 6, 2026

Copy link
Copy Markdown

Fixes #9235

Add the effective client authority to stats.OutHeader and populate it from callHdr.Host, as requested in the issue discussion. The change includes unary client stats regression coverage.

Tests:
mise exec go@1.26.5 -- gofmt -d stats/stats.go stats/stats_test.go internal/transport/http2_client.go
mise exec go@1.26.5 -- go test ./stats ./internal/transport

RELEASE NOTES:

  • stats: Expose the effective client authority in client stats.OutHeader events.

@linux-foundation-easycla

linux-foundation-easycla Bot commented Aug 6, 2026

Copy link
Copy Markdown

CLA Signed
The committers listed above are authorized under a signed CLA.

@easwars

easwars commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Can you please sign the CLA and move the PR out of draft for us to start reviewing.

@easwars easwars added Status: Requires Reporter Clarification Type: Feature New features or improvements in behavior labels Aug 6, 2026
@easwars easwars added this to the 1.84 Release milestone Aug 6, 2026
@aryansk

aryansk commented Aug 7, 2026

Copy link
Copy Markdown
Author

Thanks for the guidance. The CLA requires the contributor to review and accept the legal terms personally, so I cannot make that legal attestation on their behalf. I am leaving the PR in draft until that authorization is completed. Once the repository reports the CLA as signed, I can continue with the ready-for-review step.

@aryansk

aryansk commented Aug 9, 2026

Copy link
Copy Markdown
Author

Thanks for the heads-up. I’m leaving this PR in draft while the required CLA step remains outstanding; I won’t claim that legal agreement is signed from here. Once that requirement is handled on GitHub, the PR can be reviewed.

@easwars

easwars commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

There is nothing that we as contributors need to do to approve the legal terms. You just need to click the button/link and agree to the terms.

@aryansk
aryansk marked this pull request as ready for review August 11, 2026 05:13
@aryansk

aryansk commented Aug 11, 2026

Copy link
Copy Markdown
Author

Thanks for the clarification. EasyCLA now reports the commits as authorized under the signed CLA, and the PR is marked ready for review. The remaining check failures are separate from the CLA status and will need to be handled independently.

@codecov

codecov Bot commented Aug 11, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 83.22%. Comparing base (c200c2d) to head (fef007f).
⚠️ Report is 14 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #9296      +/-   ##
==========================================
+ Coverage   83.02%   83.22%   +0.20%     
==========================================
  Files         423      423              
  Lines       35215    35140      -75     
==========================================
+ Hits        29236    29246      +10     
+ Misses       4453     4400      -53     
+ Partials     1526     1494      -32     
Files with missing lines Coverage Δ
internal/transport/http2_client.go 92.63% <100.00%> (+0.69%) ⬆️
stats/stats.go 66.66% <ø> (ø)

... and 47 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@eshitachandwani eshitachandwani assigned easwars and mbissa and unassigned aryansk Aug 11, 2026
@aryansk

aryansk commented Aug 11, 2026

Copy link
Copy Markdown
Author

Thanks for the report. Coverage for the changed lines is complete at head df0c780; the 7-commit-behind note is expected since the PR was branched earlier. Remaining CI work is tracked separately.

@mbissa

mbissa commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

/gemini review

@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 the Authority field to the OutHeader struct in the stats package to track the :authority pseudo-header for client RPCs, and updates the HTTP/2 client to populate it. It also adds corresponding test coverage, including a new test case for authority overrides. The reviewer suggested a valuable improvement to validate st.Authority against the default authority (the server address) when no override is specified, ensuring broader test coverage for this new field.

Comment thread stats/stats_test.go Outdated
Comment on lines +629 to +631
if e.authority != "" && st.Authority != e.authority {
t.Fatalf("st.Authority = %s, want %s", st.Authority, e.authority)
}

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.

medium

Currently, st.Authority is only validated when an explicit authority override is set in the test configuration (e.authority != ""). For all other tests, the Authority field in OutHeader goes completely unchecked.

We should validate st.Authority against the default authority (which is e.serverAddr) when no override is specified. This ensures that the default authority is also correctly populated and verified across all existing test cases.

		wantAuthority := e.authority
		if wantAuthority == "" {
			wantAuthority = e.serverAddr
		}
		if st.Authority != wantAuthority {
			t.Fatalf("st.Authority = %s, want %s", st.Authority, wantAuthority)
		}

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Implemented in efbf744. Client OutHeader now validates the explicit authority override when present and the default server address otherwise; the full stats package test suite passes.

@aryansk

aryansk commented Aug 11, 2026

Copy link
Copy Markdown
Author

The Gemini review suggestion is implemented in efbf744: the existing client stats assertion now checks the default server authority as well as explicit overrides. go test ./stats -count=1 passes.

@aryansk

aryansk commented Aug 11, 2026

Copy link
Copy Markdown
Author

Thanks for the review. I applied the requested default-authority coverage in efbf744 and verified the full stats package with go test ./stats -count=1.

Comment thread stats/stats_test.go Outdated
h.mu.Lock()
checkConnStats(t, h.gotConn)
h.mu.Unlock()
expect.authority = cc.authority

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.

Nit: Can this field be set as part of the literal struct initialization for expectedData above?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Done in fef007f. Initialized authority directly inside the expectedData struct literal; go test ./stats passes.

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

Labels

Status: Requires Reporter Clarification Type: Feature New features or improvements in behavior

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support for Authority in stats.Handler

4 participants