var NameValidationScheme … var NameEscapingScheme … type ValidationScheme … const LegacyValidation … const UTF8Validation … type EscapingScheme … const NoEscaping … const UnderscoreEscaping … const DotsEscaping … const ValueEncodingEscaping … const EscapingKey … const AllowUTF8 … const EscapeUnderscores … const EscapeDots … const EscapeValues … var MetricNameRE … type Metric … // Equal compares the metrics. func (m Metric) Equal(o Metric) bool { … } // Before compares the metrics' underlying label sets. func (m Metric) Before(o Metric) bool { … } // Clone returns a copy of the Metric. func (m Metric) Clone() Metric { … } func (m Metric) String() string { … } // Fingerprint returns a Metric's Fingerprint. func (m Metric) Fingerprint() Fingerprint { … } // FastFingerprint returns a Metric's Fingerprint calculated by a faster hashing // algorithm, which is, however, more susceptible to hash collisions. func (m Metric) FastFingerprint() Fingerprint { … } // IsValidMetricName returns true iff name matches the pattern of MetricNameRE // for legacy names, and iff it's valid UTF-8 if the UTF8Validation scheme is // selected. func IsValidMetricName(n LabelValue) bool { … } // IsValidLegacyMetricName is similar to IsValidMetricName but always uses the // legacy validation scheme regardless of the value of NameValidationScheme. // This function, however, does not use MetricNameRE for the check but a much // faster hardcoded implementation. func IsValidLegacyMetricName(n LabelValue) bool { … } // EscapeMetricFamily escapes the given metric names and labels with the given // escaping scheme. Returns a new object that uses the same pointers to fields // when possible and creates new escaped versions so as not to mutate the // input. func EscapeMetricFamily(v *dto.MetricFamily, scheme EscapingScheme) *dto.MetricFamily { … } func metricNeedsEscaping(m *dto.Metric) bool { … } const lowerhex … // EscapeName escapes the incoming name according to the provided escaping // scheme. Depending on the rules of escaping, this may cause no change in the // string that is returned. (Especially NoEscaping, which by definition is a // noop). This function does not do any validation of the name. func EscapeName(name string, scheme EscapingScheme) string { … } // lower function taken from strconv.atoi func lower(c byte) byte { … } // UnescapeName unescapes the incoming name according to the provided escaping // scheme if possible. Some schemes are partially or totally non-roundtripable. // If any error is enountered, returns the original input. func UnescapeName(name string, scheme EscapingScheme) string { … } func isValidLegacyRune(b rune, i int) bool { … } func (e EscapingScheme) String() string { … } func ToEscapingScheme(s string) (EscapingScheme, error) { … }