Example #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>());
        }
Example #2
0
        /// <summary>
        /// AppendAsync serializes the passed in span into Jaeger Thrift and passes it off
        /// to the sender which will buffer it to be sent. If the buffer is full enough it
        /// will be flushed and the number of spans sent will be returned. If the buffer is
        /// not full enough, nothing will be done and a 0 will be returned to indicate that 0
        /// spans were sent.
        /// </summary>
        /// <param name="span">The span to serialize into Jaeger Thrift and buffer to be sent</param>
        /// <param name="cancellationToken"></param>
        /// <returns>The number of spans flushed, if any</returns>
        public async Task <int> AppendAsync(IJaegerCoreSpan span, CancellationToken cancellationToken)
        {
            if (_process == null)
            {
                _process = _jaegerThriftSerialization.BuildJaegerProcessThrift(span.Tracer);
            }

            var jaegerSpan = _jaegerThriftSerialization.BuildJaegerThriftSpan(span);

            return(await ProtocolAppendLogicAsync(jaegerSpan, cancellationToken));
        }
Example #3
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);
        }
Example #4
0
        //private readonly JaegerThriftTransport _testingTransport;

        public JaegerUdpTransportTests()
        {
            _mockJaegerThriftSerialization = Substitute.For <ISerialization>();
            _protocolFactory = new TCompactProtocol.Factory();
            _mockSender      = Substitute.For <ISender>();
            _mockSender.ProtocolFactory.Returns(_protocolFactory);

            var jSpan = new JaegerSpan(10, 11, 12, 13, "opName", 0, 1234, 1235);

            _jSpanSize = CalcSizeOfSerializedThrift(jSpan);

            var jProcess = new JaegerProcess("testing");

            _jProcessSize = CalcSizeOfSerializedThrift(jProcess);

            _mockJaegerThriftSerialization.BuildJaegerProcessThrift(Arg.Any <IJaegerCoreTracer>()).Returns(jProcess);
            _mockJaegerThriftSerialization.BuildJaegerThriftSpan(Arg.Any <IJaegerCoreSpan>()).Returns(jSpan);
        }