Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add List method to gRPC Health service #8155

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

marcoshuck
Copy link

This change introduces a new List RPC endpoint for the Health service, allowing clients to retrieve the statuses of all monitored services. This feature simplifies integration with status-reporting dashboards and enhances observability for microservices.

Proposal: grpc/proposal#468
gRPC-proto change: grpc/grpc-proto#143

This change introduces a new `List` RPC endpoint for the Health service, allowing clients to retrieve the statuses of all monitored services. This feature simplifies integration with status-reporting dashboards and enhances observability for microservices.

Proposal: grpc/proposal#468
gRPC-proto change: grpc/grpc-proto#143
Signed-off-by: Marcos Huck <[email protected]>
Copy link
Author

Choose a reason for hiding this comment

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

I regenerated the Go stubs using the work in progress version of grpc/grpc-proto#143

Copy link
Author

Choose a reason for hiding this comment

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

I regenerated the Go stubs using the work in progress version of grpc/grpc-proto#143

Copy link

codecov bot commented Mar 8, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 82.29%. Comparing base (5668c66) to head (31b32ef).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #8155      +/-   ##
==========================================
- Coverage   82.32%   82.29%   -0.04%     
==========================================
  Files         392      392              
  Lines       39140    39156      +16     
==========================================
+ Hits        32222    32223       +1     
- Misses       5597     5605       +8     
- Partials     1321     1328       +7     
Files with missing lines Coverage Δ
health/server.go 95.83% <100.00%> (+0.83%) ⬆️

... and 25 files with indirect coverage changes

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

Copy link
Contributor

@purnesh42H purnesh42H left a comment

Choose a reason for hiding this comment

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

@marcoshuck i think we need to wait for the proposal and proto change to be merged before this? I still see them in review

@dfawley cc

s.mu.RLock()
defer s.mu.RUnlock()

if len(s.statusMap) > 100 {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: 100 can be a const above with a meaningful variable name

@@ -81,3 +86,46 @@ func (s) TestShutdown(t *testing.T) {
t.Fatalf("status for %s is %v, want %v", testService, status, healthpb.HealthCheckResponse_NOT_SERVING)
}
}

func (s) TestList(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Please docstring for Test explaining what is it verifying

s := NewServer()

// Remove the zero value
delete(s.statusMap, "")
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: need to acquire lock for this?

delete(s.statusMap, "")

// Fill out status map with service information, 101 elements will trigger an error.
for i := 1; i <= 101; i++ {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it would be cleaner to have separate test for ResourceExhausted and success

}

for key := range out.GetStatuses() {
if _, ok := s.statusMap[key]; !ok {
Copy link
Contributor

Choose a reason for hiding this comment

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

i think we should also verify the serving status?

}

// Remove the 101 element to avoid the error.
delete(s.statusMap, "101")
Copy link
Contributor

Choose a reason for hiding this comment

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

if we can have separate test for success, the we don't need to have list of 100 services. 2 would be enough

@purnesh42H purnesh42H added Area: Observability Includes Stats, Tracing, Channelz, Healthz, Binlog, Reflection, Admin, GCP Observability Type: Feature New features or improvements in behavior Status: Requires Reporter Clarification labels Mar 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Observability Includes Stats, Tracing, Channelz, Healthz, Binlog, Reflection, Admin, GCP Observability 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.

2 participants