// FilterMetricName returns true for a metric which matches allow, or if no allow rules are present,
// if it didn't match deny. Returns false otherwise.
542507
func (f *FilteredForwarder) FilterMetricName(metricName string) bool {
	denied := false
	for _, a := range f.deny {
		if a.Match([]byte(metricName)) {
			denied = true
			break
		}
	}
	found := false
	for _, a := range f.allow {
		if a.Match([]byte(metricName)) {
			denied = false
			found = true
			break
		}
	}
	return found || (len(f.allow) == 0 && !denied)
}
145544
func (m *Metrics) UpdateFilter(allow, block []string) {
	m.UpdateFilterAndLabels(allow, block, m.AllowedLabels, m.BlockedLabels)
}
1146456
func (s *MetricDatum) SetMetricName(v string) *MetricDatum {
	s.MetricName = &v
	return s
}
864394
func (s *RateBasedRule) SetMetricName(v string) *RateBasedRule {
	s.MetricName = &v
	return s
}
430390
func (s *Metric) SetMetricName(v string) *Metric {
	s.MetricName = &v
	return s
}
851454
func (_m *API) PostMetric(metricName string, metricValue string) (string, error) {
	ret := _m.Called(metricName, metricValue)

	var r0 string
	if rf, ok := ret.Get(0).(func(string, string) string); ok {
		r0 = rf(metricName, metricValue)
	} else {
		r0 = ret.Get(0).(string)
	}

	var r1 error
	if rf, ok := ret.Get(1).(func(string, string) error); ok {
		r1 = rf(metricName, metricValue)
	} else {
		r1 = ret.Error(1)
	}

	return r0, r1
}
455739
func validateMetricNamespace(ns core.Namespace) error {
	value := ""
	for _, i := range ns {
		// A dynamic element requires the name while a static element does not.
		if i.Name != "" && i.Value != "*" {
			return errorMetricStaticElementHasName(i.Value, i.Name, ns.String())
		}
		if i.Name == "" && i.Value == "*" {
			return errorMetricDynamicElementHasNoName(i.Value, ns.String())
		}
		if isTuple(i.Value) {
			return errorMetricElementHasTuple(i.Value, ns.String())
		}
		value += i.Value
	}
	// plugin should NOT advertise metrics ending with a wildcard
	if strings.HasSuffix(value, "*") {
		return errorMetricEndsWithAsterisk(ns.String())
	}
	return nil
}
73867
func (mtt *mttNode) GetMetric(ns []string, ver int) (*metricType, error) {
	mts, err := mtt.GetMetrics(ns, ver)
	if err != nil {
		return nil, err
	}
	// there is an expectation that only one metric should be fitted
	if len(mts) > 1 {
		return nil, fmt.Errorf("Incoming namespace `%s` is too ambiguous (version: %d)", "/"+strings.Join(ns, "/"), ver)
	}
	return mts[0], nil
}
440166
func (s *MetricData) SetMetricName(v string) *MetricData {
	s.MetricName = &v
	return s
}
168945
func validName(s string) bool {
	_, ok := dns.IsDomainName(s)
	if !ok {
		return false
	}
	if len(dns.Name(s).String()) > 255 {
		return false
	}

	return true
}
152061
func (f *Filter) filterTags(metric telegraf.Metric) {
	filterKeys := []string{}
	if f.tagInclude != nil {
		for _, tag := range metric.TagList() {
			if !f.tagInclude.Match(tag.Key) {
				filterKeys = append(filterKeys, tag.Key)
			}
		}
	}
	for _, key := range filterKeys {
		metric.RemoveTag(key)
	}

	if f.tagExclude != nil {
		for _, tag := range metric.TagList() {
			if f.tagExclude.Match(tag.Key) {
				filterKeys = append(filterKeys, tag.Key)
			}
		}
	}
	for _, key := range filterKeys {
		metric.RemoveTag(key)
	}
}
857356
func (r *PCPRegistry) HasMetric(name string) bool {
	r.metricslock.RLock()
	defer r.metricslock.RUnlock()

	_, present := r.metrics[name]
	return present
}
961853
func (a *HistoricalApi) processMetricNamesRequest(key core.HistoricalKey, response *restful.Response) {
	if resp, err := a.historicalSource.GetMetricNames(key); err != nil {
		response.WriteError(http.StatusInternalServerError, err)
	} else {
		response.WriteEntity(resp)
	}
}
732553
func dnToMetric(dn string, o *Openldap) string {
	if o.ReverseMetricNames {
		var metricParts []string

		dn = strings.Trim(dn, " ")
		dn = strings.Replace(dn, " ", "_", -1)
		dn = strings.Replace(dn, "cn=", "", -1)
		dn = strings.ToLower(dn)
		metricParts = strings.Split(dn, ",")
		for i, j := 0, len(metricParts)-1; i < j; i, j = i+1, j-1 {
			metricParts[i], metricParts[j] = metricParts[j], metricParts[i]
		}
		return strings.Join(metricParts[1:], "_")
	} else {
		metricName := strings.Trim(dn, " ")
		metricName = strings.Replace(metricName, " ", "_", -1)
		metricName = strings.ToLower(metricName)
		metricName = strings.TrimPrefix(metricName, "cn=")
		metricName = strings.Replace(metricName, strings.ToLower("cn=Monitor"), "", -1)
		metricName = strings.Replace(metricName, "cn=", "_", -1)
		return strings.Replace(metricName, ",", "", -1)
	}
}
873526
func normalizeMetric(name string) string {
	// Special cases
	r := strings.NewReplacer("VSchema", "vschema", "VtGate", "vtgate")
	name = r.Replace(name)

	return stats.GetSnakeName(name)
}
504159
func (sink *influxdbSink) checkSanitizedMetricName(name string) error {
	if !metricAllowedChars.MatchString(name) {
		return fmt.Errorf("Invalid metric name %q", name)
	}

	return nil
}
365941
func (s *WebACL) SetMetricName(v string) *WebACL {
	s.MetricName = &v
	return s
}