SSE: (Chore/Instrumentation) Add ds_queries_total metric and move met… (#66695)

* SSE: (Chore/Instrumentation) Add ds_queries_total metric and move metrics to service
This commit is contained in:
Kyle Brandt
2023-04-17 19:12:44 -04:00
committed by GitHub
parent 45e1bfe421
commit 2f13c851e4
9 changed files with 66 additions and 24 deletions

View File

@ -230,11 +230,16 @@ func (dn *DSNode) Execute(ctx context.Context, now time.Time, _ mathexp.Vars, s
}
responseType := "unknown"
respStatus := "success"
var useDataplane bool
defer func() {
if e != nil {
responseType = "error"
respStatus = "failure"
}
logger.Debug("Data source queried", "responseType", responseType)
s.metrics.dsRequests.WithLabelValues(respStatus, fmt.Sprintf("%t", useDataplane)).Inc()
}()
resp, err := s.dataService.QueryData(ctx, req)
@ -259,7 +264,9 @@ func (dn *DSNode) Execute(ctx context.Context, now time.Time, _ mathexp.Vars, s
return mathexp.Results{}, QueryError{RefID: dn.refID, Err: response.Error}
}
if dt, use, _ := shouldUseDataplane(response.Frames, logger, s.features.IsEnabled(featuremgmt.FlagDisableSSEDataplane)); use {
var dt data.FrameType
dt, useDataplane, _ = shouldUseDataplane(response.Frames, logger, s.features.IsEnabled(featuremgmt.FlagDisableSSEDataplane))
if useDataplane {
logger.Debug("Handling SSE data source query through dataplane", "datatype", dt)
return handleDataplaneFrames(dt.Kind(), response.Frames)
}