MiniProfiler / dotnet

A simple but effective mini-profiler for ASP.NET (and Core) websites
https://miniprofiler.com/dotnet/
MIT License
2.9k stars 598 forks source link

Blazor support #441

Open RemiBou opened 4 years ago

RemiBou commented 4 years ago

Hi,

I would like to work on Blazor support for miniprofiler. Before anything : are you interested by this ? I can work on my side but it might be better here.

Here are the thing I would like to do

If this fit in this repo : do you think I should translate all the typescript code to blazor ? It'll force the repo to maintain 2 version (ts and razor) but it'll remove any need for jquery.

What do you think ?

NickCraver commented 4 years ago

Hey there! I appreciate the interest for sure :)

I'm not sure translating the client-size to Blazor makes much sense - the current UI can be rendered in Blazor since it can run the current script, we may be missing a few bits to rig it up (some extensibility) but that shouldn't be a huge change. By contrast, moving the client to Blazor for everyone would be extremely heavy, going from ~45KB of payloads sent to the client to many megabytes (Blazor has a huge base cost).

I think the appropriate path here is to run the JavaScript in a Blazor call, just need to hook up the piping - and much more interesting possibly is running the profiler itself in Blazor and rendering there for client-side things - I think there's a lot we can do there.

On the side: I'm not against removing jQuery as a dependency at this point (dropping support for Internet Explorer 11 basically), but that should be separate fro the Blazor bits. I planned to maybe tinker on this over the holiday breaks here. It'd use raw browser APIs instead - we're just not doing that much, so I want to see what it's like and what the payload/complexity wins are...I am not convinced (until doing it) that it's necessarily the right path. Need to explore to find out.

RemiBou commented 4 years ago

All right. I'll create a jsInterop wrapper around miniprofiler and add profiling in blazor.

The jQuery removal can be done in a totally different project.

NickCraver commented 4 years ago

I got bored and am tinkering with #442 - it's totally unrelated to Blazor but something I wanted to try and this was motivation. I'm going to diff and see what IE 11 will take later, just wanted to give a heads up: jQuery removal won't affect the overall API here, it's all internal.

RemiBou commented 4 years ago

I have a POC (https://github.com/RemiBou/dotnet) :

My problem being that we need to create Profiler by hand because I can't find a good way for creating Profiler :

I think my only solution would be to create a new MiniProfiler extension method that would create the profiler if none available, and close it when the root timing is closed.

Maybe you have an idea or a suggestion about which way I should go.

RemiBou commented 4 years ago

@NickCraver I have a better idea : instead of trying (fighting) to find sowehere where I can create a profiler, I'll add a button "Start Profiler" and "Stop Profiler" to the UI.

RemiBou commented 4 years ago

@NickCraver I managed to do some work on this (https://github.com/RemiBou/dotnet, there is sample), so far :

Here is my todo list : https://trello.com/b/455mSgsl/miniprofilerblazor.

The problem I met :

Now I have a question : should I move forward ? There is already profiling tools in the browser and I can create API (like here with the Time API) that will push information to these tools.

Do you think there is any added value in my work ?

Bouke commented 1 year ago

I'd be interested in better support for Blazor Server. Currently everything done within Blazor is logged in a single session /_blazor with a duration of however long that Blazor session took. It doesn't give me any details to investigate which database queries were in response to what action was performed, or component lifecycle events. Blazor Server is quite different from your traditional request/response messaging, as it more closely resembles a client-server model. I'm not familiar enough with the Blazor code to identify hooks that could be hooked into (if any?). Ideally the profiling report would show a breakdown per user-action, similar to the request/response model.

alexandrejobin commented 11 months ago

Is there any news about Blazor support? I miss so much MiniProfiler since we have decided to go Blazor Server!