Permalink
Browse files

Added total topics performance counter.

  • Loading branch information...
1 parent 56359d0 commit ece78b804cf44a7348560d403282e77832ae9164 @davidfowl davidfowl committed Dec 19, 2012
View
5 src/Microsoft.AspNet.SignalR.Core/Infrastructure/IPerformanceCounterManager.cs
@@ -93,6 +93,11 @@ public interface IPerformanceCounterManager
IPerformanceCounter MessageBusBusyWorkers { get; }
/// <summary>
+ /// Gets the performance counter representing the number of topics in the message bus.
+ /// </summary>
+ IPerformanceCounter MessageBusTotalTopics { get; }
+
+ /// <summary>
/// Gets the performance counter representing the total number of all errors processed since the application was started.
/// </summary>
IPerformanceCounter ErrorsAllTotal { get; }
View
6 src/Microsoft.AspNet.SignalR.Core/Infrastructure/PerformanceCounterManager.cs
@@ -123,6 +123,12 @@ public PerformanceCounterManager()
public IPerformanceCounter MessageBusBusyWorkers { get; private set; }
/// <summary>
+ /// Gets the performance counter representing the number of topics in the message bus.
+ /// </summary>
+ [PerformanceCounter(Name = "Message Bus Total Topics", Description = "The number of topics in the message bus.", CounterType = PerformanceCounterType.NumberOfItems32)]
+ public IPerformanceCounter MessageBusTotalTopics { get; private set; }
+
+ /// <summary>
/// Gets the performance counter representing the total number of all errors processed since the application was started.
/// </summary>
[PerformanceCounter(Name = "Errors: All Total", Description = "The total number of all errors processed since the application was started.", CounterType = PerformanceCounterType.NumberOfItems32)]
View
5 src/Microsoft.AspNet.SignalR.Core/MessageBus/MessageBus.cs
@@ -311,6 +311,9 @@ private void ScheduleTopic(Topic topic)
/// <returns>A <see cref="Topic"/> for the specified key.</returns>
protected virtual Topic CreateTopic(string key)
{
+ // REVIEW: This can be called multiple times, should we guard against it?
+ Counters.MessageBusTotalTopics.Increment();
+
return new Topic(_messageStoreSize, _topicTtl);
}
@@ -368,6 +371,8 @@ internal void GarbageCollectTopics()
Topics.TryRemove(pair.Key, out topic);
_stringMinifier.RemoveUnminified(pair.Key);
+ Counters.MessageBusTotalTopics.Decrement();
+
Trace.TraceInformation("RemoveTopic(" + pair.Key + ")");
if (AfterTopicGarbageCollected != null)

0 comments on commit ece78b8

Please sign in to comment.