Kentico / xperience-by-kentico-miniprofiler

MIT License
2 stars 0 forks source link

Feature Request: Show debugging information for SQL queries #10

Open ChristopherBass opened 1 month ago

ChristopherBass commented 1 month ago

A very useful feature Kentico 13 had was SQL debugging - the ability to review a page load and see what specific SQL queries were run, and how long they took (including highlighting long-running queries).

This helped with determining if our caching was working (if the queries don't run and the data still shows up, the cache succeeded) - it also helped with performance-tuning queries and detecting when devs didn't apply proper filters/paging to queries (by viewing the result count).

Miniprofiler appears to be able to do that, judging by https://miniprofiler.com/dotnet/ and https://docs.servicestack.net/built-in-profiling#sql-profiling (The latter is a third-party service and is using the MVC (not core) version of Miniprofiler, but both links show screenshots of Miniprofiler being used in the way I'm imagining)

Currently I don't believe the Kentico Miniprofiler implementation (Or XbyK internally) gives any insight into SQL queries at all, so anything would be an improvement.

liparova commented 3 weeks ago

Thank you for highlighting this request. We will review it internally and keep you informed of any developments.

seangwright commented 3 weeks ago

@ChristopherBass are you sure you tried out this integration? SQL debugging is the main feature of adding MiniProfiler to Xperience.

Here's what it looks like when enabled in the Kentico Community Portal

image

If you click on the "sql" column for the one of the results, it will show all the SQL queries run within that part of the call stack.

image

ChristopherBass commented 3 weeks ago

I don't see how that could be the case, unless you're running a newer version somehow?

This is XbyK version 29.0.1

I ran dotnet add package Kentico.Xperience.MiniProfiler. That added Kentico.Xperience.MiniProfiler version 1.0.0 to my website.csproj. Program.zip

Attached is my program.cs, with calls to AddKenticoMiniProfiler and UseMiniProfiler in there.

And here is my profile results 2024-06-10 09_01_26-Home

ChristopherBass commented 3 weeks ago

I also reproduced this in 29.1.3 on Dancing Goat (updated to .net 8) Program.zip 2024-06-10 10_18_16-Home - Dancing Goat

ChristopherBass commented 3 weeks ago

Comparing projects with Sean Wright, I think this is just a documentation fix.

The documentation just says to put the 'AddKenticoMiniProfiler' call in your program.cs

and gives this as guidance:

var env = builder.Environment;

if (env.IsDevelopment())
{
    builder.Services.AddKenticoMiniProfiler();
}

// Other services ...

But if you put it before the builder.Services.AddKentico(), then you get the non-SQL version. It's possible AddKentico is touching the sql in a way that's kicking the profiler off of the SqlConnection, but in either case, as long as you add it after AddKentico() it seems to work as designed.