public async Task CollectAsync(params Span[] spans) { var request = WebRequest.CreateHttp(_url); request.Method = "POST"; request.ContentType = "application/x-thrift"; using (var output = new MemoryStream()) { ThriftSpanSerializer.WriteSpans(spans, output); output.Position = 0; request.ContentLength = output.Length; using (var stream = await request.GetRequestStreamAsync()) { await output.CopyToAsync(stream); await stream.FlushAsync(); } } using (var reply = (HttpWebResponse)await request.GetResponseAsync()) { if (reply.StatusCode != HttpStatusCode.Accepted) { throw new ZipkinCollectorException($"Zipkin HTTP receiver responded with status code {reply.StatusCode}"); } } }
public async Task CollectAsync(params Span[] spans) { using (var stream = new MemoryStream()) { ThriftSpanSerializer.WriteSpans(spans, stream); stream.Position = 0; var message = new Message { Value = stream.ToArray() }; var result = await _producer.SendMessageAsync(_settings.ZipkinTopic, new[] { message }); var res = result.First(); if (res.Error != 0) { throw new ZipkinCollectorException($"An error (code: {res.Error}) occurred while sending trace data to zipkin-kafka"); } } }