// Handles stats summary requests to /stats/summary
// If "only_cpu_and_memory" GET param is true then only cpu and memory is returned in response.
424886
func (h *handler) handleSummary(request *restful.Request, response *restful.Response) {
	onlyCPUAndMemory := false
	request.Request.ParseForm()
	if onlyCluAndMemoryParam, found := request.Request.Form["only_cpu_and_memory"]; found &&
		len(onlyCluAndMemoryParam) == 1 && onlyCluAndMemoryParam[0] == "true" {
		onlyCPUAndMemory = true
	}
	var summary *statsapi.Summary
	var err error
	if onlyCPUAndMemory {
		summary, err = h.summaryProvider.GetCPUAndMemoryStats()
	} else {
		// external calls to the summary API use cached stats
		forceStatsUpdate := false
		summary, err = h.summaryProvider.Get(forceStatsUpdate)
	}
	if err != nil {
		handleError(response, "/stats/summary", err)
	} else {
		writeResponse(response, summary)
	}
}
757164
func (t *Task) Stats(ctx context.Context) (*types.Any, error) {
	t.mu.Lock()
	defer t.mu.Unlock()
	if t.cg == nil {
		return nil, errors.Wrap(errdefs.ErrNotFound, "cgroup does not exist")
	}
	stats, err := t.cg.Stat(cgroups.IgnoreNotExist)
	if err != nil {
		return nil, err
	}
	return typeurl.MarshalAny(stats)
}
133316
func (p *Plan) Stats() PlanStats {
	var ret PlanStats
	for _, r := range p.Resources {
		switch r.Action {
		case plans.Create:
			ret.ToAdd++
		case plans.Update:
			ret.ToChange++
		case plans.DeleteThenCreate, plans.CreateThenDelete:
			ret.ToAdd++
			ret.ToDestroy++
		case plans.Delete:
			ret.ToDestroy++
		}
	}
	return ret
}
619898
func (fn InventoryGetHandlerFunc) Handle(params InventoryGetParams, principal interface{}) middleware.Responder {
	return fn(params, principal)
}
543909
func Handle(writer http.ResponseWriter, req *http.Request) {

	var (
		work Workload
		err  error
		res  Result
		body []byte
	)

	body, err = ioutil.ReadAll(req.Body)

	if err != nil {
		str := fmt.Sprintf("[Handle] Unable to read in the body of the request: %s", body)
		log.Error(str)
		http.Error(writer, str, 500)
		return
	}

	err = json.Unmarshal(body, &work)

	if err != nil {
		str := fmt.Sprintf("[ERROR] Unable to parse workload JSON: %s", err)
		http.Error(writer, str, 500)
		return
	}

	err = process(work, &res)

	if err != nil {
		str := fmt.Sprintf("[ERROR] Problems processing workload: %s", err)
		http.Error(writer, str, 500)
		return
	}

	body, _ = json.Marshal(res)
	writer.Write(body)
}
1154436
func (f FuncRespHandler) Handle(resp *http.Response, ctx *ProxyCtx) *http.Response {
	return f(resp, ctx)
}
196337
func RequestStats() gin.HandlerFunc {
	return func(c *gin.Context) {
		start := time.Now()

		c.Next()

		req := metrics.GetOrRegisterMeter(ginRequestMetric, nil)
		req.Mark(1)

		latency := metrics.GetOrRegisterTimer(ginLatencyMetric, nil)
		latency.UpdateSince(start)

		status := metrics.GetOrRegisterMeter(fmt.Sprintf("%s.%d", ginStatusMetric, c.Writer.Status()), nil)
		status.Mark(1)
	}
}
355434
func (h *Handle) HandleUpdateStats(is infoschema.InfoSchema) error {
	sql := "select table_id, hist_id, is_index, feedback from mysql.stats_feedback order by table_id, hist_id, is_index"
	rows, _, err := h.restrictedExec.ExecRestrictedSQL(nil, sql)
	if len(rows) == 0 || err != nil {
		return errors.Trace(err)
	}

	var groupedRows [][]chunk.Row
	preIdx := 0
	tableID, histID, isIndex := rows[0].GetInt64(0), rows[0].GetInt64(1), rows[0].GetInt64(2)
	for i := 1; i < len(rows); i++ {
		row := rows[i]
		if row.GetInt64(0) != tableID || row.GetInt64(1) != histID || row.GetInt64(2) != isIndex {
			groupedRows = append(groupedRows, rows[preIdx:i])
			tableID, histID, isIndex = row.GetInt64(0), row.GetInt64(1), row.GetInt64(2)
			preIdx = i
		}
	}
	groupedRows = append(groupedRows, rows[preIdx:])

	for _, rows := range groupedRows {
		if err := h.handleSingleHistogramUpdate(is, rows); err != nil {
			return errors.Trace(err)
		}
	}
	return nil
}
418143
func (i *AgentIPC) handleStats(client *IPCClient, seq uint64) error {
	header := responseHeader{
		Seq:   seq,
		Error: "",
	}
	resp := i.agent.Stats()
	return client.Send(&header, resp)
}
299208
func NewRequestsTotalStatsHandler(sub Subsystem, vec *prometheus.CounterVec) *RequestsTotalStatsHandler {
	return &RequestsTotalStatsHandler{
		baseStatsHandler: baseStatsHandler{
			subsystem: sub,
			collector: vec,
		},
		vec: vec,
	}
}
357348
func (r *SearchRequest) Stats(statsGroup ...string) *SearchRequest {
	r.searchSource = r.searchSource.Stats(statsGroup...)
	return r
}
481258
func (it *Materialize) Stats() graph.IteratorStats {
	overhead := int64(2)
	var (
		size  int64
		exact bool
	)
	if it.expectSize > 0 {
		size, exact = it.expectSize, false
	} else {
		size, exact = it.Size()
	}
	subitStats := it.subIt.Stats()
	return graph.IteratorStats{
		ContainsCost: overhead * subitStats.NextCost,
		NextCost:     overhead * subitStats.NextCost,
		Size:         size,
		ExactSize:    exact,
		Next:         it.runstats.Next,
		Contains:     it.runstats.Contains,
	}
}
582084
func (c *Client) GetStats(i *GetStatsInput) (*StatsResponse, error) {

	p := "/stats"

	if i.Service != "" {
		p = fmt.Sprintf("%s/service/%s", p, i.Service)
	}

	if i.Field != "" {
		p = fmt.Sprintf("%s/field/%s", p, i.Field)
	}

	r, err := c.Get(p, &RequestOptions{
		Params: map[string]string{
			"from":   i.From,
			"to":     i.To,
			"by":     i.By,
			"region": i.Region,
		},
	})
	if err != nil {
		return nil, err
	}

	var sr *StatsResponse
	if err := decodeJSON(&sr, r.Body); err != nil {
		return nil, err
	}

	return sr, nil
}
873609
func (s *BulkProcessorService) Stats(wantStats bool) *BulkProcessorService {
	s.wantStats = wantStats
	return s
}
254732
func (c *managedHandleImpl) Handle() (interface{}, error) {
	if atomic.LoadInt32(&c.isActive) == 0 {
		return c.handle, errors.New("Resource handle is no longer valid")
	}
	return c.handle, nil
}
1136224
func (fn GetOrderHandlerFunc) Handle(params GetOrderParams, principal *models.Principal) middleware.Responder {
	return fn(params, principal)
}
68784
func (fn DeleteTaskHandlerFunc) Handle(params DeleteTaskParams, principal interface{}) middleware.Responder {
	return fn(params, principal)
}