datasources: querier: log caller (#115087)

This commit is contained in:
Gábor Farkas
2025-12-10 18:23:59 +01:00
committed by GitHub
parent 9e1fe16873
commit a847f36df2
2 changed files with 23 additions and 3 deletions
+13 -2
View File
@@ -10,6 +10,8 @@ import (
"strconv"
"strings"
"github.com/grafana/authlib/authn"
claims "github.com/grafana/authlib/types"
"github.com/grafana/grafana-plugin-sdk-go/backend"
"github.com/grafana/grafana-plugin-sdk-go/experimental/apis/data/v0alpha1"
"github.com/grafana/grafana/pkg/api/dtos"
@@ -154,11 +156,11 @@ func (r *queryREST) Connect(connectCtx context.Context, name string, _ runtime.O
}
}
}
connectLogger.Debug("responder sending status code", "statusCode", statusCode)
connectLogger.Debug("responder sending status code", "statusCode", statusCode, "caller", getCaller(ctx))
},
func(err error) {
connectLogger.Error("error caught in handler", "err", err)
connectLogger.Error("error caught in handler", "err", err, "caller", getCaller(ctx))
span.SetStatus(codes.Error, "query error")
if err == nil {
@@ -480,3 +482,12 @@ func getValidDataSourceRef(ctx context.Context, ds *v0alpha1.DataSourceRef, id i
return ds, nil
}
func getCaller(ctx context.Context) string {
authInfo, ok := claims.AuthInfoFrom(ctx)
if !ok {
return "<auth-missing>"
} else {
return strings.Join(authInfo.GetExtra()[authn.ServiceIdentityKey], ",")
}
}