Beispiel #1
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);
        }
Beispiel #2
0
        public async void EmitBatchOverhead_ShouldNotGoOverOverheadConstant()
        {
            var transport       = new TMemoryBuffer();
            var protocolFactory = new TCompactProtocol.Factory();
            var client          = new Agent.Client(protocolFactory.GetProtocol(transport));

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

            var tests = new[] { 1, 2, 14, 15, 377, 500, 65000, 0xFFFF };

            foreach (var test in tests)
            {
                transport.Reset();
                var batch       = new List <JaegerSpan>();
                var processTags = new List <JaegerTag>();
                for (var j = 0; j < test; j++)
                {
                    batch.Add(jSpan);
                    processTags.Add(new JaegerTag("testingTag", TagType.BINARY)
                    {
                        VBinary = new byte[] { 0x20 }
                    });
                }

                var jProcess = new JaegerProcess("testing")
                {
                    Tags = processTags
                };
                await client.emitBatchAsync(new JaegerBatch(jProcess, batch), CancellationToken.None);

                var jProcessSize = CalcSizeOfSerializedThrift(jProcess);

                var overhead = transport.GetBuffer().Length - test * jSpanSize - jProcessSize;
                Assert.True(overhead <= TransportConstants.UdpEmitBatchOverhead);
            }
        }