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.38k stars 350 forks source link

ServiceEndpointWatcher should be creating activities #4423

Open thompson-tomo opened 1 month ago

thompson-tomo commented 1 month ago

Upon an analysis of my application i have observed that "Microsoft.Extensions.ServiceDiscovery.ServiceEndpointWatcher" is not having trace/transactions ids.

As such i would like that all methods generating logs are wrapped in activities to enabled distributed tracing and at the same time all log events have a trace/transaction id.

At the same time it should be checked if any other methods are not covered

davidfowl commented 1 month ago

Why would it create an activity?

thompson-tomo commented 3 weeks ago

@davidfowl when i look at my logs i am getting the following log messages:

{"@timestamp":"2024-06-13T08:39:05.4832113+10:00","log.level":"Debug","message":"Resolving endpoints for service \u0027http://localhost:8761\u0027.","log":{"logger":"Microsoft.Extensions.ServiceDiscovery.ServiceEndpointWatcher"},"labels":{"EventName":"ResolvingEndpoints"},"event":{"code":"1","created":"2024-06-13T08:39:05.4832113+10:00","severity":7,"timezone":"AUS Eastern Standard Time"}"service":{"name":"http://localhost:8761","node.name":"","version":"2.3.1-beta-241610955\u002B81e61e0e20f6b035dc1bb7e4e91442759b37c0b3"},"metadata":{"EventId":1},"MessageTemplate":"Resolving endpoints for service \u0027{ServiceName}\u0027."}
{"@timestamp":"2024-06-13T08:39:05.4832113+10:00","log.level":"Debug","message":"No valid endpoint configuration was found for service \u0027localhost\u0027 from path \u0027Services:localhost\u0027.","log":{"logger":"Microsoft.Extensions.ServiceDiscovery.Configuration.ConfigurationServiceEndpointProvider"},"labels":{"Path":"Services:localhost","EventName":"ServiceConfigurationNotFound"},"event":{"code":"3","created":"2024-06-13T08:39:05.4832113+10:00","severity":7,"timezone":"AUS Eastern Standard Time"},"service":{"name":"localhost","node.name":"","version":"2.3.1-beta-241610955\u002B81e61e0e20f6b035dc1bb7e4e91442759b37c0b3"},"metadata":{"EventId":3},"MessageTemplate":"No valid endpoint configuration was found for service \u0027{ServiceName}\u0027 from path \u0027{Path}\u0027."}
{"@timestamp":"2024-06-13T08:39:05.493175+10:00","log.level":"Debug","message":"No valid endpoint configuration was found for service \u0027localhost\u0027 from path \u0027Services:localhost\u0027.","log":{"logger":"Microsoft.Extensions.ServiceDiscovery.Configuration.ConfigurationServiceEndpointProvider"},"labels":{"Path":"Services:localhost","EventName":"ServiceConfigurationNotFound"},"event":{"code":"3","created":"2024-06-13T08:39:05.493175+10:00","severity":7,"timezone":"AUS Eastern Standard Time"},"service":{"name":"localhost","node.name":"","version":"2.3.1-beta-241610955\u002B81e61e0e20f6b035dc1bb7e4e91442759b37c0b3"},"metadata":{"EventId":3},"MessageTemplate":"No valid endpoint configuration was found for service \u0027{ServiceName}\u0027 from path \u0027{Path}\u0027."}
{"@timestamp":"2024-06-13T08:39:05.493175+10:00","log.level":"Debug","message":"Using pass-through service endpoint provider for service \u0027http://localhost:8761\u0027.","log":{"logger":"Microsoft.Extensions.ServiceDiscovery.PassThrough.PassThroughServiceEndpointProvider"},"labels":{"EventName":"UsingPassThrough"},"event":{"code":"1","created":"2024-06-13T08:39:05.493175+10:00","severity":7,"timezone":"AUS Eastern Standard Time"},"service":{"name":"http://localhost:8761","node.name":"","version":"2.3.1-beta-241610955\u002B81e61e0e20f6b035dc1bb7e4e91442759b37c0b3"},"metadata":{"EventId":1},"MessageTemplate":"Using pass-through service endpoint provider for service \u0027{ServiceName}\u0027."}
{"@timestamp":"2024-06-13T08:39:05.5097284+10:00","log.level":"Debug","message":"Resolved 1 endpoints for service \u0027http://localhost:8761\u0027: localhost:8761 (Pass-through).","log":{"logger":"Microsoft.Extensions.ServiceDiscovery.ServiceEndpointWatcher"},"labels":{"Endpoints":"localhost:8761 (Pass-through)","EventName":"ResolutionSucceeded"},"event":{"code":"3","created":"2024-06-13T08:39:05.5097284+10:00","severity":7,"timezone":"AUS Eastern Standard Time"},"service":{"name":"http://localhost:8761","node.name":"","version":"2.3.1-beta-241610955\u002B81e61e0e20f6b035dc1bb7e4e91442759b37c0b3"},"metadata":{"Count":1,"EventId":3},"MessageTemplate":"Resolved {Count} endpoints for service \u0027{ServiceName}\u0027: {Endpoints}."}

an activity should be being created so that it is easy to associate the "Resolving endpoints for service " to the final message which indicates it has been resolved via pass through "Resolved 1 endpoints for service \u0027http://localhost:8761\u0027: localhost:8761 (Pass-through)."

mitchdenny commented 2 weeks ago

adding @ReubenBond and @JamesNK given it spans service discovery and telemetry.