dotnet / aspire

Tools, templates, and packages to accelerate building observable, production-ready apps
https://learn.microsoft.com/dotnet/aspire
MIT License
3.93k stars 480 forks source link

Allow users to configure preferred protocol (gRPC or HTTP/Protobuf) for OpenTelemetry endpoints #6789

Open wterpstra opened 13 hours ago

wterpstra commented 13 hours ago

Is there an existing issue for this?

Is your feature request related to a problem? Please describe the problem.

See this code:

https://github.com/dotnet/aspire/blob/c9326c75b42b28e3f3a4174f9b24bad9f22305e9/src/Aspire.Hosting/OtlpConfigurationExtensions.cs#L48C1-L63C14

Currently the gRPC endpoint is preferred over the HTTP/Protobuf endpoint. When running a frontend application with for example the Aspire.Hosting.NodeAppResource it will always default to the gRPC endpoint, even though only the HTTP/Protobuf endpoint is feasible for frontends. While it is possible to disable the gRPC endpoint, this is not ideal. I would still like to run my APIs with the gRPC endpoint since that matches the eventual production configuration

Describe the solution you'd like

I propose adding an extra overload to the OtlpConfigurationExtensions.WithOtlpExporter(...). This overload would allow users to explicitly configure which endpoint (and protocol) should be used. If an endpoint is selected that is not running on the dashboard, an exception should be thrown.

Additional context

No response