Search in sources :

Example 26 with GzipSink

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);
}
Also used : Buffer(okio.Buffer) ByteString(okio.ByteString) GzipSink(okio.GzipSink) Test(org.junit.Test)

Aggregations

GzipSink (okio.GzipSink)26 BufferedSink (okio.BufferedSink)20 Buffer (okio.Buffer)13 RequestBody (okhttp3.RequestBody)5 ByteString (okio.ByteString)3 RequestBody (com.squareup.okhttp.RequestBody)2 Request (okhttp3.Request)2 Response (okhttp3.Response)2 Test (org.junit.Test)2 ErrorPayload (co.elastic.apm.impl.error.ErrorPayload)1 File (java.io.File)1 IOException (java.io.IOException)1 TreeSet (java.util.TreeSet)1 OkHttpClient (okhttp3.OkHttpClient)1 MockResponse (okhttp3.mockwebserver.MockResponse)1 BufferedSource (okio.BufferedSource)1 Sink (okio.Sink)1