public void RemoteReporter_ShouldCallMetrics()
        {
            var transport = Substitute.For <ITransport>();
            var span      = Substitute.For <IJaegerCoreSpan>();
            var metrics   = InMemoryMetricsFactory.Instance.CreateMetrics();

            transport.CloseAsync(Arg.Any <CancellationToken>()).Returns(Task.FromResult(2));

            using (var reporter = new RemoteReporter.Builder(transport).WithMetrics(metrics).Build())
            {
                reporter.Report(span);
                reporter.Report(span);

                transport.Received(2).AppendAsync(span, Arg.Any <CancellationToken>());
            }
            transport.Received(1).CloseAsync(Arg.Any <CancellationToken>());
            Assert.Equal(2, metrics.ReporterSuccess.Count);
        }
        public void RemoteReporter_ShouldCallTransport()
        {
            var transport = Substitute.For <ITransport>();
            var span      = Substitute.For <IJaegerCoreSpan>();

            using (var reporter = new RemoteReporter.Builder(transport).Build())
            {
                reporter.Report(span);
                transport.Received(1).AppendAsync(span, Arg.Any <CancellationToken>());
            }
            transport.Received(1).CloseAsync(Arg.Any <CancellationToken>());
        }
        public void RemoteReporter_ShouldCountReporterDropped()
        {
            var transport = Substitute.For <ITransport>();
            var span      = Substitute.For <IJaegerCoreSpan>();
            var metrics   = InMemoryMetricsFactory.Instance.CreateMetrics();

            transport.AppendAsync(span, Arg.Any <CancellationToken>()).Throws(new SenderException(String.Empty, 1));

            using (var reporter = new RemoteReporter.Builder(transport).WithMetrics(metrics).Build())
            {
                reporter.Report(span);

                transport.Received(1).AppendAsync(span, Arg.Any <CancellationToken>());
            }
            transport.Received(1).CloseAsync(Arg.Any <CancellationToken>());
            Assert.Equal(0, metrics.ReporterSuccess.Count);
            Assert.Equal(1, metrics.ReporterDropped.Count);
            Assert.Equal(0, metrics.ReporterFailure.Count);
        }