scrape/target.go
func (t *Target) URL() *url.URL {
	params := url.Values{}

	for k, v := range t.params {
		params[k] = make([]string, len(v))
		copy(params[k], v)
	}
	for _, l := range t.labels {
		if !strings.HasPrefix(l.Name, model.ParamLabelPrefix) {
			continue
		}
		ks := l.Name[len(model.ParamLabelPrefix):]

		if len(params[ks]) > 0 {
			params[ks][0] = l.Value
		} else {
			params[ks] = []string{l.Value}
		}
	}

	return &url.URL{
		Scheme:   t.labels.Get(model.SchemeLabel),
		Host:     t.labels.Get(model.AddressLabel),
		Path:     t.labels.Get(model.MetricsPathLabel),
		RawQuery: params.Encode(),
	}
}
func (t *Target) URL() *url.URL {
	params := url.Values{}

	for k, v := range t.params {
		params[k] = make([]string, len(v))
		copy(params[k], v)
	}
	for _, l := range t.labels {
		if !strings.HasPrefix(l.Name, model.ParamLabelPrefix) {
			continue
		}
		ks := l.Name[len(model.ParamLabelPrefix):]

		if len(params[ks]) > 0 {
			params[ks][0] = l.Value
		} else {
			params[ks] = []string{l.Value}
		}
	}

	return &url.URL{
		Scheme:   t.labels.Get(model.SchemeLabel),
		Host:     t.labels.Get(model.AddressLabel),
		Path:     t.labels.Get(model.MetricsPathLabel),
		RawQuery: params.Encode(),
	}
}
func ( t * Target ) URL ( ) * url . URL { params := url . Values { } for k , v := range t . params { params [ k ] = make ( [ ] string , len ( v ) ) copy ( params [ k ] , v ) } for _ , l := range t . labels { if ! strings . HasPrefix ( l . Name , model . ParamLabelPrefix ) { continue } ks := l . Name [ len ( model . ParamLabelPrefix ) : ] if len ( params [ ks ] ) > 0 { params [ ks ] [ 0 ] = l . Value } else { params [ ks ] = [ ] string { l . Value } } } return & url . URL { Scheme : t . labels . Get ( model . SchemeLabel ) , Host : t . labels . Get ( model . AddressLabel ) , Path : t . labels . Get ( model . MetricsPathLabel ) , RawQuery : params . Encode ( ) , } }
// URL returns a copy of the target's URL.
URL returns a copy of the target s URL .