If you're not using Glimpse with ASP.NET for debugging and profiling, you're missing out
I've blogged about Glimpse since the day I first saw it at Mix 2011's open source fest. It's popular, but frankly, Glimpse is so useful more people need to know about it.
From within your ASP.NET application in Visual Studio, install Glimpse using NuGet. You'll want to install the right Glimpse packages for the ASP.NET features you're using. For example, I'm using MVC4 and Entity Framework 5, so I will use NuGet and:
install-package Glimpse.MVC4
install-package Glimpse.EF5
These packages pull in the core Glimpse libraries plus the hooks for the specific ASP.NET modules and handlers needed for Glimpse to collect all the information about your application and present it to the client side. Be sure to pick the right NuGet packages for your project type.
- Core: Glimpse
- ASP.NET Core: Glimpse ASP.NET
- Specific ASP.NET Framework: Glimpse MVC2, Glimpse MVC3, Glimpse MVC4
- Database: Glimpse ADO, Glimpse EF 4.3, Glimpse EF 5, Glimpse EF 6
The releases of Glimpse 1.4.0, and now most recently 1.5.0 improve Glimpse with the addition of a really amazing HUD (Heads Up Display). As you hover over each segment, it pops up with lots of details about the HTTP request, AJAX requests, deep inspection database interactions, and lots more.
Here I've hovered over one segment and you can see the time it took to render this first page, and exactly how much time was spent during each activity, from rendering to action methods to database connections.
You can move from the HUD to the standard Glimpse view. The best part is that each Glimpse Tab is a plugin itself! There's a whole community creating Glimpse Plugins. If you're using RavenDB, or NHibernate, or SignalR or whatever, you can get introspection into what's going on in a Glimpse Tab.
You turn Glimpse on and off with cookies, and you can setup security policy however you want. Glimpse isn't in the background creeping around - you have absolute control over when you want it used. Perhaps local and only when debugging, or perhaps always and with a specific cookie value, it's up to you.
Below you can see the actual SQL query executed by my Entity Framework code and how long it took to execute. I didn't have to change any part of my code or do anything more than just install Glimpse. Glimpse added the modules and handlers, and Glimpse policies can be installed to turn Glimpse on or off based on any option I can think of. I can even put Glimpse into production and only turn it on for certain requests, giving me a profiling tool I can peek at whenever I like.
You likely use F12 developer tools in Chrome, IE and Firefox, and you've seen Timeline views before. But remember that Glimpse is JavaScript and HTML on the client - it's NOT a browser plugin - and it's a series of plugins on the server that give you a holistic view that's way more than just what's visible on the client.
Glimpse's Timeline View shows you exactly what's happening on the server, how long it's taking, and how it all fits together.
Sessions within Glimpse are all tracked and be optionally named. Since the server is collecting what's going on, you can pull out a popup browser window of Glimpse and connect to sessions from other browsers. Below I'm using an iPhone mobile emulator from ElectricPlum and inspecting requests from another browser window.
Glimpse is all open source and under the Apache 2.0 license. You can certainly help out, but the most interesting thing in my opinion is writing Glimpse Tabs - extending Glimpse to collect and show new data. Tabs can show technical stuff, but even business stuff that's specific to your application or style of application. For example, the Umbraco CMS could make a Glimpse Tab that puts configuration or technical Umbraco specific details up front. A line of business app could show tax details or shopping cart contents.
Glimpse is so useful that it's the first thing I install after I File | New Project on any non-trivial thing I'm working on. It's replaced Mini-Profiler as my go-to "production profiler" for web apps, and if you use ELMAH to collect and manage your application errors, there's even a Glimpse ELMAH plugin!
Check it out and go talk to Anthony and Nik about Glimpse on Twitter and thank for their work!
DISCLOSURE NOTE: The Red Gate company sponsors the Glimpse open source project. Red Gate also sponsored my blog feed this week. That is a cool coincidence, but it's just a coincidence. Red Gate does a lot of stuff. This post about Glimpse was written earlier. Just an FYI for y'all.
Sponsor: Big thanks to the folks at Red Gate for sponsoring the feed this week. Take a moment and check out their free download of Deployment Manager! Easy release management: Deploy your .NET apps, services and SQL Server databases in a single, repeatable process with Red Gate’s Deployment Manager. There’s a free Starter edition, so get started now!
About Scott
Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.
About Newsletter
https://github.com/Glimpse/Glimpse/issues/344
Uninstalling right after 5 minutes again. Sad :-(
Cannot add duplicate collection entry of type 'add' with unique key attribute 'name' set to 'Glimpse'
I had to do a little web.config hacking. In the system.webserver section add a remove name="Glimpse" in the modules and handlers areas before it would work.
Ive plugged it straight into an MVC4 project I am working on and the information in provides is so valuable.
How do you find out about all these tools?
Are you aware of any similar tool(s) but for WPF applications?
It woukd appear that the guys that developed FriendlyUrls are going against the spirit of openness in Asp.Net by sealing it, making it closed source, and causing the issue that Uwe reported. Please hassle them so that more devs can use the goodness of Glimpse.
I also have been using your MVCScaffolding project and have been able to modify the templates for my purposes. I found the tool extremely useful as a starting place getting into EF, repositories, and asp.net mvc in general. Thanks again for sharing that code. :)
http://www.nuget.org/packages/MVCScaffolding/
I don't see something equivalent with Glimpse.
https://github.com/Glimpse/Glimpse/issues/344
@FriendlyUrlRoute We are looking to see what we can do here so it doesn't break out of the box. Within the next week we should have something that fixes this up. Watch the blog for more details - http://blog.getglimpse.com/
@Ubikuity We don't currently have a WCF component. Its not that its rocket science but we have been going where the community points us and todate, WCF hasn't been a priority. If you could go to the issues list and raise support there we might be able to get something rolling. You might also be interested in this one - https://github.com/Glimpse/Glimpse/issues/337.
@NickPortelli We do replace the arguments in the SQL tab with the values of the argument. The intent is to make it easy to be able to copy out and put into SSMS. See here as an example - http://raw.github.com/wiki/Glimpse/Glimpse/images/sqlTab.png. If you aren't seeing this in your code, then we will need to take a look at it. By default there is no way to get particular ajax calls ignored (didn't think of that use case) but its a great idea. If you want to add to the issues list, let see if we can get it in.
@Everyone Thanks for the positive feedback and support.
We are working with the ASP.NET team to figure out the best solution for the FriendlyUrl problem. Please keep an eye on on this issue for the most up to date information.
@Nick Portelli - please submit an issue on GitHub describing the feature you'd like. It will most likely be added!
Thanks,
After installing glimpse ,it seems the app is unable to recognize the send property of email Class ?
Any ideas ?
Keep getting this error:
Unable to cast object of type 'Glimpse.Ado.AlternateType.GlimpseDbConnection' to type 'System.Data.SqlClient.SqlConnection'
Even after following the documentation to initialize Ado and EF in Application Start.
It looks nice though.
Sri - we're not familiar with Postal. Could you describe your issue on StackOverflow and we'll help you out. Just be sure to use the 'glimpse' tag.
Richard and Balajj - open these as issues on GitHub and we'll track down the problem.
Thanks,
Nik
Is this because it's Web Forms? I guess I'd better play around more, with an MVC (or even a brand new Web Forms) project to see if Glimpse is capable of showing all the stuff I was expecting.
At this point, Glimpse certainly provides more diagnostics information for MVC than WebForms. We are continually working to improve the WebForms story - and would love to hear your ideas. Feel free to reach out to us on GitHub and we'll work through this together.
In IE10, with compatibility-mode = 'on', java script error whenever Glimpse Turned on.
I have some stuff that works only with IE Comapatibility-mode='on'.
Thanks in advance,
Ramesh
Its great and useful.
Eager to see the results.
Just finished installing it.
I tried Glimpse MVC 3. It ran successfully with my MVC 3 application and I was amazed with the level of details it provided.
Later when I decided to uninstall it using nuget, it messed up all config files. I had to do a manual cleaning of the config files, browser cache and cleared "Temporary ASP.NET Files" folder then only I was able to run the application successfully again.
Please let me know is there any graceful way of uninstalling the nuget Glimpse and clearing config files.
Regards,
Soumen Banerjee
@TwitToSoumen
I installed and checked this tool with existing application. It is awesome one and display is very good. Thanks for sharing this.
I think such tools increase the quality of the code in the development phase because it gives the programmer to get clear insights about how to optimize his/her code.
Thanks for sharing.
Comments are closed.
Fingers crossed that even more devs start using it!