SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

my code:

using (new SPMonitoredScope("Sleepy Time", 1000)) {

when I enable the Developer Dashboard, I am expecting a red border around it because the code running in the monitored scope is running longer than 1000 milliseconds.

But it doesn't happen. I do get a bullet point in the Developer Dashboard such as

  • Sleepy Time (5008.26 ms)

but no indication that the counter was triggered. Can anyone explain why?

share|improve this question

DD only show you the standard events called by SharePoint. Eg OnPreRender, CreateChildControls etc.

If you want to add monitors to a web part, you would need to create a method like this

private void SleepyTime()
    using (SPMonitoredScope scope = new SPMonitoredScope("SleepyTime"))

and it would show up in DD from the overridden event from which the method was called CreateChildControls (50xx ms) - SleepyTime (5000 ms)

Note that the code above wont run in a sandboxed solution!

You can also create a custom monitored scope using the ISPScopedPerformanceMonitor interface. This is used in conjunction with an overridden constructor

int maxExecutionTime = 1000; // The maximum duration of the monitoring operation, in milliseconds
using (SPMonitoredScope scope = new SPMonitoredScope("SleepyTime", maxExecutionTime, new MyCustomMonitor()))
    // MyCustomMonitor implements ISPScopedPerformanceMonitor interface
    // If monitoring the scope exceeds the time represented by the maximumExecutionTime value, you can use the maximumExecutionTime value to increase the logging level.
share|improve this answer

The red border is only triggered by SharePoint defined monitors at the root scope. A yellow border should indicate that the request took more than one second.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.