diff --git a/plugin/storage/cassandra/spanstore/reader.go b/plugin/storage/cassandra/spanstore/reader.go index 33bdbe5f6b0..85dff51bbef 100644 --- a/plugin/storage/cassandra/spanstore/reader.go +++ b/plugin/storage/cassandra/spanstore/reader.go @@ -237,7 +237,10 @@ func (s *SpanReader) FindTraces(ctx context.Context, traceQuery *spanstore.Trace } if traceQuery.NumTraces == 0 { traceQuery.NumTraces = defaultNumTraces + } else if traceQuery.NumTraces > 10000 { + traceQuery.NumTraces = 10000 } + uniqueTraceIDs, err := s.findTraceIDs(ctx, traceQuery) if err != nil { return nil, err diff --git a/plugin/storage/es/spanstore/reader.go b/plugin/storage/es/spanstore/reader.go index ff75314e754..4e78789d3a7 100644 --- a/plugin/storage/es/spanstore/reader.go +++ b/plugin/storage/es/spanstore/reader.go @@ -54,6 +54,7 @@ const ( defaultDocCount = 10000 // the default elasticsearch allowed limit defaultNumTraces = 100 + defaultNumSpans = 1000 ) var ( @@ -265,7 +266,7 @@ func (s *SpanReader) multiRead(ctx context.Context, traceIDs []string, startTime if val, ok := searchAfterTime[traceID]; ok { nextTime = val } - searchRequests[i] = elastic.NewSearchRequest().IgnoreUnavailable(true).Type(spanType).Source(elastic.NewSearchSource().Query(query).Size(defaultDocCount).Sort("startTime", true).SearchAfter(nextTime)) + searchRequests[i] = elastic.NewSearchRequest().IgnoreUnavailable(true).Type(spanType).Source(elastic.NewSearchSource().Query(query).Size(defaultDocCount).TerminateAfter(defaultNumSpans).Sort("startTime", true).SearchAfter(nextTime)) } // set traceIDs to empty traceIDs = nil