// update adds a response into the stats container
183657
func (r *responseStats) update(rsp libhoney.Response) {
	r.lock.Lock()
	defer r.lock.Unlock()
	r.count += 1
	r.statusCodes[rsp.StatusCode] += 1
	r.bodies[strings.TrimSpace(string(rsp.Body))] += 1
	if rsp.Err != nil {
		r.errors[rsp.Err.Error()] += 1
	}
	if r.minDuration == 0 {
		r.minDuration = rsp.Duration
	}
	if rsp.Duration < r.minDuration {
		r.minDuration = rsp.Duration
	} else if rsp.Duration > r.maxDuration {
		r.maxDuration = rsp.Duration
	}
	r.sumDuration += rsp.Duration
	ev := rsp.Metadata.(event.Event)
	r.event = &ev
}
613115
func (su *StatusUpdater) Update(status interface{}) {
	su.Status = status.(string)

	// initialize event ID
	if su.EventID == 0 {
		su.EventID = time.Now().UnixNano()
	}
}
741860
func (rs *RoleService) Update(ctx context.Context, roleName string, role *Role) (
	r *Role, resp *APIResponse, err error) {

	r = &Role{}
	_, resp, err = rs.client.putAction(ctx, &APIClientRequest{
		APIVersion:   apiV1,
		Path:         fmt.Sprintf("admin/security/roles/%s", roleName),
		ResponseBody: r,
		RequestBody:  role,
	})

	return
}
1253436
func (e *ErrorRate) Update(rate float64) {
	e.QueryTotal++
	e.ErrorTotal += rate
}
502338
func (s *ServicesService) Update(serviceID uint, service *Service) (*http.Response, error) {
	u := fmt.Sprintf("services/%d", serviceID)
	req, err := s.client.NewRequest("PUT", u, service)
	if err != nil {
		return nil, err
	}

	return s.client.Do(req, nil)
}
147158
func (r *Record) Update(recordInfo Info, args ...string) (status *Status, err error) {
	switch len(args) {
	case 0:
		_, err = r.Put(r.uri("/records"), recordInfo, &status)
	case 1:
		_, err = r.Put(r.uri("/records/%s", args...), recordInfo, &status)
	case 2:
		_, err = r.Put(r.uri("/records/%s/%s", args...), recordInfo, &status)
	default:
		err = r.formatCallError("Update", args...)
	}
	return
}
954138
func (t *StandardTimer) Update(d time.Duration) {
	t.mutex.Lock()
	defer t.mutex.Unlock()
	t.histogram.Update(int64(d))
	t.meter.Mark(1)
}
558694
func (m *Metrics) Update(status StatusType) Metrics {
	m.Status = status
	m.Health = 0
	m.record = append(m.record, status)

	if len(m.record) > 100 {
		m.record = m.record[1:]
	}

	for _, result := range m.record {
		m.Health += float64(result)
	}

	m.Health = 1.0 - m.Health/float64(len(m.record))

	if ts := time.Now(); m.Status != StatusUp {
		m.Uptime, m.lastTs = 0, ts
	} else {
		m.Uptime, m.lastTs = m.Uptime+ts.Sub(m.lastTs)/time.Second, ts
	}

	return *m
}
25141
func (r *RoomService) Update(id string, roomReq *UpdateRoomRequest) (*http.Response, error) {
	req, err := r.client.NewRequest("PUT", fmt.Sprintf("room/%s", id), nil, roomReq)
	if err != nil {
		return nil, err
	}

	return r.client.Do(req, nil)
}
99506
func (e *Timing) Update(e2 Event) error {
	if e.Type() != e2.Type() {
		return fmt.Errorf("statsd event type conflict: %s vs %s ", e.String(), e2.String())
	}
	p := e2.Payload().(map[string]int64)
	e.Count += p["cnt"]
	e.Value += p["val"]
	e.Min = minInt64(e.Min, p["min"])
	e.Max = maxInt64(e.Max, p["max"])
	return nil
}
159556
func (q *Query) Update(scan ...interface{}) (Result, error) {
	return q.update(scan, false)
}
453985
func (c *bcacheCollector) Update(ch chan<- prometheus.Metric) error {
	stats, err := c.fs.BcacheStats()
	if err != nil {
		return fmt.Errorf("failed to retrieve bcache stats: %v", err)
	}

	for _, s := range stats {
		c.updateBcacheStats(ch, s)
	}
	return nil
}
1060876
func (c *Counter) Update(v int64) {
	atomic.AddInt64(&c.count, v)
}
1327322
func (c *ContainerServer) Update() error {
	c.updateLock.Lock()
	defer c.updateLock.Unlock()

	containers, err := c.store.Containers()
	if err != nil && !os.IsNotExist(errors.Cause(err)) {
		logrus.Warnf("could not read containers and sandboxes: %v", err)
		return err
	}
	newPods := map[string]*storage.RuntimeContainerMetadata{}
	oldPods := map[string]string{}
	removedPods := map[string]string{}
	newPodContainers := map[string]*storage.RuntimeContainerMetadata{}
	oldPodContainers := map[string]string{}
	removedPodContainers := map[string]string{}
	for i := range containers {
		container := &containers[i]
		if c.HasSandbox(container.ID) {
			// FIXME: do we need to reload/update any info about the sandbox?
			oldPods[container.ID] = container.ID
			oldPodContainers[container.ID] = container.ID
			continue
		}
		if c.GetContainer(container.ID) != nil {
			// FIXME: do we need to reload/update any info about the container?
			oldPodContainers[container.ID] = container.ID
			continue
		}
		// not previously known, so figure out what it is
		metadata, err2 := c.storageRuntimeServer.GetContainerMetadata(container.ID)
		if err2 != nil {
			logrus.Errorf("error parsing metadata for %s: %v, ignoring", container.ID, err2)
			continue
		}
		if metadata.Pod {
			newPods[container.ID] = &metadata
		} else {
			newPodContainers[container.ID] = &metadata
		}
	}
	c.ctrIDIndex.Iterate(func(id string) {
		if _, ok := oldPodContainers[id]; !ok {
			// this container's ID wasn't in the updated list -> removed
			removedPodContainers[id] = id
		} else {
			ctr := c.GetContainer(id)
			if ctr != nil {
				// if the container exists, update its state
				c.ContainerStateFromDisk(c.GetContainer(id))
			}
		}
	})
	for removedPodContainer := range removedPodContainers {
		// forget this container
		ctr := c.GetContainer(removedPodContainer)
		if ctr == nil {
			logrus.Warnf("bad state when getting container removed %+v", removedPodContainer)
			continue
		}
		c.ReleaseContainerName(ctr.Name())
		c.RemoveContainer(ctr)
		if err = c.ctrIDIndex.Delete(ctr.ID()); err != nil {
			return err
		}
		logrus.Debugf("forgetting removed pod container %s", ctr.ID())
	}
	c.PodIDIndex().Iterate(func(id string) {
		if _, ok := oldPods[id]; !ok {
			// this pod's ID wasn't in the updated list -> removed
			removedPods[id] = id
		}
	})
	for removedPod := range removedPods {
		// forget this pod
		sb := c.GetSandbox(removedPod)
		if sb == nil {
			logrus.Warnf("bad state when getting pod to remove %+v", removedPod)
			continue
		}
		podInfraContainer := sb.InfraContainer()
		c.ReleaseContainerName(podInfraContainer.Name())
		c.RemoveContainer(podInfraContainer)
		if err = c.ctrIDIndex.Delete(podInfraContainer.ID()); err != nil {
			return err
		}
		sb.RemoveInfraContainer()
		c.ReleasePodName(sb.Name())
		if err := c.RemoveSandbox(sb.ID()); err != nil {
			logrus.Warnf("failed to remove sandbox ID %s: %v", sb.ID(), err)
		}
		if err = c.podIDIndex.Delete(sb.ID()); err != nil {
			return err
		}
		logrus.Debugf("forgetting removed pod %s", sb.ID())
	}
	for sandboxID := range newPods {
		// load this pod
		if err = c.LoadSandbox(sandboxID); err != nil {
			logrus.Warnf("could not load new pod sandbox %s: %v, ignoring", sandboxID, err)
		} else {
			logrus.Debugf("loaded new pod sandbox %s: %v", sandboxID, err)
		}
	}
	for containerID := range newPodContainers {
		// load this container
		if err = c.LoadContainer(containerID); err != nil {
			logrus.Warnf("could not load new sandbox container %s: %v, ignoring", containerID, err)
		} else {
			logrus.Debugf("loaded new pod container %s: %v", containerID, err)
		}
	}
	return nil
}
979309
func (c *cpuCollector) Update(ch chan<- prometheus.Metric) error {
	if err := c.updateStat(ch); err != nil {
		return err
	}
	if err := c.updateThermalThrottle(ch); err != nil {
		return err
	}
	return nil
}
422811
func (charts *ChartData) Update() {
	for _, updater := range charts.updaters {
		stateID := charts.StateID()
		rows, cancel, err := updater.Fetcher(charts)
		if err != nil {
			err = fmt.Errorf("error encountered during charts %s update. aborting update: %v", updater.Tag, err)
		} else {
			charts.mtx.Lock()
			if !charts.validState(stateID) {
				err = fmt.Errorf("state change detected during charts %s update. aborting update", updater.Tag)
			} else {
				err = updater.Appender(charts, rows)
				if err != nil {
					err = fmt.Errorf("error detected during charts %s append. aborting update: %v", updater.Tag, err)
				}
			}
			charts.mtx.Unlock()
		}
		cancel()
		if err != nil {
			log.Warnf("%v", err)
			return
		}
	}
}
76342
func (c *Client) Update(args params.ApplicationUpdate) error {
	return c.facade.FacadeCall("Update", args, nil)
}