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

Create a /deep-dependencies endpoint #6654

Open
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

adityachopra29
Copy link
Contributor

@adityachopra29 adityachopra29 commented Feb 2, 2025

Which problem is this PR solving?

Description of the changes

  • Create endpoint api/deep-dependencies for ddg.
  • Adds code for it to server

How was this change tested?

Checklist

@adityachopra29 adityachopra29 requested a review from a team as a code owner February 2, 2025 16:02
@dosubot dosubot bot added the enhancement label Feb 2, 2025
Copy link

codecov bot commented Feb 2, 2025

Codecov Report

Attention: Patch coverage is 88.57143% with 4 lines in your changes missing coverage. Please review.

Project coverage is 96.01%. Comparing base (ce0f543) to head (e817951).

Files with missing lines Patch % Lines
...d/query/app/analytics/deep_dependencies_handler.go 87.87% 3 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6654      +/-   ##
==========================================
- Coverage   96.06%   96.01%   -0.06%     
==========================================
  Files         364      365       +1     
  Lines       20696    20730      +34     
==========================================
+ Hits        19881    19903      +22     
- Misses        622      631       +9     
- Partials      193      196       +3     
Flag Coverage Δ
badger_v1 9.76% <ø> (ø)
badger_v2 1.82% <ø> (ø)
cassandra-4.x-v1-manual 14.81% <ø> (ø)
cassandra-4.x-v2-auto 1.81% <ø> (ø)
cassandra-4.x-v2-manual 1.81% <ø> (ø)
cassandra-5.x-v1-manual 14.81% <ø> (ø)
cassandra-5.x-v2-auto 1.81% <ø> (ø)
cassandra-5.x-v2-manual 1.81% <ø> (ø)
elasticsearch-6.x-v1 19.15% <ø> (ø)
elasticsearch-7.x-v1 19.23% <ø> (ø)
elasticsearch-8.x-v1 19.40% <ø> (ø)
elasticsearch-8.x-v2 1.82% <ø> (ø)
grpc_v1 10.81% <ø> (ø)
grpc_v2 7.80% <ø> (ø)
kafka-3.x-v1 10.13% <ø> (ø)
kafka-3.x-v2 1.82% <ø> (ø)
memory_v2 1.82% <ø> (ø)
opensearch-1.x-v1 19.28% <ø> (ø)
opensearch-2.x-v1 ?
opensearch-2.x-v2 1.82% <ø> (-0.12%) ⬇️
tailsampling-processor 0.48% <ø> (ø)
unittests 94.90% <88.57%> (-0.05%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@yurishkuro
Copy link
Member

Please see comments in #6608, the same applies here

@adityachopra29 adityachopra29 force-pushed the add-deep-dependencies-endpoint branch from 8ff02e0 to 0e4d03e Compare February 3, 2025 18:16
@adityachopra29
Copy link
Contributor Author

adityachopra29 commented Feb 3, 2025

@yurishkuro the /deep-dependencies url is working now, but there are some issues.

  • Actually jaeger-ui tries to find a focalNode (ie focalService and focalOperation), which is chosen from all the operations of the chosen service. Hence there doesnt seem to be a simple way of just hardcoding the deep-dependencies.
    To show the working in the ui, I chose the hotrod example and a specific service (namely driver) to show the rendering.
  • I tried to set a default value for the focalNode as a temporary solution, but the problem remains that the focalService and focalOperation will have to exist for this to work.
REC-20250203235503.mp4
  • As per your suggestion, I changed the backend to /api/deep-dependencies. However, the frontend still looks for the backend data on /analytics/v1/dependencies . So we will need to raise a PR in the ui repo for the same.

@yurishkuro
Copy link
Member

Sorry I don't follow your points about focal service. Isn't that a user choice after you return the data? Is that an input to the endpoint that returns the data? In either case the dummy endpoint can ignore that input and always return the same data, and to test it you can specify the focal service in the query URL (I assume).

Another thing I didn't understand is why did you have to run hotrod in your screencast? If the endpoint always returns dummy data, what was the point of sending data to Jaeger from HotROD?

@yurishkuro
Copy link
Member

And yes, you will need to make a change to the UI to use a different URL for the data. We could make it configurable in the UI, to keep it backwards compatible.

@adityachopra29
Copy link
Contributor Author

adityachopra29 commented Feb 11, 2025

In either case the dummy endpoint can ignore that input and always return the same data, and to test it you can specify the focal service in the query URL (I assume).

@yurishkuro
I was actually trying to find workarounds of not hardcoding the service and operation, and directly going to /deep-dependencies and chosing a service and operation, which was causing a problem. But I understand the need now.

If we go to http://localhost:16686/deep-dependencies?density=ppe&operation=opA&service=serviceA we get the required graph.

This was also the reason I was running the hotrod example, to mock services and operations.

Are there any other considerations? Otherwise, I will move on and write the tests for the same, and also raise a pr in the ui.

@adityachopra29 adityachopra29 force-pushed the add-deep-dependencies-endpoint branch from 4c624a3 to 2389215 Compare February 12, 2025 20:57
@adityachopra29 adityachopra29 changed the title add deep dependencies endpoint Create a /deeo-dependencies endpoint Feb 12, 2025
@adityachopra29 adityachopra29 changed the title Create a /deeo-dependencies endpoint Create a /deep-dependencies endpoint Feb 12, 2025
@adityachopra29
Copy link
Contributor Author

@yurishkuro I have added the tests and also raised the PR in the UI. Please have a look once.

_ ...any, /* args */
) *mux.Route {
var handler http.Handler = http.HandlerFunc(f)
handler = otelhttp.WithRouteTag(route, handler)
Copy link
Member

Choose a reason for hiding this comment

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

isn't tracing of the endpoint already taken care of at the top level?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

But wouldn't that only trace the parent span? As I understand, the parent tracer will not go recursively into the children spans. Please clariy once.

Copy link
Member

Choose a reason for hiding this comment

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

you are not adding any child spans, you're adding another, duplicate layer of instrumentation. It's redundant.

Signed-off-by: adityachopra29 <[email protected]>
Signed-off-by: adityachopra29 <[email protected]>
Signed-off-by: adityachopra29 <[email protected]>
Signed-off-by: adityachopra29 <[email protected]>
Signed-off-by: adityachopra29 <[email protected]>
Signed-off-by: adityachopra29 <[email protected]>
Signed-off-by: adityachopra29 <[email protected]>
Signed-off-by: adityachopra29 <[email protected]>
@adityachopra29 adityachopra29 force-pushed the add-deep-dependencies-endpoint branch from b9c8a50 to 0370b33 Compare February 14, 2025 18:35
@adityachopra29
Copy link
Contributor Author

@yurishkuro I have made the changes. Please have a look.

Comment on lines 19 to 21
// HTTPGateway exposes analytics HTTP endpoints.
type HTTPGateway struct{}

Copy link
Member

Choose a reason for hiding this comment

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

not used

Suggested change
// HTTPGateway exposes analytics HTTP endpoints.
type HTTPGateway struct{}

@@ -0,0 +1,90 @@
// Copyright (c) 2025 The Jaeger Authors.
Copy link
Member

Choose a reason for hiding this comment

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

why is the file called http_gateway? It does nothing of the sort.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. I had named it before when I had made the gateway struct. Will rename it to deep_dependencies_handler


res, err := json.Marshal(dependencies)
if err != nil {
http.Error(w, "Failed to encode response", http.StatusNotImplemented)
Copy link
Member

Choose a reason for hiding this comment

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

StatusNotImplemented

it IS implemented.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay. I will use InternalServerError.

Comment on lines 76 to 78
if basePath != "" && basePath != "/" {
gw.router = gw.router.PathPrefix(basePath).Subrouter()
}
Copy link
Member

Choose a reason for hiding this comment

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

why is this relevant?

) *testGateway {
gw := setupHTTPGatewayNoServer(t, basePath)

httpServer := httptest.NewServer(gw.router)
Copy link
Member

Choose a reason for hiding this comment

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

there is no need to set up a server to test the RegisterRouter function. You can do it all with a mock http response recorder.

Signed-off-by: adityachopra29 <[email protected]>
Signed-off-by: adityachopra29 <[email protected]>
router *mux.Router,
f func(http.ResponseWriter, *http.Request),
route string,
_ ...any, /* args */
Copy link
Member

Choose a reason for hiding this comment

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

what is this for?

@@ -183,6 +183,8 @@ func initRouter(
Tracer: telset.TracerProvider,
}).RegisterRoutes(r)

analytics.RegisterRoutes(r)
Copy link
Member

Choose a reason for hiding this comment

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

why isn't it called from apiHandler.RegisterRoutes(r)?

Copy link
Member

@yurishkuro yurishkuro left a comment

Choose a reason for hiding this comment

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

please use the exact same structure/organization of code as in #6608

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.

Create dummy /deep-dependencies endpoint
2 participants