public async Task Track_ActiveMessages_And_DeadLetteredMessages_Metrics_Per_Subscription(int numSubscriptions)
        {
            // arrange
            var random        = new Random();
            var subscriptions = Enumerable.Range(0, numSubscriptions)
                                .Select(n => _servicebusNamespaceServiceStub.SetupSubscription(
                                            $"topic{n}",
                                            $"subscription{n}",
                                            random.Next(),
                                            random.Next()))
                                .ToList();

            // act
            await _metricsCollector.Run(null, NullLogger.Instance);

            // assert
            foreach (var subscription in subscriptions)
            {
                _telemetryChannelMock.Verify(
                    c => c.Send(It.Is <MetricTelemetry>(
                                    m => m.Name == TrackedMetrics.ActiveMessages &&
                                    m.Properties[nameof(subscription.EntityName)] == subscription.EntityName &&
                                    m.Sum == subscription.ActiveMessagesCount)), Times.Once);

                _telemetryChannelMock.Verify(
                    c => c.Send(It.Is <MetricTelemetry>(
                                    m => m.Name == TrackedMetrics.DeadLetteredMessages &&
                                    m.Properties[nameof(subscription.EntityName)] == subscription.EntityName &&
                                    m.Sum == subscription.DeadLetteredMessagesCount)), Times.Once);
            }

            _telemetryChannelMock.Verify(m => m.Flush(), Times.Once);
        }
예제 #2
0
        static async Task Main(string[] args)
        {
            var config = await Parsing.Parsing.Config.LoadConfig(Parsing.Parsing.Config.DefaultConfigFilename);

            var collector = new MetricsCollector(statusUpdater:
                                                 update => System.Console.WriteLine(update)
                                                 );
            await collector.Run(config);

            System.Console.WriteLine("Metrics collection complete.");
        }