mirror of
https://github.com/prometheus/prometheus.git
synced 2025-09-21 13:51:00 +02:00
* remote read: simplify ReadMultiple to return single SeriesSet Changed ReadMultiple to return a single SeriesSet with interleaved series from all queries instead of a slice of SeriesSets. This simplifies the interface and removes the complex multiplexing infrastructure while maintaining the ability to send multiple queries in a single HTTP request. Changes: - Updated ReadClient interface: ReadMultiple now returns storage.SeriesSet - Removed multiplexing infrastructure (MessageQueue, QueueConsumer, etc.) - Simplified response handling to interleave series from all queries - Updated tests to match new interface - All existing tests pass Signed-off-by: Dimitar Dimitrov <dimitar.dimitrov@grafana.com> * Fix sorting behavior in ReadMultiple for samples responses When sortSeries=false, the previous implementation incorrectly used storage.NewMergeSeriesSet which requires sorted inputs, violating the function's contract and potentially producing incorrect results. Changes: - When sortSeries=true: Use NewMergeSeriesSet for efficient merging and deduplication of sorted series - When sortSeries=false: Use simple concatenation to avoid the sorted input requirement, preserving duplicates from overlapping queries - Add comprehensive tests to verify both sorting behaviors - Update existing test expectations to match correct sorted order Signed-off-by: Dimitar Dimitrov <dimitar.dimitrov@grafana.com> * Refactor to reduce code duplication in ReadMultiple implementation Extract common query result combination logic into a shared combineQueryResults function that handles both sorted and unsorted cases. This eliminates duplication between the real client implementation and the mock client used in tests. Changes: - Add combineQueryResults helper function in client.go - Refactor handleSamplesResponseImpl to use the helper - Simplify mockedRemoteClient.ReadMultiple to use the same helper - Reduce code duplication by ~30 lines while maintaining same functionality Signed-off-by: Dimitar Dimitrov <dimitar.dimitrov@grafana.com>