agent/handlers/v2/stats_response.go
func NewTaskStatsResponse(taskARN string,
	state dockerstate.TaskEngineState,
	statsEngine stats.Engine) (map[string]*types.StatsJSON, error) {

	containerMap, ok := state.ContainerMapByArn(taskARN)
	if !ok {
		return nil, errors.Errorf(
			"v2 task stats response: unable to lookup containers for task %s",
			taskARN)
	}

	resp := make(map[string]*types.StatsJSON)
	for _, dockerContainer := range containerMap {
		containerID := dockerContainer.DockerID
		dockerStats, err := statsEngine.ContainerDockerStats(taskARN, containerID)
		if err != nil {
			seelog.Warnf("V2 task stats response: Unable to get stats for container '%s' for task '%s': %v",
				containerID, taskARN, err)
			resp[containerID] = nil
			continue
		}

		resp[containerID] = dockerStats
	}

	return resp, nil
}
func NewTaskStatsResponse(taskARN string,
	state dockerstate.TaskEngineState,
	statsEngine stats.Engine) (map[string]*types.StatsJSON, error) {

	containerMap, ok := state.ContainerMapByArn(taskARN)
	if !ok {
		return nil, errors.Errorf(
			"v2 task stats response: unable to lookup containers for task %s",
			taskARN)
	}

	resp := make(map[string]*types.StatsJSON)
	for _, dockerContainer := range containerMap {
		containerID := dockerContainer.DockerID
		dockerStats, err := statsEngine.ContainerDockerStats(taskARN, containerID)
		if err != nil {
			seelog.Warnf("V2 task stats response: Unable to get stats for container '%s' for task '%s': %v",
				containerID, taskARN, err)
			resp[containerID] = nil
			continue
		}

		resp[containerID] = dockerStats
	}

	return resp, nil
}
// NewTaskStatsResponse returns a new task stats response object