@@ -6,10 +6,9 @@ import (
|
||||
"io"
|
||||
"net/http"
|
||||
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
|
||||
"github.com/grafana/grafana-plugin-sdk-go/backend"
|
||||
"github.com/grafana/grafana-plugin-sdk-go/data"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
|
||||
"github.com/grafana/grafana/pkg/api/response"
|
||||
"github.com/grafana/grafana/pkg/api/routing"
|
||||
@@ -34,7 +33,9 @@ func (s *searchHTTPService) RegisterHTTPRoutes(storageRoute routing.RouteRegiste
|
||||
}
|
||||
|
||||
func (s *searchHTTPService) doQuery(c *contextmodel.ReqContext) response.Response {
|
||||
searchReadinessCheckResp := s.search.IsReady(c.Req.Context(), c.SignedInUser.GetOrgID())
|
||||
ctx, span := tracer.Start(c.Req.Context(), "searchV2.doQuery")
|
||||
defer span.End()
|
||||
searchReadinessCheckResp := s.search.IsReady(ctx, c.SignedInUser.GetOrgID())
|
||||
if !searchReadinessCheckResp.IsReady {
|
||||
dashboardSearchNotServedRequestsCounter.With(prometheus.Labels{
|
||||
"reason": searchReadinessCheckResp.Reason,
|
||||
@@ -59,7 +60,7 @@ func (s *searchHTTPService) doQuery(c *contextmodel.ReqContext) response.Respons
|
||||
return response.Error(http.StatusBadRequest, "error parsing body", err)
|
||||
}
|
||||
|
||||
resp := s.search.doDashboardQuery(c.Req.Context(), c.SignedInUser, c.SignedInUser.GetOrgID(), *query)
|
||||
resp := s.search.doDashboardQuery(ctx, c.SignedInUser, c.SignedInUser.GetOrgID(), *query)
|
||||
|
||||
if resp.Error != nil {
|
||||
return response.Error(http.StatusInternalServerError, "error handling search request", resp.Error)
|
||||
|
||||
@@ -9,6 +9,7 @@ import (
|
||||
"github.com/grafana/grafana-plugin-sdk-go/backend"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
"github.com/prometheus/client_golang/prometheus/promauto"
|
||||
"go.opentelemetry.io/otel"
|
||||
|
||||
"github.com/grafana/grafana/pkg/infra/db"
|
||||
"github.com/grafana/grafana/pkg/infra/log"
|
||||
@@ -58,6 +59,7 @@ var (
|
||||
Namespace: namespace,
|
||||
Subsystem: subsystem,
|
||||
})
|
||||
tracer = otel.Tracer("github.com/grafana/grafana/pkg/services/searchv2")
|
||||
)
|
||||
|
||||
type StandardSearchService struct {
|
||||
@@ -120,6 +122,8 @@ func (s *StandardSearchService) IsDisabled() bool {
|
||||
}
|
||||
|
||||
func (s *StandardSearchService) Run(ctx context.Context) error {
|
||||
ctx, span := tracer.Start(ctx, "searchv2.Run")
|
||||
defer span.End()
|
||||
orgQuery := &org.SearchOrgsQuery{}
|
||||
result, err := s.orgService.Search(ctx, orgQuery)
|
||||
if err != nil {
|
||||
@@ -146,6 +150,8 @@ func (s *StandardSearchService) RegisterDashboardIndexExtender(ext DashboardInde
|
||||
}
|
||||
|
||||
func (s *StandardSearchService) getUser(ctx context.Context, backendUser *backend.User, orgId int64) (*user.SignedInUser, error) {
|
||||
ctx, span := tracer.Start(ctx, "searchv2.getUser")
|
||||
defer span.End()
|
||||
// TODO: get user & user's permissions from the request context
|
||||
|
||||
var usr *user.SignedInUser
|
||||
@@ -204,6 +210,8 @@ func (s *StandardSearchService) getUser(ctx context.Context, backendUser *backen
|
||||
}
|
||||
|
||||
func (s *StandardSearchService) DoDashboardQuery(ctx context.Context, user *backend.User, orgID int64, q DashboardQuery) *backend.DataResponse {
|
||||
ctx, span := tracer.Start(ctx, "searchv2.DoDashboardQuery")
|
||||
defer span.End()
|
||||
start := time.Now()
|
||||
|
||||
signedInUser, err := s.getUser(ctx, user, orgID)
|
||||
@@ -232,6 +240,8 @@ func (s *StandardSearchService) DoDashboardQuery(ctx context.Context, user *back
|
||||
}
|
||||
|
||||
func (s *StandardSearchService) doDashboardQuery(ctx context.Context, signedInUser *user.SignedInUser, orgID int64, q DashboardQuery) *backend.DataResponse {
|
||||
ctx, span := tracer.Start(ctx, "searchv2.doDashboardQuery")
|
||||
defer span.End()
|
||||
rsp := &backend.DataResponse{}
|
||||
|
||||
filter, err := s.auth.GetDashboardReadFilter(ctx, orgID, signedInUser)
|
||||
|
||||
@@ -45,7 +45,7 @@ var (
|
||||
)
|
||||
|
||||
func updateUsageStats(ctx context.Context, reader *bluge.Reader, logger log.Logger, tracer tracing.Tracer) {
|
||||
ctx, span := tracer.Start(ctx, "searchV2 updateUsageStats")
|
||||
ctx, span := tracer.Start(ctx, "searchV2.updateUsageStats")
|
||||
defer span.End()
|
||||
req := bluge.NewAllMatches(bluge.NewTermQuery("panel").SetField(documentFieldKind))
|
||||
for _, usage := range panelUsage {
|
||||
|
||||
Reference in New Issue
Block a user