From 10eab41b489653468d608dce324599875495d410 Mon Sep 17 00:00:00 2001 From: beorn7 Date: Mon, 1 Jun 2015 15:41:09 +0200 Subject: [PATCH] Make LabelNameRE public. --- model/labelname.go | 5 +++-- prometheus/desc.go | 7 +++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/model/labelname.go b/model/labelname.go index 66b0a55..7efbd9f 100644 --- a/model/labelname.go +++ b/model/labelname.go @@ -61,7 +61,8 @@ const ( QuantileLabel = "quantile" ) -var labelNameRE = regexp.MustCompile("^[a-zA-Z_][a-zA-Z0-9_]*$") +// LabelNameRE is a regular expression matching valid label names. +var LabelNameRE = regexp.MustCompile("^[a-zA-Z_][a-zA-Z0-9_]*$") // A LabelName is a key for a LabelSet or Metric. It has a value associated // therewith. @@ -73,7 +74,7 @@ func (ln *LabelName) UnmarshalYAML(unmarshal func(interface{}) error) error { if err := unmarshal(&s); err != nil { return err } - if !labelNameRE.MatchString(s) { + if !LabelNameRE.MatchString(s) { return fmt.Errorf("%q is not a valid label name", s) } *ln = LabelName(s) diff --git a/prometheus/desc.go b/prometheus/desc.go index 7e1f9e8..1fe10bc 100644 --- a/prometheus/desc.go +++ b/prometheus/desc.go @@ -9,16 +9,15 @@ import ( "sort" "strings" - "github.com/prometheus/client_golang/model" + "github.com/golang/protobuf/proto" dto "github.com/prometheus/client_model/go" - "github.com/golang/protobuf/proto" + "github.com/prometheus/client_golang/model" ) var ( metricNameRE = regexp.MustCompile(`^[a-zA-Z_][a-zA-Z0-9_:]*$`) - labelNameRE = regexp.MustCompile(`^[a-zA-Z_][a-zA-Z0-9_]*$`) ) // Labels represents a collection of label name -> value mappings. This type is @@ -194,6 +193,6 @@ func (d *Desc) String() string { } func checkLabelName(l string) bool { - return labelNameRE.MatchString(l) && + return model.LabelNameRE.MatchString(l) && !strings.HasPrefix(l, model.ReservedLabelPrefix) }