-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Call AddMetrics inside AddRouting #50168
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
Conversation
var services = new ServiceCollection(); | ||
services.AddLogging(); | ||
services.AddOptions(); | ||
services.AddSingleton<DiagnosticListener>(s => new DiagnosticListener("Test")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sebastienros UseRouting requires DiagnosticListener
in DI, but I don't see that in OC source code. I'm confused how it worked before.
@Tratcher Multiple calls to AddMetrics has uncovered a problem with some changes you made to |
Blocked on dotnet/runtime#90779, which causes test failures in ASP.NET Core.
We might struggle to get both fixes into rc1 on time. |
This PR doesn't seem critical for RC1, it's an uncommon issue with an easy workaround. I'll look into the other issue today. |
79ec039
to
ff64647
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks @JamesNK!
Routing now uses metrics. The meter and counters are created using
IMeterFactory
.IMeterFactory
is a new type and an implementation is registered by callingAddMetrics()
.AddMetrics()
is called by host builders.However, this breaks if someone creates an app without using a host builder. They will get an error that
IMeterFactory
can't be resolved. Orchard Core doesn't use one of our built-in host builders and runs into this problem: https://github.com/OrchardCMS/OrchardCore/blob/fa03f92536de065c87f780ae27b277cce6d2d656/src/OrchardCore/OrchardCore/Modules/Extensions/ServiceCollectionExtensions.cs#L92. This is probably a rare situation.Fix this issue by calling
AddMetrics()
insideAddRouting()
so anIMeterFactory
is always present. If the host already added metrics then the extra add inside routing doesn't have any impact.