code: func cadvisorInfoToUserDefinedMetrics(info *cadvisorapiv2.ContainerInfo) []statsapi.UserDefinedMetric {
  	type specVal struct {
  		ref     statsapi.UserDefinedMetricDescriptor
  		valType cadvisorapiv1.DataType
  		time    time.Time
  		value   float64
  	}
  	udmMap := map[string]*specVal{}
  	for _, spec := range info.Spec.CustomMetrics {
  		udmMap[spec.Name] = &specVal{
  			ref: statsapi.UserDefinedMetricDescriptor{
  				Name:  spec.Name,
  				Type:  statsapi.UserDefinedMetricType(spec.Type),
  				Units: spec.Units,
  			},
  			valType: spec.Format,
  		}
  	}
  	for _, stat := range info.Stats {
  		for name, values := range stat.CustomMetrics {
  			specVal, ok := udmMap[name]
  			if !ok {
  				klog.Warningf("spec for custom metric %q is missing from cAdvisor output. Spec: %+v, Metrics: %+v", name, info.Spec, stat.CustomMetrics)
  				continue
  			}
  			for _, value := range values {
  				// Pick the most recent value
  				if value.Timestamp.Before(specVal.time) {
  					continue
  				}
  				specVal.time = value.Timestamp
  				specVal.value = value.FloatValue
  				if specVal.valType == cadvisorapiv1.IntType {
  					specVal.value = float64(value.IntValue)
  				}
  			}
  		}
  	}
  	var udm []statsapi.UserDefinedMetric
  	for _, specVal := range udmMap {
  		udm = append(udm, statsapi.UserDefinedMetric{
  			UserDefinedMetricDescriptor: specVal.ref,
  			Time:                        metav1.NewTime(specVal.time),
  			Value:                       specVal.value,
  		})
  	}
  	return udm
  }
docs: // cadvisorInfoToUserDefinedMetrics returns the statsapi.UserDefinedMetric
  // converted from the container info from cadvisor.