diff --git a/pkg/tsdb/tempo/grpc.go b/pkg/tsdb/tempo/grpc.go index 95f3fdefab2..474502af75f 100644 --- a/pkg/tsdb/tempo/grpc.go +++ b/pkg/tsdb/tempo/grpc.go @@ -10,14 +10,13 @@ import ( "github.com/grafana/grafana-plugin-sdk-go/backend" "github.com/grafana/grafana-plugin-sdk-go/backend/httpclient" - "github.com/grafana/grafana/pkg/infra/log" "github.com/grafana/tempo/pkg/tempopb" "google.golang.org/grpc" "google.golang.org/grpc/credentials" "google.golang.org/grpc/credentials/insecure" ) -var logger = log.New("tsdb.tempo") +var logger = backend.NewLoggerWith("logger", "tsdb.tempo") // This function creates a new gRPC client to connect to a streaming query service. // It starts by parsing the URL from the data source settings and extracting the host, since that's what the gRPC connection expects. diff --git a/pkg/tsdb/tempo/search_stream_test.go b/pkg/tsdb/tempo/search_stream_test.go index 5cf6c09b62e..31a1e702425 100644 --- a/pkg/tsdb/tempo/search_stream_test.go +++ b/pkg/tsdb/tempo/search_stream_test.go @@ -11,14 +11,13 @@ import ( "github.com/grafana/grafana-plugin-sdk-go/backend" "github.com/grafana/grafana-plugin-sdk-go/data" - "github.com/grafana/grafana/pkg/infra/log" "github.com/grafana/grafana/pkg/tsdb/tempo/kinds/dataquery" "github.com/grafana/tempo/pkg/tempopb" "google.golang.org/grpc/metadata" ) func TestProcessStream_ValidInput_ReturnsNoError(t *testing.T) { - logger := log.New("tsdb.tempo.test") + logger := backend.NewLoggerWith("logger", "tsdb.tempo.test") service := &Service{ logger: logger, } @@ -30,7 +29,7 @@ func TestProcessStream_ValidInput_ReturnsNoError(t *testing.T) { } } func TestProcessStream_InvalidInput_ReturnsError(t *testing.T) { - logger := log.New("tsdb.tempo.test") + logger := backend.NewLoggerWith("logger", "tsdb.tempo.test") service := &Service{ logger: logger, } @@ -44,7 +43,7 @@ func TestProcessStream_InvalidInput_ReturnsError(t *testing.T) { } } func TestProcessStream_ValidInput_ReturnsExpectedOutput(t *testing.T) { - logger := log.New("tsdb.tempo.test") + logger := backend.NewLoggerWith("logger", "tsdb.tempo.test") service := &Service{ logger: logger, } diff --git a/pkg/tsdb/tempo/tempo.go b/pkg/tsdb/tempo/tempo.go index 631042c971a..e5c3fdb599e 100644 --- a/pkg/tsdb/tempo/tempo.go +++ b/pkg/tsdb/tempo/tempo.go @@ -11,7 +11,7 @@ import ( "github.com/grafana/grafana-plugin-sdk-go/backend/datasource" "github.com/grafana/grafana-plugin-sdk-go/backend/httpclient" "github.com/grafana/grafana-plugin-sdk-go/backend/instancemgmt" - "github.com/grafana/grafana/pkg/infra/log" + "github.com/grafana/grafana-plugin-sdk-go/backend/log" "github.com/grafana/grafana/pkg/tsdb/tempo/kinds/dataquery" "github.com/grafana/tempo/pkg/tempopb" ) @@ -40,7 +40,7 @@ func logEntrypoint() string { func ProvideService(httpClientProvider *httpclient.Provider) *Service { return &Service{ - logger: log.New("tsdb.tempo"), + logger: backend.NewLoggerWith("logger", "tsdb.tempo"), im: datasource.NewInstanceManager(newInstanceSettings(httpClientProvider)), } } @@ -53,7 +53,7 @@ type Datasource struct { func newInstanceSettings(httpClientProvider *httpclient.Provider) datasource.InstanceFactoryFunc { return func(ctx context.Context, settings backend.DataSourceInstanceSettings) (instancemgmt.Instance, error) { - ctxLogger := log.New("tsdb.tempo").FromContext(ctx) + ctxLogger := backend.NewLoggerWith("logger", "tsdb.tempo").FromContext(ctx) opts, err := settings.HTTPClientOptions(ctx) if err != nil { ctxLogger.Error("Failed to get HTTP client options", "error", err, "function", logEntrypoint()) diff --git a/pkg/tsdb/tempo/trace_test.go b/pkg/tsdb/tempo/trace_test.go index 5b202d90df7..e58da96f5f1 100644 --- a/pkg/tsdb/tempo/trace_test.go +++ b/pkg/tsdb/tempo/trace_test.go @@ -4,21 +4,21 @@ import ( "context" "testing" - "github.com/grafana/grafana/pkg/infra/log" + "github.com/grafana/grafana-plugin-sdk-go/backend" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) func TestTempo(t *testing.T) { t.Run("createRequest without time range - success", func(t *testing.T) { - service := &Service{logger: log.New("tempo-test")} + service := &Service{logger: backend.NewLoggerWith("logger", "tempo-test")} req, err := service.createRequest(context.Background(), &Datasource{}, "traceID", 0, 0) require.NoError(t, err) assert.Equal(t, 1, len(req.Header)) }) t.Run("createRequest with time range - success", func(t *testing.T) { - service := &Service{logger: log.New("tempo-test")} + service := &Service{logger: backend.NewLoggerWith("logger", "tempo-test")} req, err := service.createRequest(context.Background(), &Datasource{}, "traceID", 1, 2) require.NoError(t, err) assert.Equal(t, 1, len(req.Header))