dotnet / aspire

An opinionated, cloud ready stack for building observable, production ready, distributed applications in .NET
https://learn.microsoft.com/dotnet/aspire
MIT License
3.79k stars 449 forks source link

Display referenced resources in the dashboard #2595

Open JamesNK opened 7 months ago

JamesNK commented 7 months ago

I think it would be pretty useful to see what resources a resource is referencing in the dashboard.

builder.AddProject<Projects.MyFrontend>("frontend")
       .WithReference(basketService)
       .WithReference(catalogService.GetEndpoint("http"));

In the example above, the frontend resource would have two references. A reference would have:

The resource model today doesn't have references, just the env vars used by the app. You could try to reverse engineer references by looking at environment variables, but it would be a pain in the butt. It is much easier to model it explicitly and display values from the model.

Edit: We could also display the reverse. What resources reference the current resource, e.g. basketservice is referenced by frontend and apigateway.

In the UI, call it dependencies and used by? That's what NuGet does:

JamesNK commented 7 months ago

Note: I looks like the app model doesn't have this information (just env vars are added). Edit: Actually, EndpointReferenceAnnotation is added sometimes and other times (for connection strings?) it isn't.

It would need to be added to the app model, returned in the resource service (I added a comment to https://github.com/dotnet/aspire/issues/2415), the added to the resource detail UI.

JamesNK commented 7 months ago

cc @davidfowl @DamianEdwards

davidfowl commented 7 months ago

Here is the original issue and PR for modeling dependencies:

This is the latest PR: https://github.com/dotnet/aspire/pull/2594. The goal is to move to a richer way of modeling references in things like environment variables and connection strings. Are you thinking we only show connection string references and endpoint references or more?

davidfowl commented 7 months ago

Also related https://github.com/dotnet/aspire/issues/1436

davidfowl commented 7 months ago

cc @IEvangelist was interested in this as well.

IEvangelist commented 7 months ago

Yeah, I had imagined that we should display a visual representation of the network topology.

image

This was drafted up with mermaid, assuming that we might want to use that in the dashboard. I wrote a Razor library POC to test out using mermaid.js, with the idea that it might be used for something like this. Ideally, we could either query the App Model or maybe even the manifest. With the dependency graph and some other runtime data, we could create a mermaid chart and render it like that. All of this was just an idea though...

dahlsailrunner commented 3 months ago

Love this thought / direction and it would be super helpful!!!