log: added debug-log (#113156)

* log: added debug-log

* fixed unit test

* fixed another unit test
This commit is contained in:
Gábor Farkas
2025-10-29 14:19:24 +01:00
committed by GitHub
parent 8bff09b88b
commit ec0c14ac1a
2 changed files with 5 additions and 0 deletions
+2
View File
@@ -76,6 +76,8 @@ func (hs *HTTPServer) QueryMetricsV2(c *contextmodel.ReqContext) response.Respon
var resp *backend.QueryDataResponse
var err error
hs.log.Debug("QueryMetricsV2: request received", "time_in_query", handleTimeInQuery)
if handleTimeInQuery {
resp, err = hs.queryDataService.QueryDataNew(c.Req.Context(), c.SignedInUser, c.SkipDSCache, reqDTO)
} else {
+3
View File
@@ -16,6 +16,7 @@ import (
"github.com/grafana/grafana/pkg/apimachinery/errutil"
"github.com/grafana/grafana/pkg/infra/db/dbtest"
"github.com/grafana/grafana/pkg/infra/localcache"
"github.com/grafana/grafana/pkg/infra/log"
"github.com/grafana/grafana/pkg/plugins"
"github.com/grafana/grafana/pkg/plugins/backendplugin"
pluginClient "github.com/grafana/grafana/pkg/plugins/manager/client"
@@ -86,6 +87,7 @@ func TestAPIEndpoint_Metrics_QueryMetricsV2(t *testing.T) {
server := SetupAPITestServer(t, func(hs *HTTPServer) {
hs.queryDataService = qds
hs.QuotaService = quotatest.New(false, nil)
hs.log = log.New("test-logger")
})
t.Run("Status code is 400 when data source response has an error", func(t *testing.T) {
@@ -252,6 +254,7 @@ func TestDataSourceQueryError(t *testing.T) {
err := r.Add(context.Background(), p)
require.NoError(t, err)
ds := &fakeDatasources.FakeDataSourceService{}
hs.log = log.New("test-logger")
hs.queryDataService = query.ProvideService(
cfg,
&fakeDatasources.FakeCacheService{},