(b *testing.B)
| 864 | } |
| 865 | |
| 866 | func BenchmarkOTLPWriteHandlerCompression(b *testing.B) { |
| 867 | cfg := distributor.OTLPConfig{ |
| 868 | ConvertAllAttributes: false, |
| 869 | DisableTargetInfo: false, |
| 870 | } |
| 871 | overrides := validation.NewOverrides(querier.DefaultLimitsConfig(), nil) |
| 872 | |
| 873 | exportRequest := generateOTLPWriteRequest() |
| 874 | mockPushFunc := func(context.Context, *cortexpb.WriteRequest) (*cortexpb.WriteResponse, error) { |
| 875 | return &cortexpb.WriteResponse{}, nil |
| 876 | } |
| 877 | handler := OTLPHandler(10000, overrides, cfg, nil, mockPushFunc, nil) |
| 878 | |
| 879 | b.Run("json with no compression", func(b *testing.B) { |
| 880 | req, err := getOTLPHttpRequest(&exportRequest, jsonContentType, "") |
| 881 | require.NoError(b, err) |
| 882 | |
| 883 | b.ReportAllocs() |
| 884 | for b.Loop() { |
| 885 | recorder := httptest.NewRecorder() |
| 886 | handler.ServeHTTP(recorder, req) |
| 887 | |
| 888 | resp := recorder.Result() |
| 889 | require.Equal(b, http.StatusOK, resp.StatusCode) |
| 890 | req.Body.(*resetReader).Reset() |
| 891 | } |
| 892 | }) |
| 893 | b.Run("json with gzip", func(b *testing.B) { |
| 894 | req, err := getOTLPHttpRequest(&exportRequest, jsonContentType, "gzip") |
| 895 | require.NoError(b, err) |
| 896 | |
| 897 | b.ReportAllocs() |
| 898 | for b.Loop() { |
| 899 | recorder := httptest.NewRecorder() |
| 900 | handler.ServeHTTP(recorder, req) |
| 901 | |
| 902 | resp := recorder.Result() |
| 903 | require.Equal(b, http.StatusOK, resp.StatusCode) |
| 904 | req.Body.(*resetReader).Reset() |
| 905 | } |
| 906 | }) |
| 907 | b.Run("proto with no compression", func(b *testing.B) { |
| 908 | req, err := getOTLPHttpRequest(&exportRequest, pbContentType, "") |
| 909 | require.NoError(b, err) |
| 910 | |
| 911 | b.ReportAllocs() |
| 912 | for b.Loop() { |
| 913 | recorder := httptest.NewRecorder() |
| 914 | handler.ServeHTTP(recorder, req) |
| 915 | |
| 916 | resp := recorder.Result() |
| 917 | require.Equal(b, http.StatusOK, resp.StatusCode) |
| 918 | req.Body.(*resetReader).Reset() |
| 919 | } |
| 920 | }) |
| 921 | b.Run("proto with gzip", func(b *testing.B) { |
| 922 | req, err := getOTLPHttpRequest(&exportRequest, pbContentType, "gzip") |
| 923 | require.NoError(b, err) |
nothing calls this directly
no test coverage detected