(t *testing.T, client *httpclient.Client, info *tempoUtil.TraceInfo)
| 41 | } |
| 42 | |
| 43 | func queryAndAssertTraceCompression(t *testing.T, client *httpclient.Client, info *tempoUtil.TraceInfo) { |
| 44 | // The received client will strip the header before we have a chance to inspect it, so just validate that the compressed client works as expected. |
| 45 | result, err := client.QueryTrace(info.HexID()) |
| 46 | require.NoError(t, err) |
| 47 | require.NotNil(t, result) |
| 48 | |
| 49 | expected, err := info.ConstructTraceFromEpoch() |
| 50 | require.NoError(t, err) |
| 51 | util.AssertEqualTrace(t, result, expected) |
| 52 | |
| 53 | // Go's http.Client transparently requests gzip compression and automatically decompresses the |
| 54 | // response, to disable this behaviour you have to explicitly set the Accept-Encoding header. |
| 55 | |
| 56 | // Make the call directly so we have a chance to inspect the response header and manually un-gzip it ourselves to confirm the content. |
| 57 | request, err := http.NewRequest("GET", client.BaseURL+httpclient.QueryTraceV2Endpoint+"/"+info.HexID(), nil) |
| 58 | require.NoError(t, err) |
| 59 | request.Header.Add("Accept-Encoding", "gzip") |
| 60 | |
| 61 | res, err := client.Do(request) |
| 62 | require.NoError(t, err) |
| 63 | defer res.Body.Close() |
| 64 | |
| 65 | require.Equal(t, "gzip", res.Header.Get("Content-Encoding")) |
| 66 | |
| 67 | gzipReader, err := gzip.NewReader(res.Body) |
| 68 | require.NoError(t, err) |
| 69 | defer gzipReader.Close() |
| 70 | |
| 71 | m := &tempopb.TraceByIDResponse{} |
| 72 | |
| 73 | bodyBytes, _ := io.ReadAll(gzipReader) |
| 74 | err = jsonpb.Unmarshal(bytes.NewReader(bodyBytes), m) |
| 75 | require.NoError(t, err) |
| 76 | |
| 77 | util.AssertEqualTrace(t, expected, m.Trace) |
| 78 | } |
no test coverage detected