agent/handlers/v3/container_stats_handler.go
func ContainerStatsHandler(state dockerstate.TaskEngineState, statsEngine stats.Engine) func(http.ResponseWriter, *http.Request) {
	return func(w http.ResponseWriter, r *http.Request) {
		taskARN, err := getTaskARNByRequest(r, state)
		if err != nil {
			errResponseJSON, _ := json.Marshal(
				fmt.Sprintf("V3 container stats handler: unable to get task arn from request: %s", err.Error()))
			utils.WriteJSONToResponse(w, http.StatusBadRequest, errResponseJSON, utils.RequestTypeTaskStats)
			return
		}

		containerID, err := getContainerIDByRequest(r, state)
		if err != nil {
			responseJSON, _ := json.Marshal(
				fmt.Sprintf("V3 container stats handler: unable to get container ID from request: %s", err.Error()))
			utils.WriteJSONToResponse(w, http.StatusBadRequest, responseJSON, utils.RequestTypeContainerStats)
			return
		}

		seelog.Infof("V3 container stats handler: writing response for container '%s'", containerID)

		// v3 handler shares the same container stats response format with v2 handler.
		v2.WriteContainerStatsResponse(w, taskARN, containerID, statsEngine)
	}
}
func ContainerStatsHandler(state dockerstate.TaskEngineState, statsEngine stats.Engine) func(http.ResponseWriter, *http.Request) {
	return func(w http.ResponseWriter, r *http.Request) {
		taskARN, err := getTaskARNByRequest(r, state)
		if err != nil {
			errResponseJSON, _ := json.Marshal(
				fmt.Sprintf("V3 container stats handler: unable to get task arn from request: %s", err.Error()))
			utils.WriteJSONToResponse(w, http.StatusBadRequest, errResponseJSON, utils.RequestTypeTaskStats)
			return
		}

		containerID, err := getContainerIDByRequest(r, state)
		if err != nil {
			responseJSON, _ := json.Marshal(
				fmt.Sprintf("V3 container stats handler: unable to get container ID from request: %s", err.Error()))
			utils.WriteJSONToResponse(w, http.StatusBadRequest, responseJSON, utils.RequestTypeContainerStats)
			return
		}

		seelog.Infof("V3 container stats handler: writing response for container '%s'", containerID)

		// v3 handler shares the same container stats response format with v2 handler.
		v2.WriteContainerStatsResponse(w, taskARN, containerID, statsEngine)
	}
}
func ContainerStatsHandler ( state dockerstate . TaskEngineState , statsEngine stats . Engine ) func ( http . ResponseWriter , * http . Request ) { return func ( w http . ResponseWriter , r * http . Request ) { taskARN , err := getTaskARNByRequest ( r , state ) if err != nil { errResponseJSON , _ := json . Marshal ( fmt . Sprintf ( " " , err . Error ( ) ) ) utils . WriteJSONToResponse ( w , http . StatusBadRequest , errResponseJSON , utils . RequestTypeTaskStats ) return } containerID , err := getContainerIDByRequest ( r , state ) if err != nil { responseJSON , _ := json . Marshal ( fmt . Sprintf ( " " , err . Error ( ) ) ) utils . WriteJSONToResponse ( w , http . StatusBadRequest , responseJSON , utils . RequestTypeContainerStats ) return } seelog . Infof ( " " , containerID ) // v3 handler shares the same container stats response format with v2 handler. v2 . WriteContainerStatsResponse ( w , taskARN , containerID , statsEngine ) } }
// ContainerStatsHandler returns the handler method for handling container stats requests.
ContainerStatsHandler returns the handler method for handling container stats requests .