public void TestBuildTags() { var tags = new Dictionary <string, object> { { "key", "value" } }; List <ThriftTag> thriftTags = JaegerThriftSpanConverter.BuildTags(tags); Assert.NotNull(thriftTags); Assert.Single(thriftTags); Assert.Equal("key", thriftTags[0].Key); Assert.Equal("value", thriftTags[0].VStr); Assert.Equal(ThriftTagType.STRING, thriftTags[0].VType); }
public async Task <int> AppendAsync(Span span, CancellationToken cancellationToken) { if (_process == null) { _process = new ThriftProcess(span.Tracer.ServiceName); _process.Tags = JaegerThriftSpanConverter.BuildTags(span.Tracer.Tags); _processBytesSize = CalculateProcessSize(_process); _byteBufferSize += _processBytesSize; } ThriftSpan thriftSpan = JaegerThriftSpanConverter.ConvertSpan(span); int spanSize = CalculateSpanSize(thriftSpan); if (spanSize > MaxSpanBytes) { throw new SenderException($"ThriftSender received a span that was too large, size = {spanSize}, max = {MaxSpanBytes}", null, 1); } _byteBufferSize += spanSize; if (_byteBufferSize <= MaxSpanBytes) { _spanBuffer.Add(thriftSpan); if (_byteBufferSize < MaxSpanBytes) { return(0); } return(await FlushAsync(cancellationToken).ConfigureAwait(false)); } int n; try { n = await FlushAsync(cancellationToken).ConfigureAwait(false); } catch (SenderException ex) { // +1 for the span not submitted in the buffer above throw new SenderException(ex.Message, ex, ex.DroppedSpanCount + 1); } _spanBuffer.Add(thriftSpan); _byteBufferSize = _processBytesSize + spanSize; return(n); }