Orchard Harvest 2015 – Orchard Telemetry with Glimpse
Bede Gaming is an online casino gaming company that is built entirely on Orchard. As such, they need to be able to debug a lot of Orchard code as fast as possible. For that, they use Glimpse a lot. Glimpse is a Firebug-like tool for debugging server code.
Out of the box, Glimpse gives you is a timeline, that looks like the network tab in browser developer tools. This is extremely useful to see where time is being spent. Think of it as lightweight profiling. The execution tab does more profiling by showing all method calls, with their aggregated execution times. The routes tab shows what routes exist on the system, and which one was selected and why. The SQL tab shows all the SQL queries being executed, which is extremely useful in Orchard (it does most of what mini-profiler can do). The trace tab allows you to see log entries corresponding to the current request.
Glimpse is an extensible platform however, and it’s easy to add more Orchard-specific tabs. In his demo, Chris showed how to build a “cache service” tab that shows cache hits and misses, and integrates into the base timeline tab.
Chris Payne built a couple of interesting interfaces to facilitate Glimpse integration: IGlimpseService, and IDecorator<>. IDecorator is generally useful and should definitely make its way into Orchard. It’s a way to decorate a service with additional behavior instead of suppressing dependencies and then calling a specific implementation. It includes the decorated service as an injected dependency, which makes it possible to add behavior and call into the decorated implementation without having to know what exactly it is. How did we not think of that?
With IDecorator, Chris was able to decorate ICacheService and make it publish Glimpse messages every time the caching API gets hit.
What I really like about this approach is that Chris built the right abstractions, so that it is easy for Orchard developers to add their own debugging and diagnostics information into Glimpse with just a few lines of code. This is very Orchardy, even more so probably than our old diagnostics tools, which really are a fixed set of features. I can see how unifying the current debug console and Glimpse would make a lot of sense, refactoring everything as Glimpse tabs. This is something we’ve talked about before, but never did. This talk is giving a really good incentive, and a set of tools, to achieve it. There will be a lot of benefits, not the least of which being that the Glimpse shell is much better polished than our own.
Other tabs that they’ve built include a content management tab that shows the content items involved in building the current page, a shape tab that shows shapes and alternates, and layer and widgets tabs that show the layers and widgets that are currently active or not. They have also built custom tabs that show information specific to their business, such as an external API request tab. Almost all custom tabs have a very handy “edit” link next to each content item that appears in the tabs, and that takes you directly to the editor.
Chris showed how using his Glimpse tooling, he discovered and fixed a SELECT N+1 issue in the Orchard widget and layers code. His pull request was accepted live, during the session, which is pretty impressive. This emphasizes how better tooling directly leads to better code.
They are aggregating the data gathered into NewRelic to generate reports that clearly show where to focus to improve performance.
And this is all available on GitHub: look for his branches under https://github.com/paynecrl97/Orchard
UPDATE: the video is online.