public async Task Should_capture_the_bus_instance_metric()
        {
            await InputQueueSendEndpoint.Send(new PingMessage());

            await InputQueueSendEndpoint.Send(new PingMessage());

            await InputQueueSendEndpoint.Send(new PingMessage());

            await InputQueueSendEndpoint.Send(new PingMessage());

            await InputQueueSendEndpoint.Send(new PingMessage());

            await Bus.Publish(new PingMessage());

            await Bus.Publish(new PingMessage());

            await Bus.Publish(new PingMessage());

            await Bus.Publish <GenericMessage <LongMessage> >(new { Message = new LongMessage() });

            await _activityMonitor.AwaitBusInactivity(TestCancellationToken);

            using var stream = new MemoryStream();
            await Metrics.DefaultRegistry.CollectAndExportAsTextAsync(stream);

            var text = Encoding.UTF8.GetString(stream.ToArray());

            Console.WriteLine(text);

            Assert.That(text.Contains("mt_publish_total{service_name=\"unit_test\",message_type=\"PingMessage\"} 3"), "publish");
            Assert.That(text.Contains("mt_send_total{service_name=\"unit_test\",message_type=\"PingMessage\"} 5"), "send");
            Assert.That(text.Contains("mt_receive_total{service_name=\"unit_test\",endpoint_address=\"input_queue\"} 9"), "receive");
            Assert.That(text.Contains("mt_consume_total{service_name=\"unit_test\",message_type=\"PingMessage\",consumer_type=\"TestConsumer\"} 8"), "consume");
        }
Beispiel #2
0
        public async Task Should_complete_with_metrics_available()
        {
            RoutingSlipCompleted completed = (await _completed).Message;

            await _activityMonitor.AwaitBusInactivity(TestCancellationToken);

            using var stream = new MemoryStream();
            await Metrics.DefaultRegistry.CollectAndExportAsTextAsync(stream);

            var text = Encoding.UTF8.GetString(stream.ToArray());

            Console.WriteLine(text);

            Assert.That(text.Contains("mt_activity_execute_total{service_name=\"unit_test\",activity_name=\"SecondTest\",argument_type=\"Test\"} 1"));
            Assert.That(text.Contains("mt_activity_execute_total{service_name=\"unit_test\",activity_name=\"Test\",argument_type=\"Test\"} 1"));
        }