/// <summary>
        /// Method used to generated messages that will be sent during the benchmark
        /// </summary>
        private IMessageDiagnostics[] GenerateMessages()
        {
            var messages = new IMessageDiagnostics[BenchmarkConfiguration.MessageCount];
            var filler   = new byte[BenchmarkConfiguration.FillerSize];

            for (var i = 0; i < BenchmarkConfiguration.MessageCount; i++)
            {
                messages[i] = CreateMessage(i, filler);
            }

            return(messages);
        }
예제 #2
0
        /// <summary>
        /// Message receive handler, this method will increment a counter that keeps track of the
        /// amount of messages that have been received
        /// </summary>
        public void HandleEvent(TelemetryEventType telemetryEventType, Guid?messageId, IMessageDiagnostics message)
        {
            var elapsedSpan = new TimeSpan(DateTime.UtcNow.Ticks - _createdAt.Ticks);

            if (telemetryEventType == TelemetryEventType.PostConsume)
            {
                Interlocked.Increment(ref _postConsumeMessagesCount);
            }

            _telemetryClient.TrackEvent(
                telemetryEventType,
                messageId ?? Guid.Empty,
                new
            {
                CreatedAt = elapsedSpan.Ticks,
                Message   = new { message.Id }
            }
                );
        }