Beispiel #1
0
        public async void AppendAsync_ShouldCallSerializationAndSender()
        {
            var span   = Substitute.For <ILetsTraceSpan>();
            var tracer = Substitute.For <ILetsTraceTracer>();

            span.Tracer.Returns(tracer);
            var cts = new CancellationTokenSource();

            var jProcess = Substitute.For <JaegerProcess>();

            _mockJaegerThriftSerialization.BuildJaegerProcessThrift(Arg.Is(tracer)).Returns(jProcess);

            var jSpan = Substitute.For <JaegerSpan>();

            _mockJaegerThriftSerialization.BuildJaegerThriftSpan(Arg.Is(span)).Returns(jSpan);

            _mockSender.BufferItem(Arg.Is(jSpan)).Returns(2);

            var sent = await _testingTransport.AppendAsync(span, cts.Token);

            Assert.Equal(0, sent);
            _mockJaegerThriftSerialization.Received(1).BuildJaegerProcessThrift(Arg.Is(tracer));
            _mockJaegerThriftSerialization.Received(1).BuildJaegerThriftSpan(Arg.Is(span));
            _mockSender.Received(1).BufferItem(Arg.Is(jSpan));
            await _mockSender.Received(0).FlushAsync(Arg.Any <JaegerProcess>(), Arg.Any <CancellationToken>());
        }
Beispiel #2
0
        public async Task <int> AppendAsync(ILetsTraceSpan span, CancellationToken canellationToken)
        {
            if (_process == null)
            {
                _process = _jaegerThriftSerialization.BuildJaegerProcessThrift(span.Tracer);
            }
            var jaegerSpan = _jaegerThriftSerialization.BuildJaegerThriftSpan(span);

            var curBuffCount = _sender.BufferItem(jaegerSpan);

            if (curBuffCount > BufferSize)
            {
                return(await _sender.FlushAsync(_process, canellationToken));
            }

            return(0);
        }