Using the Developer Dashboard
Published: May 2010
The Developer Dashboard is an instrumentation framework introduced in Microsoft SharePoint Foundation 2010. Similar in concept to ASP.NET page tracing, it provides diagnostic information that can help a developer or system administrator troubleshoot problems with page components that would otherwise be very difficult to isolate. For example, a developer can easily introduce extra SPSite or SPWeb objects into his or her code unknowingly or add extraneous SQL Server queries.
In the past, the only way to debug performance problems caused by the extra overhead of these instances in code would be to attach a debugger to the code and monitor SQL Server Profiler traces. With the Developer Dashboard, a developer can identify this type of problem, either programmatically by using the object model or visually by looking at page output.
Although performance issues and resource usage information is available in the Unified Logging Service (ULS) logs, interpreting the raw data can be very time consuming. With the Developer Dashboard, all the related information is correlated, which makes identifying these types of issues much easier.
Developer Dashboard contains an extensible mechanism for measuring various performance counters at various scopes. Within Developer Dashboard, the following performance counters are used to monitor usage and resource consumption at each stage of the requests.
These counters measure values for the current request or timer job:
Thread execution time
Number, duration, call stack information and query text of each SQL Server query generated by the page
Number, duration, and call stack information of each WCF call
URL or timer job name
Execution start time
Any of the preceding statistics for code enclosed by SPMonitoredScope (see Using SPMonitoredScope)
The preceding data is output to two locations at the end of every request or timer job:
ULS log — All collected statistics for a specified scope are always logged to the ULS log.
Developer Dashboard — Performance statistics for a request are available in the browser window.
The Developer Dashboard can be displayed in the following modes:
When enabled in On mode, the Dashboard is viewable on all pages that use the default master page.
When the Developer Dashboard is set to OnDemand mode, an icon is displayed on the top right side of the page. This icon allows the user to toggle the Dashboard on and off.
It is important to note that when the display mode is set to OnDemand, anyone who has rights to view the page will also be able to see the Dashboard output.
The Developer Dashboard is always off by default. To make it viewable, you must enable it, by using STSADM, Windows PowerShell cmdlets, or the SharePoint Foundation object model.
Open a command window to the %ProgramFiles%\Common Files\Microsoft Shared Debug\Web Server Extensions\14\BIN directory and enter one of the following commands, depending on the desired display mode.
stsadm -o setproperty -pn developer-dashboard -pv on
stsadm -o setproperty -pn developer-dashboard -pv ondemand
Using Windows PowerShell Cmdlets
(Get-SPFarm).PerformanceMonitor.DeveloperDashboardLevel = ”On”
(Get-SPFarm).PerformanceMonitor.DeveloperDashboardLevel = ”OnDemand”
Two components are required for the Dashboard to display. These include the Developer Dashboard Launcher and the page rendering control that renders the output to the page.
Developer Dashboard Launcher
When the display mode is set to OnDemand, the Launcher displays the launcher icon. It can be used anywhere on the page. The following example shows the markup necessary to include the Launcher on a master page.
Page Rendering Control.
The rendering control must located be at the bottom of the page markup. Any controls on the page that fall below the rendering control will not have their metrics reported to the Developer Dashboard.
With the introduction of the SPMonitoredScope class, a developer has the ability to ”wrap” code and have the usage statistics for that code displayed on the screen. This information can be used to identify potential points of failure or, at the very least, components that are not performing as expected.