Open NinoFloris opened 5 years ago
I'm not sure what's being asked for here - what sort of method are you looking for? Pretend I'm stupid about the non-MVC use case :)
Any update here?
Sorry this one slipped my view!
One that'll just enable the middleware level services. I'll attach what we enable in a bit
Not sure which extensions we're after here still, so let me know please :)
Yes we're using this as a minimal setup for middleware only
public class MiniProfilerOptionsDefaults: IConfigureOptions<MiniProfilerOptions>
{
private IMemoryCache _cache;
public MiniProfilerOptionsDefaults(IMemoryCache cache)
{
_cache = cache;
}
public void Configure(MiniProfilerOptions options)
{
if (options.Storage == null)
options.Storage = new MemoryCacheStorage(_cache, TimeSpan.FromMinutes(60.0));
}
}
/// services
services.AddMemoryCache()
services.AddSingleton<IConfigureOptions<MiniProfilerOptions>, MiniProfilerOptionsDefaults>()
services.Configure<MiniProfilerOptions>(o => // some config of MiniProfiler )
// middleware
app.UseMiniProfiler()
Gotcha - so you want to profile the overall request but not actions or views in said profiles? If so, why?
I'm having trouble picturing the use case here. I'm not sure if adding a more minimal .Add*
here makes sense, but if I understood the use case more than it might.
We don't use MVC 🙃 , we're interested in request and per request provider profiles (EFCore, pg). With our migration to endpoint routing in 3.0 we can add routing information without MVC as well
Ah gotcha! What would be a good pattern here do you think? I think MVC by default is still correct for most people. But due to ordering, I can't reliably detect it and swap it automatically. What about an optional arg, something like:
services.AddMiniProfiler(includeMvc: false);
...or something like that?
That may be fine actually :) With framework references containing MVC anyway the dependency on it isn't really a problem, so that's good.
We're looking at this for Stack Overflow's ASP.NET Core port now (and seeing what fun there is in the migration at mass scale)...will report back and update on what solutions we find since it may adjust services and built-in options here a bit. Sorry for the delay, we for held up on some side work and thought I'd be to this in prod for SO by now.
I would imagine fixing this would mean breaking this out into two methods?
https://github.com/MiniProfiler/dotnet/blob/master/src/MiniProfiler.AspNetCore.Mvc/MvcExtensions.cs#L22