mirror of
https://github.com/prometheus/prometheus.git
synced 2024-12-26 22:19:40 -08:00
Merge pull request #14306 from pracucci/export-tolabelmatchers
Export remote.ToLabelMatchers()
This commit is contained in:
commit
6572b1fe63
|
@ -95,7 +95,7 @@ func EncodeReadResponse(resp *prompb.ReadResponse, w http.ResponseWriter) error
|
||||||
|
|
||||||
// ToQuery builds a Query proto.
|
// ToQuery builds a Query proto.
|
||||||
func ToQuery(from, to int64, matchers []*labels.Matcher, hints *storage.SelectHints) (*prompb.Query, error) {
|
func ToQuery(from, to int64, matchers []*labels.Matcher, hints *storage.SelectHints) (*prompb.Query, error) {
|
||||||
ms, err := toLabelMatchers(matchers)
|
ms, err := ToLabelMatchers(matchers)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -566,7 +566,8 @@ func validateLabelsAndMetricName(ls []prompb.Label) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func toLabelMatchers(matchers []*labels.Matcher) ([]*prompb.LabelMatcher, error) {
|
// ToLabelMatchers converts Prometheus label matchers to protobuf label matchers.
|
||||||
|
func ToLabelMatchers(matchers []*labels.Matcher) ([]*prompb.LabelMatcher, error) {
|
||||||
pbMatchers := make([]*prompb.LabelMatcher, 0, len(matchers))
|
pbMatchers := make([]*prompb.LabelMatcher, 0, len(matchers))
|
||||||
for _, m := range matchers {
|
for _, m := range matchers {
|
||||||
var mType prompb.LabelMatcher_Type
|
var mType prompb.LabelMatcher_Type
|
||||||
|
@ -591,7 +592,7 @@ func toLabelMatchers(matchers []*labels.Matcher) ([]*prompb.LabelMatcher, error)
|
||||||
return pbMatchers, nil
|
return pbMatchers, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// FromLabelMatchers parses protobuf label matchers to Prometheus label matchers.
|
// FromLabelMatchers converts protobuf label matchers to Prometheus label matchers.
|
||||||
func FromLabelMatchers(matchers []*prompb.LabelMatcher) ([]*labels.Matcher, error) {
|
func FromLabelMatchers(matchers []*prompb.LabelMatcher) ([]*labels.Matcher, error) {
|
||||||
result := make([]*labels.Matcher, 0, len(matchers))
|
result := make([]*labels.Matcher, 0, len(matchers))
|
||||||
for _, matcher := range matchers {
|
for _, matcher := range matchers {
|
||||||
|
|
Loading…
Reference in a new issue