Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions proxy/search/ingestor.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ const (
// SearchStats carries observability data collected while executing a search.
type SearchStats struct {
Query string
From seq.MID
To seq.MID
Size int
HasHist bool
HasAgg bool
Expand Down Expand Up @@ -113,6 +115,8 @@ func (si *Ingestor) Search(

stats = &SearchStats{
Query: string(sr.Q),
From: sr.From,
To: sr.To,
Size: sr.Size + sr.Offset,
HasHist: sr.Interval > 0,
HasAgg: len(sr.AggQ) > 0,
Expand Down
7 changes: 6 additions & 1 deletion proxyapi/grpc_v1.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,9 @@ func (g *grpcV1) doSearch(

obs := requestObservation{
start: time.Now(),
stats: &search.SearchStats{},
stats: &search.SearchStats{
Size: int(req.Size) + int(req.Offset),
},
}

span := trace.FromContext(ctx)
Expand All @@ -205,9 +207,12 @@ func (g *grpcV1) doSearch(
if req.Query == nil {
return nil, obs, status.Error(codes.InvalidArgument, "search query must be provided")
}
obs.stats.Query = req.Query.Query
if req.Query.From == nil || req.Query.To == nil {
return nil, obs, status.Error(codes.InvalidArgument, `search query "from" and "to" fields must be provided`)
}
obs.stats.From = seq.MID(req.Query.From.AsTime().UnixNano())
obs.stats.To = seq.MID(req.Query.To.AsTime().UnixNano())
if req.Offset != 0 && req.OffsetId != "" {
return nil, obs, status.Error(codes.InvalidArgument, `only one of "offset" and "offset_id" must be provided`)
}
Expand Down
2 changes: 2 additions & 0 deletions proxyapi/request_observation.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ func (o *requestObservation) finish(method string, retErr error) {
fields := []zap.Field{
zap.String("method", method),
zap.String("query", o.stats.Query),
zap.String("from", o.stats.From.String()),
zap.String("to", o.stats.To.String()),
zap.Bool("agg", o.stats.HasAgg),
zap.Bool("hist", o.stats.HasHist),
zap.Int("size", o.stats.Size),
Expand Down
Loading