use of okio.GzipSink in project zipkin by openzipkin.
the class ZipkinRuleTest method gzippedSpans.
@Test
public void gzippedSpans() throws IOException {
byte[] spansInJson = SpanBytesEncoder.JSON_V1.encodeList(spans);
Buffer sink = new Buffer();
GzipSink gzipSink = new GzipSink(sink);
gzipSink.write(new Buffer().write(spansInJson), spansInJson.length);
gzipSink.close();
ByteString gzippedJson = sink.readByteString();
client.newCall(new Request.Builder().url(zipkin.httpUrl() + "/api/v1/spans").addHeader("Content-Encoding", "gzip").post(RequestBody.create(MediaType.parse("application/json"), gzippedJson)).build()).execute();
assertThat(zipkin.collectorMetrics().bytes()).isEqualTo(spansInJson.length);
}
Aggregations