feat(apiv3): implement GetDependencies in gRPC handler and HTTP gateway#8581
feat(apiv3): implement GetDependencies in gRPC handler and HTTP gateway#8581Pulkit7070 wants to merge 4 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds a GetDependencies endpoint to the APIv3 query service, exposed via both gRPC and HTTP handlers, with corresponding unit tests.
Changes:
- Implement
GetDependencieshandler in the APIv3 gRPC handler. - Add
/api/v3/dependenciesHTTP route with start/end time validation and response marshaling. - Extend the HTTP gateway test harness with a dependency-store mock and add tests for success and missing-params cases.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| cmd/jaeger/internal/extension/jaegerquery/internal/apiv3/grpc_handler.go | Adds gRPC GetDependencies implementation translating query results to API types. |
| cmd/jaeger/internal/extension/jaegerquery/internal/apiv3/http_gateway.go | Registers new /api/v3/dependencies route and implements its handler. |
| cmd/jaeger/internal/extension/jaegerquery/internal/apiv3/gateway_test.go | Adds depReader mock field to the test gateway. |
| cmd/jaeger/internal/extension/jaegerquery/internal/apiv3/http_gateway_test.go | Adds tests for the new dependencies HTTP endpoint, including a missing-params error case. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Gentle ping - happy to address any feedback when you get a chance. |
|
@Pulkit7070 can you please address the merge conflicts? |
970bf7a to
54f7490
Compare
|
The merge conflicts were resolved in the latest push - the branch is rebased cleanly on top of main (no conflict markers remaining). GitHub's mergeable status now shows clean. |
I'm still seeing merge conflicts |
…TTP gateway The api/v3 GetDependencies method was defined in the proto but not implemented in the Go Handler or HTTP gateway, causing every call to return an unimplemented error. Wire the method through to the QueryService so callers can fetch service dependency graphs via v3. Signed-off-by: Pulkit Saraf <prateeksaraf9@gmail.com>
54f7490 to
36ac250
Compare
| h.marshalResponse(&api_v3.DependenciesResponse{Dependencies: apiDeps}, w) | ||
| } | ||
| func (h *HTTPGateway) getServices(w http.ResponseWriter, r *http.Request) { |
| if startTime.IsZero() || endTime.IsZero() { | ||
| return nil, status.Error(codes.InvalidArgument, "start_time and end_time are required") | ||
| } |
- Add blank line between getDependencies and getServices handlers - Validate that endTime is after startTime in both HTTP and gRPC handlers - Use getQueryParam helper in getDependencies to support deprecated snake_case params - Add gRPC handler tests for success path, invalid params, and storage error - Add depReader field to testServerClient for dependency mock access Signed-off-by: Pulkit Saraf <prateeksaraf9@gmail.com>
Restore snapshot files to their upstream state; the CRLF/LF regeneration was a Windows-only side effect unrelated to the GetDependencies feature. Signed-off-by: Pulkit Saraf <prateeksaraf9@gmail.com>
| apiDeps := make([]*api_v3.Dependency, len(deps)) | ||
| for i, d := range deps { | ||
| apiDeps[i] = &api_v3.Dependency{ | ||
| Parent: d.Parent, | ||
| Child: d.Child, | ||
| CallCount: uint64(d.CallCount), | ||
| } | ||
| } | ||
| h.marshalResponse(&api_v3.DependenciesResponse{Dependencies: apiDeps}, w) |
| startTimeStr, startTimeParam := getQueryParam(q, paramStartTime, paramStartTimeDeprecated) | ||
| endTimeStr, endTimeParam := getQueryParam(q, paramEndTime, paramEndTimeDeprecated) | ||
| if startTimeStr == "" || endTimeStr == "" { | ||
| h.tryHandleError(w, fmt.Errorf("%s and %s are required", paramStartTime, paramEndTime), http.StatusBadRequest) | ||
| return | ||
| } |
| func TestHTTPGatewayGetDependenciesMissingParams(t *testing.T) { | ||
| gw := setupHTTPGatewayNoServer(t, "") | ||
|
|
||
| r, err := http.NewRequest(http.MethodGet, "/api/v3/dependencies", http.NoBody) | ||
| require.NoError(t, err) | ||
| w := httptest.NewRecorder() | ||
| gw.router.ServeHTTP(w, r) | ||
| assert.Equal(t, http.StatusBadRequest, w.Code) | ||
| assert.Contains(t, w.Body.String(), "are required") | ||
| } |
- Extract toAPIDependencies helper to eliminate duplicate conversion loop - Report specific missing parameter name in getDependencies error messages - Add HTTP tests for invalid time format, end-before-start, and storage error Signed-off-by: Pulkit Saraf <prateeksaraf9@gmail.com>
|
Addressed in the latest push: reverted the unrelated snapshot line-ending changes so only the GetDependencies-related files are modified. Also addressed all three Copilot comments from the second review (extracted toAPIDependencies helper, per-param missing error messages, added HTTP tests for invalid time format, end-before-start, and storage error). |
yurishkuro
left a comment
There was a problem hiding this comment.
please comment and resolve Copilot comments that are already addressed
|
linter failure |
Which problem is this PR solving?
Closes #7595
The
GetDependenciesRPC is declared inquery_service.protoand the generated Go interface requires everyQueryServiceServerto provide it. The concreteHandlerstruct inapiv3had no implementation, so all callers received anUnimplementedgRPC status. The HTTP gateway similarly had no/api/v3/dependenciesroute.Description of the changes
grpc_handler.go: AddGetDependenciesmethod onHandler. Validates that bothstart_timeandend_timeare present, computes the duration, delegates toh.QueryService.GetDependencies, and maps the result intoapi_v3.DependenciesResponse.http_gateway.go: RegisterGET /api/v3/dependenciesroute. Parsestart_time/end_timequery parameters (RFC 3339), callQueryService.GetDependencies, and encode the protobuf response via the sharedmarshalResponsehelper.gateway_test.go/http_gateway_test.go: Add tests for the happy path and missing-parameter error handling.How was this change tested?
All new tests pass. Pre-existing snapshot-test failures on Windows (CRLF/LF mismatch) are unrelated to this change.