improve validation function naming

This commit is contained in:
Marco Jantke 2017-08-25 17:58:59 +02:00
parent 0b8aef084e
commit a956c5fdd6
6 changed files with 8 additions and 8 deletions

View File

@ -111,7 +111,7 @@ func NewDesc(fqName, help string, variableLabels []string, constLabels Labels) *
}
// Validate the const label values. They can't have a wrong cardinality, so
// use in len(labelValues) as expectedNumberOfValues.
if err := validateValuesInLabels(labelValues, len(labelValues)); err != nil {
if err := validateLabelValues(labelValues, len(labelValues)); err != nil {
d.err = err
return d
}

View File

@ -430,7 +430,7 @@ func NewConstHistogram(
buckets map[float64]uint64,
labelValues ...string,
) (Metric, error) {
if err := validateValuesInLabels(labelValues, len(desc.variableLabels)); err != nil {
if err := validateLabelValues(labelValues, len(desc.variableLabels)); err != nil {
return nil, err
}
return &constHistogram{

View File

@ -24,7 +24,7 @@ const reservedLabelPrefix = "__"
var errInconsistentCardinality = errors.New("inconsistent label cardinality")
func validateLabels(labels Labels, expectedNumberOfValues int) error {
func validateValuesInLabels(labels Labels, expectedNumberOfValues int) error {
if len(labels) != expectedNumberOfValues {
return errInconsistentCardinality
}
@ -38,7 +38,7 @@ func validateLabels(labels Labels, expectedNumberOfValues int) error {
return nil
}
func validateValuesInLabels(vals []string, expectedNumberOfValues int) error {
func validateLabelValues(vals []string, expectedNumberOfValues int) error {
if len(vals) != expectedNumberOfValues {
return errInconsistentCardinality
}

View File

@ -543,7 +543,7 @@ func NewConstSummary(
quantiles map[float64]float64,
labelValues ...string,
) (Metric, error) {
if err := validateValuesInLabels(labelValues, len(desc.variableLabels)); err != nil {
if err := validateLabelValues(labelValues, len(desc.variableLabels)); err != nil {
return nil, err
}
return &constSummary{

View File

@ -155,7 +155,7 @@ func (v *valueFunc) Write(out *dto.Metric) error {
// the Collect method. NewConstMetric returns an error if the length of
// labelValues is not consistent with the variable labels in Desc.
func NewConstMetric(desc *Desc, valueType ValueType, value float64, labelValues ...string) (Metric, error) {
if err := validateValuesInLabels(labelValues, len(desc.variableLabels)); err != nil {
if err := validateLabelValues(labelValues, len(desc.variableLabels)); err != nil {
return nil, err
}
return &constMetric{

View File

@ -207,7 +207,7 @@ func (m *metricVec) Reset() {
}
func (m *metricVec) hashLabelValues(vals []string) (uint64, error) {
if err := validateValuesInLabels(vals, len(m.desc.variableLabels)); err != nil {
if err := validateLabelValues(vals, len(m.desc.variableLabels)); err != nil {
return 0, err
}
@ -220,7 +220,7 @@ func (m *metricVec) hashLabelValues(vals []string) (uint64, error) {
}
func (m *metricVec) hashLabels(labels Labels) (uint64, error) {
if err := validateLabels(labels, len(m.desc.variableLabels)); err != nil {
if err := validateValuesInLabels(labels, len(m.desc.variableLabels)); err != nil {
return 0, err
}