Skip to content

Conversation

hugehoo
Copy link
Contributor

@hugehoo hugehoo commented Sep 11, 2025

Fixes: #8529

This PR fixes to increment metrics only when the stream is active which is found in the activeStreams map.

as-is

  • The deleteStream was incrementing channelz metrics every time it was called, even when stream was already removed from activeStreams or not exists in activeStreams.

to-be

  • Added check to ensure metrics are only incremented once when a stream is actually removed from activeStreams.

RELEASE NOTES:

  • server: Fix a bug that caused overcounting of channelz metrics for successful and failed streams.

Copy link

codecov bot commented Sep 11, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.20%. Comparing base (8420f3f) to head (f701f5c).
⚠️ Report is 31 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #8573      +/-   ##
==========================================
+ Coverage   80.91%   82.20%   +1.29%     
==========================================
  Files         413      415       +2     
  Lines       40751    40712      -39     
==========================================
+ Hits        32972    33467     +495     
+ Misses       6155     5877     -278     
+ Partials     1624     1368     -256     
Files with missing lines Coverage Δ
internal/transport/http2_server.go 90.88% <100.00%> (+<0.01%) ⬆️

... and 43 files with indirect coverage changes

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

@hugehoo hugehoo marked this pull request as ready for review September 11, 2025 17:41
@arjan-bal arjan-bal self-requested a review September 23, 2025 05:05
@arjan-bal arjan-bal self-assigned this Sep 23, 2025
@arjan-bal arjan-bal added this to the 1.77 Release milestone Sep 23, 2025
Copy link
Contributor

@arjan-bal arjan-bal left a comment

Choose a reason for hiding this comment

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

Thanks for sending the PR, nice job writing a unit test for this!

@arjan-bal arjan-bal assigned hugehoo and unassigned arjan-bal Sep 23, 2025
@hugehoo hugehoo requested a review from arjan-bal September 29, 2025 16:11
@arjan-bal arjan-bal assigned arjan-bal and unassigned hugehoo Sep 29, 2025
@arjan-bal arjan-bal assigned hugehoo and unassigned arjan-bal Oct 3, 2025
@hugehoo
Copy link
Contributor Author

hugehoo commented Oct 3, 2025

@arjan-bal thx for the review, i updated additional comments

@hugehoo hugehoo requested a review from arjan-bal October 3, 2025 11:54
@arjan-bal arjan-bal assigned arjan-bal and unassigned hugehoo Oct 6, 2025
Copy link
Contributor

@arjan-bal arjan-bal left a comment

Choose a reason for hiding this comment

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

LGTM, with a minor comment. Assigning a second reviewer.

}

// Always create a real stream through the client
ctx, cancel := context.WithTimeout(context.Background(), 100*time.Millisecond)
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: We should create a context at the beginning of t.Run with a timeout of defaultTestTimeout. This should help ensure that the entire test case finishes within 10 seconds.

@arjan-bal arjan-bal removed their assignment Oct 6, 2025
@arjan-bal arjan-bal requested a review from easwars October 6, 2025 08:45
t.Run(test.name, func(t *testing.T) {
// Setup server configuration with channelz support
serverConfig := &ServerConfig{
ChannelzParent: channelz.RegisterServer("test server"),
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: Could we use t.Name() as the name for this server so that the two tests in the table get different names.

@easwars easwars removed their assignment Oct 6, 2025
@easwars
Copy link
Contributor

easwars commented Oct 6, 2025

@hugehoo : Please take care of the couple of minor nitty comments. Thanks for your contribution again.

@easwars
Copy link
Contributor

easwars commented Oct 6, 2025

Also, the PR title seems to be broken. Could you please fix that too.

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

Successfully merging this pull request may close these issues.

transport: Servers may emit extra channelz stream metrics on cancellation
3 participants