code: func SerializeCells(cells []types.Cell, now time.Time) []*pb.MetricsCollection {
  	collections := map[uint64]*pb.MetricsCollection{}
  	dataSets := map[dataSetKey]*pb.MetricsDataSet{}
  
  	for _, c := range cells {
  		// Find the collection, add it if it doesn't exist.
  		targetHash := c.Target.Hash()
  		collection, ok := collections[targetHash]
  		if !ok {
  			collection = &pb.MetricsCollection{}
  			collections[targetHash] = collection
  			c.Target.PopulateProto(collection)
  		}
  
  		// Find the data set, add it if it doesn't exist.
  		key := dataSetKey{targetHash, c.Name}
  		dataSet, ok := dataSets[key]
  		if !ok {
  			dataSet = SerializeDataSet(c)
  			dataSets[key] = dataSet
  			collection.MetricsDataSet = append(collection.MetricsDataSet, dataSet)
  		}
  
  		// Add the data to the data set.
  		dataSet.Data = append(dataSet.Data, SerializeValue(c, now))
  	}
  
  	// Turn the hash into a list and return it.
  	ret := make([]*pb.MetricsCollection, 0, len(collections))
  	for _, collection := range collections {
  		ret = append(ret, collection)
  	}
  	return ret
  }
docs: // SerializeCells creates a MetricsCollection message from a slice of cells.