(req *client.MetricsForLabelMatchersRequest, stream client.Ingester_MetricsForLabelMatchersStreamServer)
| 2128 | } |
| 2129 | |
| 2130 | func (i *Ingester) MetricsForLabelMatchersStream(req *client.MetricsForLabelMatchersRequest, stream client.Ingester_MetricsForLabelMatchersStreamServer) (err error) { |
| 2131 | defer recoverIngester(i.logger, &err) |
| 2132 | |
| 2133 | ctx := stream.Context() |
| 2134 | userID, userErr := users.TenantID(ctx) |
| 2135 | if userErr != nil { |
| 2136 | return userErr |
| 2137 | } |
| 2138 | |
| 2139 | // Set pprof labels for profiling |
| 2140 | pprof.Do(ctx, pprof.Labels("user", userID), func(ctx context.Context) { |
| 2141 | result := &client.MetricsForLabelMatchersStreamResponse{} |
| 2142 | |
| 2143 | var cleanup func() |
| 2144 | cleanup, err = i.metricsForLabelMatchersCommon(ctx, req, func(l labels.Labels) error { |
| 2145 | result.Metric = append(result.Metric, &cortexpb.Metric{ |
| 2146 | Labels: cortexpb.FromLabelsToLabelAdapters(l), |
| 2147 | }) |
| 2148 | |
| 2149 | if len(result.Metric) >= metadataStreamBatchSize { |
| 2150 | err := client.SendMetricsForLabelMatchersStream(stream, result) |
| 2151 | if err != nil { |
| 2152 | return err |
| 2153 | } |
| 2154 | result.Metric = result.Metric[:0] |
| 2155 | } |
| 2156 | return nil |
| 2157 | }) |
| 2158 | defer cleanup() |
| 2159 | if err != nil { |
| 2160 | return |
| 2161 | } |
| 2162 | |
| 2163 | // Send last batch |
| 2164 | if len(result.Metric) > 0 { |
| 2165 | err = client.SendMetricsForLabelMatchersStream(stream, result) |
| 2166 | if err != nil { |
| 2167 | return |
| 2168 | } |
| 2169 | } |
| 2170 | }) |
| 2171 | |
| 2172 | return err |
| 2173 | } |
| 2174 | |
| 2175 | // metricsForLabelMatchersCommon returns all the metrics which match a set of matchers. |
| 2176 | // this should be used by MetricsForLabelMatchers and MetricsForLabelMatchersStream. |
nothing calls this directly
no test coverage detected