internal PerSocketDirectionStats(bool sendOrReceive, SocketDirection direction) { StatisticNameFormat batchSizeStatName = sendOrReceive ? StatisticNames.MESSAGING_SENT_BATCH_SIZE_PER_SOCKET_DIRECTION : StatisticNames.MESSAGING_RECEIVED_BATCH_SIZE_PER_SOCKET_DIRECTION; StatisticNameFormat batchHistogramStatName = sendOrReceive ? StatisticNames.MESSAGING_SENT_BATCH_SIZE_BYTES_HISTOGRAM_PER_SOCKET_DIRECTION : StatisticNames.MESSAGING_RECEIVED_BATCH_SIZE_BYTES_HISTOGRAM_PER_SOCKET_DIRECTION; averageBatchSize = AverageValueStatistic.FindOrCreate(new StatisticName(batchSizeStatName, Enum.GetName(typeof(SocketDirection), direction))); batchSizeBytesHistogram = ExponentialHistogramValueStatistic.Create_ExponentialHistogram( new StatisticName(batchHistogramStatName, Enum.GetName(typeof(SocketDirection), direction)), NUM_MSG_SIZE_HISTOGRAM_CATEGORIES); }
public QueueTrackingStatistic(string queueName) { if (StatisticsCollector.CollectQueueStats) { const CounterStorage storage = CounterStorage.LogAndTable; averageQueueSizeCounter = AverageValueStatistic.FindOrCreate( new StatisticName(StatisticNames.QUEUES_QUEUE_SIZE_AVERAGE_PER_QUEUE, queueName), storage); numEnqueuedRequestsCounter = CounterStatistic.FindOrCreate( new StatisticName(StatisticNames.QUEUES_ENQUEUED_PER_QUEUE, queueName), false, storage); if (TrackExtraStats) { totalExecutionTime = TimeIntervalFactory.CreateTimeInterval(true); averageArrivalRate = FloatValueStatistic.FindOrCreate( new StatisticName(StatisticNames.QUEUES_AVERAGE_ARRIVAL_RATE_PER_QUEUE, queueName), () => { TimeSpan totalTime = totalExecutionTime.Elapsed; if (totalTime.Ticks == 0) { return(0); } long numReqs = numEnqueuedRequestsCounter.GetCurrentValue(); return((float)((((double)numReqs * (double)TimeSpan.TicksPerSecond)) / (double)totalTime.Ticks)); }, storage); } averageTimeInQueue = AverageValueStatistic.FindOrCreate(new StatisticName(StatisticNames.QUEUES_TIME_IN_QUEUE_AVERAGE_MILLIS_PER_QUEUE, queueName), storage); averageTimeInQueue.AddValueConverter(Utils.AverageTicksToMilliSeconds); if (averageTimeInAllQueues == null) { averageTimeInAllQueues = AverageValueStatistic.FindOrCreate(new StatisticName(StatisticNames.QUEUES_TIME_IN_QUEUE_AVERAGE_MILLIS_PER_QUEUE, "AllQueues"), storage); averageTimeInAllQueues.AddValueConverter(Utils.AverageTicksToMilliSeconds); } if (totalTimeInAllQueues == null) { totalTimeInAllQueues = CounterStatistic.FindOrCreate( new StatisticName(StatisticNames.QUEUES_TIME_IN_QUEUE_TOTAL_MILLIS_PER_QUEUE, "AllQueues"), false, storage); totalTimeInAllQueues.AddValueConverter(Utils.TicksToMilliSeconds); } } }
static private AverageValueStatistic FindOrCreate_Impl(StatisticName name, CounterStorage storage, bool multiThreaded) { AverageValueStatistic stat; #if COLLECT_AVERAGE if (multiThreaded) { stat = new MultiThreadedAverageValueStatistic(name); } else { stat = new SingleThreadedAverageValueStatistic(name); } stat.average = FloatValueStatistic.FindOrCreate(name, () => stat.GetAverageValue(), storage); #else stat = new AverageValueStatistic(name); #endif return stat; }
static private AverageValueStatistic FindOrCreate_Impl(StatisticName name, CounterStorage storage, bool multiThreaded) { AverageValueStatistic stat; #if COLLECT_AVERAGE if (multiThreaded) { stat = new MultiThreadedAverageValueStatistic(name); } else { stat = new SingleThreadedAverageValueStatistic(name); } stat.average = FloatValueStatistic.FindOrCreate(name, () => stat.GetAverageValue(), storage); #else stat = new AverageValueStatistic(name); #endif return(stat); }
public QueueTrackingStatistic(string queueName) { if (StatisticsCollector.CollectQueueStats) { const CounterStorage storage = CounterStorage.LogAndTable; averageQueueSizeCounter = AverageValueStatistic.FindOrCreate( new StatisticName(StatisticNames.QUEUES_QUEUE_SIZE_AVERAGE_PER_QUEUE, queueName), storage); numEnqueuedRequestsCounter = CounterStatistic.FindOrCreate( new StatisticName(StatisticNames.QUEUES_ENQUEUED_PER_QUEUE, queueName), false, storage); if (TrackExtraStats) { totalExecutionTime = TimeIntervalFactory.CreateTimeInterval(true); averageArrivalRate = FloatValueStatistic.FindOrCreate( new StatisticName(StatisticNames.QUEUES_AVERAGE_ARRIVAL_RATE_PER_QUEUE, queueName), () => { TimeSpan totalTime = totalExecutionTime.Elapsed; if (totalTime.Ticks == 0) return 0; long numReqs = numEnqueuedRequestsCounter.GetCurrentValue(); return (float)((((double)numReqs * (double)TimeSpan.TicksPerSecond)) / (double)totalTime.Ticks); }, storage); } averageTimeInQueue = AverageValueStatistic.FindOrCreate(new StatisticName(StatisticNames.QUEUES_TIME_IN_QUEUE_AVERAGE_MILLIS_PER_QUEUE, queueName), storage); averageTimeInQueue.AddValueConverter(Utils.AverageTicksToMilliSeconds); if (averageTimeInAllQueues == null) { averageTimeInAllQueues = AverageValueStatistic.FindOrCreate(new StatisticName(StatisticNames.QUEUES_TIME_IN_QUEUE_AVERAGE_MILLIS_PER_QUEUE, "AllQueues"), storage); averageTimeInAllQueues.AddValueConverter(Utils.AverageTicksToMilliSeconds); } if (totalTimeInAllQueues == null) { totalTimeInAllQueues = CounterStatistic.FindOrCreate( new StatisticName(StatisticNames.QUEUES_TIME_IN_QUEUE_TOTAL_MILLIS_PER_QUEUE, "AllQueues"), false, storage); totalTimeInAllQueues.AddValueConverter(Utils.TicksToMilliSeconds); } } }