From 1c7923630dd72e72457164e9fd987dc4433b460d Mon Sep 17 00:00:00 2001 From: Ruben Vargas Date: Wed, 9 Oct 2019 20:43:33 -0500 Subject: [PATCH] Use correct context on ES search methods Signed-off-by: Ruben Vargas --- plugin/storage/es/spanstore/reader.go | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/plugin/storage/es/spanstore/reader.go b/plugin/storage/es/spanstore/reader.go index 5b0caa50fbd6..05c34d26bdb3 100644 --- a/plugin/storage/es/spanstore/reader.go +++ b/plugin/storage/es/spanstore/reader.go @@ -90,7 +90,6 @@ var ( // SpanReader can query for and load traces from ElasticSearch type SpanReader struct { - ctx context.Context client es.Client logger *zap.Logger // The age of the oldest service/operation we will look for. Because indices in ElasticSearch are by day, @@ -119,9 +118,7 @@ type SpanReaderParams struct { // NewSpanReader returns a new SpanReader with a metrics. func NewSpanReader(p SpanReaderParams) *SpanReader { - ctx := context.Background() return &SpanReader{ - ctx: ctx, client: p.Client, logger: p.Logger, maxSpanAge: p.MaxSpanAge, @@ -291,7 +288,6 @@ func (s *SpanReader) FindTraceIDs(ctx context.Context, traceQuery *spanstore.Tra if traceQuery.NumTraces == 0 { traceQuery.NumTraces = defaultNumTraces } - esTraceIDs, err := s.findTraceIDs(ctx, traceQuery) if err != nil { return nil, err @@ -337,7 +333,7 @@ func (s *SpanReader) multiRead(ctx context.Context, traceIDs []model.TraceID, st } // set traceIDs to empty traceIDs = nil - results, err := s.client.MultiSearch().Add(searchRequests...).Index(indices...).Do(s.ctx) + results, err := s.client.MultiSearch().Add(searchRequests...).Index(indices...).Do(ctx) if err != nil { logErrorToSpan(childSpan, err) @@ -471,7 +467,6 @@ func (s *SpanReader) findTraceIDs(ctx context.Context, traceQuery *spanstore.Tra // } aggregation := s.buildTraceIDAggregation(traceQuery.NumTraces) boolQuery := s.buildFindTraceIDsQuery(traceQuery) - jaegerIndices := s.timeRangeIndices(s.spanIndexPrefix, traceQuery.StartTimeMin, traceQuery.StartTimeMax) searchService := s.client.Search(jaegerIndices...). @@ -480,7 +475,7 @@ func (s *SpanReader) findTraceIDs(ctx context.Context, traceQuery *spanstore.Tra IgnoreUnavailable(true). Query(boolQuery) - searchResult, err := searchService.Do(s.ctx) + searchResult, err := searchService.Do(ctx) if err != nil { return nil, errors.Wrap(err, "Search service failed") }