storage/remote/queue_manager.go
func processExternalLabels(ls tsdbLabels.Labels, externalLabels labels.Labels) labels.Labels {
	i, j, result := 0, 0, make(labels.Labels, 0, len(ls)+len(externalLabels))
	for i < len(ls) && j < len(externalLabels) {
		if ls[i].Name < externalLabels[j].Name {
			result = append(result, labels.Label{
				Name:  ls[i].Name,
				Value: ls[i].Value,
			})
			i++
		} else if ls[i].Name > externalLabels[j].Name {
			result = append(result, externalLabels[j])
			j++
		} else {
			result = append(result, labels.Label{
				Name:  ls[i].Name,
				Value: ls[i].Value,
			})
			i++
			j++
		}
	}
	for ; i < len(ls); i++ {
		result = append(result, labels.Label{
			Name:  ls[i].Name,
			Value: ls[i].Value,
		})
	}
	result = append(result, externalLabels[j:]...)
	return result
}
func processExternalLabels(ls tsdbLabels.Labels, externalLabels labels.Labels) labels.Labels {
	i, j, result := 0, 0, make(labels.Labels, 0, len(ls)+len(externalLabels))
	for i < len(ls) && j < len(externalLabels) {
		if ls[i].Name < externalLabels[j].Name {
			result = append(result, labels.Label{
				Name:  ls[i].Name,
				Value: ls[i].Value,
			})
			i++
		} else if ls[i].Name > externalLabels[j].Name {
			result = append(result, externalLabels[j])
			j++
		} else {
			result = append(result, labels.Label{
				Name:  ls[i].Name,
				Value: ls[i].Value,
			})
			i++
			j++
		}
	}
	for ; i < len(ls); i++ {
		result = append(result, labels.Label{
			Name:  ls[i].Name,
			Value: ls[i].Value,
		})
	}
	result = append(result, externalLabels[j:]...)
	return result
}
func processExternalLabels ( ls tsdbLabels . Labels , externalLabels labels . Labels ) labels . Labels { i , j , result := 0 , 0 , make ( labels . Labels , 0 , len ( ls ) + len ( externalLabels ) ) for i < len ( ls ) && j < len ( externalLabels ) { if ls [ i ] . Name < externalLabels [ j ] . Name { result = append ( result , labels . Label { Name : ls [ i ] . Name , Value : ls [ i ] . Value , } ) i ++ } else if ls [ i ] . Name > externalLabels [ j ] . Name { result = append ( result , externalLabels [ j ] ) j ++ } else { result = append ( result , labels . Label { Name : ls [ i ] . Name , Value : ls [ i ] . Value , } ) i ++ j ++ } } for ; i < len ( ls ) ; i ++ { result = append ( result , labels . Label { Name : ls [ i ] . Name , Value : ls [ i ] . Value , } ) } result = append ( result , externalLabels [ j : ] ... ) return result }
// processExternalLabels merges externalLabels into ls. If ls contains
// a label in externalLabels, the value in ls wins.
processExternalLabels merges externalLabels into ls . If ls contains a label in externalLabels the value in ls wins .