Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cmd/tempo-cli/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package main
import (
"flag"
"fmt"
"io/ioutil"
"os"

"github.com/grafana/tempo/cmd/tempo/app"
"github.com/grafana/tempo/tempodb/backend"
Expand Down Expand Up @@ -83,7 +83,7 @@ func loadBackend(b *backendOptions, g *globalOptions) (backend.Reader, backend.W

// Existing config
if g.ConfigFile != "" {
buff, err := ioutil.ReadFile(g.ConfigFile)
buff, err := os.ReadFile(g.ConfigFile)
if err != nil {
return nil, nil, nil, fmt.Errorf("failed to read configFile %s: %w", g.ConfigFile, err)
}
Expand Down
6 changes: 3 additions & 3 deletions cmd/tempo/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"context"
"flag"
"fmt"
"io/ioutil"
"io"
"os"
"reflect"
"runtime"
Expand Down Expand Up @@ -132,7 +132,7 @@ func loadConfig() (*app.Config, error) {

// first get the config file
fs := flag.NewFlagSet("", flag.ContinueOnError)
fs.SetOutput(ioutil.Discard)
fs.SetOutput(io.Discard)

fs.StringVar(&configFile, configFileOption, "", "")
fs.BoolVar(&configExpandEnv, configExpandEnvOption, false, "")
Expand All @@ -150,7 +150,7 @@ func loadConfig() (*app.Config, error) {

// overlay with config file if provided
if configFile != "" {
buff, err := ioutil.ReadFile(configFile)
buff, err := os.ReadFile(configFile)
if err != nil {
return nil, fmt.Errorf("failed to read configFile %s: %w", configFile, err)
}
Expand Down
4 changes: 2 additions & 2 deletions integration/e2e/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package e2e
import (
"context"
"fmt"
"io/ioutil"
"math/rand"
"os"
"testing"
"time"

Expand Down Expand Up @@ -61,7 +61,7 @@ func TestAllInOne(t *testing.T) {

// set up the backend
cfg := app.Config{}
buff, err := ioutil.ReadFile(tc.configFile)
buff, err := os.ReadFile(tc.configFile)
require.NoError(t, err)
err = yaml.UnmarshalStrict(buff, &cfg)
require.NoError(t, err)
Expand Down
5 changes: 2 additions & 3 deletions integration/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package integration
// Collection of utilities to share between our various load tests

import (
"io/ioutil"
"os"
"path/filepath"
"strconv"
Expand Down Expand Up @@ -110,14 +109,14 @@ func WriteFileToSharedDir(s *e2e.Scenario, dst string, content []byte) error {
return err
}

return ioutil.WriteFile(
return os.WriteFile(
dst,
content,
os.ModePerm)
}

func CopyFileToSharedDir(s *e2e.Scenario, src, dst string) error {
content, err := ioutil.ReadFile(src)
content, err := os.ReadFile(src)
if err != nil {
return errors.Wrapf(err, "unable to read local file %s", src)
}
Expand Down
3 changes: 1 addition & 2 deletions modules/frontend/deduper.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"encoding/binary"
"fmt"
"io"
"io/ioutil"
"net/http"

"github.com/go-kit/kit/log"
Expand Down Expand Up @@ -80,7 +79,7 @@ func (s spanIDDeduper) Do(req *http.Request) (*http.Response, error) {

return &http.Response{
StatusCode: http.StatusOK,
Body: ioutil.NopCloser(bytes.NewReader(traceBytes)),
Body: io.NopCloser(bytes.NewReader(traceBytes)),
Header: http.Header{},
ContentLength: resp.ContentLength,
}, nil
Expand Down
5 changes: 2 additions & 3 deletions modules/frontend/frontend.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package frontend
import (
"bytes"
"io"
"io/ioutil"
"net/http"
"strings"
"time"
Expand Down Expand Up @@ -162,7 +161,7 @@ func NewTracesTripperware(cfg Config, logger log.Logger, registerer prometheus.R
if err != nil {
return &http.Response{
StatusCode: http.StatusBadRequest,
Body: ioutil.NopCloser(strings.NewReader(err.Error())),
Body: io.NopCloser(strings.NewReader(err.Error())),
Header: http.Header{},
}, nil
}
Expand Down Expand Up @@ -198,7 +197,7 @@ func NewTracesTripperware(cfg Config, logger log.Logger, registerer prometheus.R
if err != nil {
return nil, err
}
resp.Body = ioutil.NopCloser(bytes.NewReader(jsonTrace.Bytes()))
resp.Body = io.NopCloser(bytes.NewReader(jsonTrace.Bytes()))
}
span.SetTag("response marshalling format", marshallingFormat)

Expand Down
10 changes: 5 additions & 5 deletions modules/frontend/frontend_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package frontend

import (
"bytes"
"io/ioutil"
"io"
"net/http"
"net/url"
"testing"
Expand All @@ -17,23 +17,23 @@ type mockNextTripperware struct{}

func (s *mockNextTripperware) RoundTrip(_ *http.Request) (*http.Response, error) {
return &http.Response{
Body: ioutil.NopCloser(bytes.NewReader([]byte("next"))),
Body: io.NopCloser(bytes.NewReader([]byte("next"))),
}, nil
}

type mockTracesTripperware struct{}

func (s *mockTracesTripperware) RoundTrip(_ *http.Request) (*http.Response, error) {
return &http.Response{
Body: ioutil.NopCloser(bytes.NewReader([]byte("traces"))),
Body: io.NopCloser(bytes.NewReader([]byte("traces"))),
}, nil
}

type mockSearchTripperware struct{}

func (s *mockSearchTripperware) RoundTrip(_ *http.Request) (*http.Response, error) {
return &http.Response{
Body: ioutil.NopCloser(bytes.NewReader([]byte("search"))),
Body: io.NopCloser(bytes.NewReader([]byte("search"))),
}, nil
}

Expand Down Expand Up @@ -93,7 +93,7 @@ func TestFrontendRoundTripper(t *testing.T) {
require.NoError(t, err)
require.NotNil(t, resp)

body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
require.NoError(t, err)
assert.Equal(t, body, []byte(tt.response))
})
Expand Down
5 changes: 2 additions & 3 deletions modules/frontend/querysharding.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"encoding/binary"
"encoding/hex"
"io"
"io/ioutil"
"net/http"
"strings"

Expand Down Expand Up @@ -184,15 +183,15 @@ func mergeResponses(ctx context.Context, rrs []RequestResponse) (*http.Response,
if shardMissCount == len(rrs) {
return &http.Response{
StatusCode: http.StatusNotFound,
Body: ioutil.NopCloser(strings.NewReader("trace not found in Tempo")),
Body: io.NopCloser(strings.NewReader("trace not found in Tempo")),
Header: http.Header{},
}, nil
}

if errCode == http.StatusOK {
return &http.Response{
StatusCode: http.StatusOK,
Body: ioutil.NopCloser(bytes.NewReader(combinedTrace)),
Body: io.NopCloser(bytes.NewReader(combinedTrace)),
// ContentLength header is added to log the size of response in the Tripperware in frontend.go
// This could be overwritten if the query client and Tempo negotiate compression
ContentLength: int64(len(combinedTrace)),
Expand Down
27 changes: 13 additions & 14 deletions modules/frontend/querysharding_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"bytes"
"context"
"io"
"io/ioutil"
"net/http"
"testing"

Expand Down Expand Up @@ -76,25 +75,25 @@ func TestMergeResponses(t *testing.T) {
{
Response: &http.Response{
StatusCode: http.StatusOK,
Body: ioutil.NopCloser(bytes.NewReader(b1)),
Body: io.NopCloser(bytes.NewReader(b1)),
},
},
{
Response: &http.Response{
StatusCode: http.StatusOK,
Body: ioutil.NopCloser(bytes.NewReader(b2)),
Body: io.NopCloser(bytes.NewReader(b2)),
},
},
{
Response: &http.Response{
StatusCode: http.StatusNotFound,
Body: ioutil.NopCloser(bytes.NewReader([]byte("foo"))),
Body: io.NopCloser(bytes.NewReader([]byte("foo"))),
},
},
},
expected: &http.Response{
StatusCode: http.StatusOK,
Body: ioutil.NopCloser(bytes.NewReader(combinedTrace)),
Body: io.NopCloser(bytes.NewReader(combinedTrace)),
ContentLength: int64(len(combinedTrace)),
},
},
Expand All @@ -104,19 +103,19 @@ func TestMergeResponses(t *testing.T) {
{
Response: &http.Response{
StatusCode: http.StatusOK,
Body: ioutil.NopCloser(bytes.NewReader(b1)),
Body: io.NopCloser(bytes.NewReader(b1)),
},
},
{
Response: &http.Response{
StatusCode: http.StatusInternalServerError,
Body: ioutil.NopCloser(bytes.NewReader([]byte("bar"))),
Body: io.NopCloser(bytes.NewReader([]byte("bar"))),
},
},
},
expected: &http.Response{
StatusCode: http.StatusInternalServerError,
Body: ioutil.NopCloser(bytes.NewReader([]byte("bar"))),
Body: io.NopCloser(bytes.NewReader([]byte("bar"))),
},
},
{
Expand All @@ -125,19 +124,19 @@ func TestMergeResponses(t *testing.T) {
{
Response: &http.Response{
StatusCode: http.StatusNotFound,
Body: ioutil.NopCloser(bytes.NewReader([]byte("foo"))),
Body: io.NopCloser(bytes.NewReader([]byte("foo"))),
},
},
{
Response: &http.Response{
StatusCode: http.StatusInternalServerError,
Body: ioutil.NopCloser(bytes.NewReader([]byte("bar"))),
Body: io.NopCloser(bytes.NewReader([]byte("bar"))),
},
},
},
expected: &http.Response{
StatusCode: http.StatusInternalServerError,
Body: ioutil.NopCloser(bytes.NewReader([]byte("bar"))),
Body: io.NopCloser(bytes.NewReader([]byte("bar"))),
},
},
{
Expand All @@ -146,19 +145,19 @@ func TestMergeResponses(t *testing.T) {
{
Response: &http.Response{
StatusCode: http.StatusOK,
Body: ioutil.NopCloser(bytes.NewReader(b1)),
Body: io.NopCloser(bytes.NewReader(b1)),
},
},
{
Response: &http.Response{
StatusCode: http.StatusForbidden,
Body: ioutil.NopCloser(bytes.NewReader([]byte("foo"))),
Body: io.NopCloser(bytes.NewReader([]byte("foo"))),
},
},
},
expected: &http.Response{
StatusCode: http.StatusInternalServerError,
Body: ioutil.NopCloser(bytes.NewReader([]byte("foo"))),
Body: io.NopCloser(bytes.NewReader([]byte("foo"))),
},
},
}
Expand Down
11 changes: 5 additions & 6 deletions modules/ingester/ingester_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package ingester

import (
"context"
"io/ioutil"
"math/rand"
"os"
"testing"
Expand Down Expand Up @@ -31,7 +30,7 @@ import (
)

func TestPushQuery(t *testing.T) {
tmpDir, err := ioutil.TempDir("/tmp", "")
tmpDir, err := os.MkdirTemp("/tmp", "")
assert.NoError(t, err, "unexpected error getting tempdir")
defer os.RemoveAll(tmpDir)

Expand Down Expand Up @@ -64,7 +63,7 @@ func TestPushQuery(t *testing.T) {
}

func TestFullTraceReturned(t *testing.T) {
tmpDir, err := ioutil.TempDir("/tmp", "")
tmpDir, err := os.MkdirTemp("/tmp", "")
assert.NoError(t, err, "unexpected error getting tempdir")
defer os.RemoveAll(tmpDir)

Expand Down Expand Up @@ -111,7 +110,7 @@ func TestFullTraceReturned(t *testing.T) {
}

func TestDeprecatedPush(t *testing.T) {
tmpDir, err := ioutil.TempDir("/tmp", "")
tmpDir, err := os.MkdirTemp("/tmp", "")
assert.NoError(t, err, "unexpected error getting tempdir")
defer os.RemoveAll(tmpDir)

Expand Down Expand Up @@ -158,7 +157,7 @@ func TestDeprecatedPush(t *testing.T) {
}

func TestWal(t *testing.T) {
tmpDir, err := ioutil.TempDir("/tmp", "")
tmpDir, err := os.MkdirTemp("/tmp", "")
require.NoError(t, err, "unexpected error getting tempdir")
defer os.RemoveAll(tmpDir)

Expand Down Expand Up @@ -260,7 +259,7 @@ func TestWalReplayDeletesLocalBlocks(t *testing.T) {
}

func TestFlush(t *testing.T) {
tmpDir, err := ioutil.TempDir("/tmp", "")
tmpDir, err := os.MkdirTemp("/tmp", "")
require.NoError(t, err, "unexpected error getting tempdir")
defer os.RemoveAll(tmpDir)

Expand Down
5 changes: 2 additions & 3 deletions modules/ingester/instance_search_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"bytes"
"context"
"fmt"
"io/ioutil"
"math/rand"
"os"
"testing"
Expand Down Expand Up @@ -42,7 +41,7 @@ func TestInstanceSearch(t *testing.T) {
assert.NoError(t, err, "unexpected error creating limits")
limiter := NewLimiter(limits, &ringCountMock{count: 1}, 1)

tempDir, err := ioutil.TempDir("/tmp", "")
tempDir, err := os.MkdirTemp("/tmp", "")
assert.NoError(t, err, "unexpected error getting temp dir")
defer os.RemoveAll(tempDir)

Expand Down Expand Up @@ -146,7 +145,7 @@ func TestInstanceSearchNoData(t *testing.T) {
assert.NoError(t, err, "unexpected error creating limits")
limiter := NewLimiter(limits, &ringCountMock{count: 1}, 1)

tempDir, err := ioutil.TempDir("/tmp", "")
tempDir, err := os.MkdirTemp("/tmp", "")
assert.NoError(t, err, "unexpected error getting temp dir")
defer os.RemoveAll(tempDir)

Expand Down
Loading