Quantcast
Channel: Service Bus forum
Viewing all articles
Browse latest Browse all 1916

How to use custom performance counters to monitor my app?

$
0
0

Hi,

I have a app which will read messages from a specified service bus queue. I want to monitor how many messages it read from service bus queue in the last minutes. And I want to use a custom performance counter to achieve that.

Then I first initialized the PerformanceCounterCategory by the following code:

            var counterCreationData = new CounterCreationData
            {
                CounterName = "numberOfMessages",
                CounterHelp = "help",
                CounterType = PerformanceCounterType.NumberOfItems32
            };

            var counterCollection = new CounterCreationDataCollection();
            counterCollection.Add(counterCreationData);

            PerformanceCounterCategory.Create(
                    "CustomCounterCategory","CategoryDescription",
                    PerformanceCounterCategoryType.SingleInstance,
                    counterCollection);

Then when my code receive messages, I just call the IncrementBy() method to count the messages. below is the code snippet:

private static readonly PerformanceCounter Counter = new PerformanceCounter("CustomCounterCategory", "numberOfMessages", string.Empty, false);

        private void OnReceive()
        {
            ...
		var messages = _subscriptionClient.ReceiveBatch(32);
		var brokeredMessages = messages as IList<BrokeredMessage> ?? messages.ToList();
		if (messages != null && brokeredMessages.Any())
		{
		      Counter.IncrementBy(messages.Count);
		      MessageReceived(this, brokeredMessages);
		}

         }

When I check the data from the azure table, "WADPerformanceCountersTable".  The CounterValue is just simply increasing. It is not the numbers of received messages in last minutes.

To get the numbers of received messages in last minutes, how should I write my code?

BTW, I'm using the AZure SDK 2.5. The transfer interval is set to 1 min, sample rate set to 20 sec. This might be changed.

Thanks.



Viewing all articles
Browse latest Browse all 1916

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>