Tuesday, May 4, 2010

Developer Dashboard in SharePoint 2010

What is developer dashboard:
SharePoint is very big system and consists of so many modules integrated. We can do lot of customization and all our code will be deployed to SharePoint and end users will use it. But, what if client comes to you with the question, "why my SharePoint site is loading very slow?" How you proceed?
First thing you need to check is all server configurations like is memory is sufficient/ Processor is sufficient etc.. After you found they are more than enough, now it's time to find problem in the code. Till SharePoint 2007, it's very difficult to find which part of the code is taking how much time and analyze it better. But luckily in SharePoint 2010, Microsoft added a very nice feature for developers to detect which module is taking how much time. It will record all the requests and the time to get response etc.... This is what we are calling Developer Dashboard.

The great advantatge with it is, it will differ the requests and show like, database queries [Which query took how much time], SPRequest allocation, Webpart event offsets, etc in very detailed way. I really love it. Thanks a ton to SharePoint 2010 team.

The developer dashboard records and display performance statistics of the related code that executed to produce current page.

How to enable/disable it on the specific site?
Method 1:  [STSADM]
'On' Mode :
STSADM –o setproperty –pn developer-dashboard –pv On

'Off' Mode:
STSADM –o setproperty –pn developer-dashboard –pv Off

'OnDemand' Mode:
STSADM –o setproperty –pn developer-dashboard –pv OnDemand

Suppose you'd like to only display the developer dashboard if one or more acceptable values are exceeded, there's a way to do that too by running:
STSADM –o setproperty –pn developer-dashboard –pv expensiveoperationsonly

Once you executed the command the output is "Operation executed successfully."

Method 2: Windows Powershell script:
You need to open the windows power shell prompt and copy the below script and hit enter.
$DevDashboardSettings = [Microsoft.SharePoint.Administration.SPWebService]::ContentService.DeveloperDashboardSettings;
$DevDashboardSettings.DisplayLevel = 'OnDemand';
$DevDashboardSettings.RequiredPermissions = 'EmptyMask';
$DevDashboardSettings.TraceEnabled = $true;
$DevDashboardsettings.Update();

The both above methods will enable developer dashboard to entire farm level.

UPDATED**
"DevDashboardSettings.RequiredPermissions determines which users will see the developer dashboard. EmptyMask means all users will be able to access developer dashboard. Any mask available in SPBasePermissions object can be used to filter down to a specific group so that only a small subset of users will be able to access developer dashboard."

Now, when you browse to the web site you can't find it immediately on the screen. You need explicitly enable for the page. Find a small image at the corner of the page as shown below.
That image behaves as a toggle button. When you click very first time then the developer dashboard will be enabled for the specific page. When you click again, then it will go off. You can't see that until you click it again.
How it looks like:

Note: This option is page specific level. So, when you enable it and move to another page it's default state is closed/disabled.

11 comments:

  1. Hi,

    I am using Developer dashboard in SP2010. But I could not see it on the pages which are created based on page layouts that we acreted and applied different masterpages.

    As far as I could observe, I can only see that on the application pages. Is there anything that I am missing.

    Thanks In Advance for any help

    ReplyDelete
  2. Hi there,
    Make sure you have used the code for getting the dashboard launcher in your custom page layout or master page. This is part of the SPRibbon and if your ribbon is customized and didn't have the dashboard tag, then it won't render on the page. The related code for Dashboard launcher is here.

    <SharePoint:DelegateControl ControlId="GlobalSiteLink2" ID="GlobalDelegate2" Scope="Farm" runat="server" />
    <span>
    <span class="s4-devdashboard">
    <Sharepoint:DeveloperDashboardLauncher
    ID="DeveloperDashboardLauncher"
    NavigateUrl="javascript:ToggleDeveloperDashboard()"
    runat="server"
    ImageUrl="/_layouts/images/fgimg.png"
    Text="<%$Resources:wss,multipages_launchdevdashalt_text%>"
    OffsetX=0
    OffsetY=222
    Height=16
    Width=16 />
    </span>
    </span>

    This is part of SPRibbonPeripheralContent. So, make sure your layout or master page ribbon tag has this.

    ReplyDelete
  3. Hi,

    Many thanks.
    I didn't customized the ribbon. But the masterpage and pagelayouts yes.

    If I put the code that you suggested on masterpage, will that workas per the security the user has.

    I enabled it as onDemand feature, so will it be viewable only for admins? Is there a way to control the visibility by using permissions?

    ReplyDelete
  4. Hi there,
    We need to use the shell script code to give or manage permissions.
    Please check the code below.
    $DevDashboardSettings = [Microsoft.SharePoint.Administration.SPWebService]::ContentService.DeveloperDashboardSettings;

    $DevDashboardSettings.DisplayLevel = 'OnDemand';

    $DevDashboardSettings.RequiredPermissions = 'EmptyMask';

    $DevDashboardSettings.TraceEnabled = $true;

    $DevDashboardsettings.Update();


    "DevDashboardSettings.RequiredPermissions determines which users will see the developer dashboard. EmptyMask means all users will be able to access developer dashboard. Any mask available in SPBasePermissions object can be used to filter down to a specific group so that only a small subset of users will be able to access developer dashboard."

    Let me know, if you need any more help!!!

    ReplyDelete
  5. Wonderful.. I am looking over internet for the security in developer dashboard.. Thanks a ton

    ReplyDelete
  6. HI

    Your post regarding the developer dashboard really helped me in getting the same. I thank you very much for that .. I have doubt that is STSADM command is still working in SP 2010. Bcos I used that command and the message came as "This command is obselute" . Kindly explain this one..

    ReplyDelete
  7. Hi Karthik,
    Good to know post helped you. Yes. STSADM command is available in SP 2010 and the term obsolete means - No longer in use. Because they have replaced that tool with Windows Power Shell Script in SP 2010. You can still use STSADM tool, but, that is too old to use in SP 2010. Got it?

    ReplyDelete
  8. Hi,

    I recently came across your blog and have been reading along. I thought I would leave my first comment. I don't know what to say except that I have enjoyed reading.

    Nice blog. I will keep visiting this blog very often.

    -
    Custom Dynamics GP

    ReplyDelete
  9. You need to make sure that Developer Dashboard control is present in your master page near the end of the page. If this control is not present then dashboard won't show up.

    ReplyDelete
  10. Hi Praveen,

    Iam learning SharePoint2010 in Hyderabad.As a fresher this blog helps me a lot and thanks a ton to your patience for explaining concepts with Questions.Please suggest me, which books and where can i get useful information .
    VEERU YADAV

    ReplyDelete
  11. Thank you for the post! Trying it figure out what all the information I have now means. I have over 50 SPWeb: http://sharepoint
    and a good # maybe around the same, or less for proc_GetTpWebMetaDataAndListMetaData

    ReplyDelete