// Update implements Collector and exposes cpu related metrics from /proc/stat and /sys/.../cpu/.
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
}
329859
func (c *componentStatuses) Update(componentStatus *v1.ComponentStatus) (result *v1.ComponentStatus, err error) {
	result = &v1.ComponentStatus{}
	err = c.client.Put().
		Resource("componentstatuses").
		Name(componentStatus.Name).
		Body(componentStatus).
		Do().
		Into(result)
	return
}
437648
func (c *FakeSecrets) Update(secret *corev1.Secret) (result *corev1.Secret, err error) {
	obj, err := c.Fake.
		Invokes(testing.NewUpdateAction(secretsResource, c.ns, secret), &corev1.Secret{})

	if obj == nil {
		return nil, err
	}
	return obj.(*corev1.Secret), err
}
985761
func (m *Monitor) Update(n int) int {
	m.mu.Lock()
	m.update(n)
	m.mu.Unlock()
	return n
}
161443
func (c *aPIServices) Update(aPIService *v1beta1.APIService) (result *v1beta1.APIService, err error) {
	result = &v1beta1.APIService{}
	err = c.client.Put().
		Resource("apiservices").
		Name(aPIService.Name).
		Body(aPIService).
		Do().
		Into(result)
	return
}
608290
func (t *Task) Update(ctx context.Context, resources *types.Any) error {
	if _, err := t.shim.Update(ctx, &shim.UpdateTaskRequest{
		Resources: resources,
	}); err != nil {
		return errdefs.FromGRPC(err)
	}
	return nil
}
295226
func (ha *Heap) Update() {
	ha.m.Lock()
	defer ha.m.Unlock()

	runtime.ReadMemStats(&ha.mem)
	ha.g.Update(int64(ha.mem.HeapAlloc))
}
153675
func (c *statCollector) Update(ch chan<- prometheus.Metric) error {
	var fieldsCount = 5
	cpuTimes, err := getDragonFlyCPUTimes()
	if err != nil {
		return err
	}

	// Export order: user nice sys intr idle
	cpuFields := []string{"user", "nice", "sys", "interrupt", "idle"}
	for i, value := range cpuTimes {
		cpux := fmt.Sprintf("%d", i/fieldsCount)
		ch <- prometheus.MustNewConstMetric(c.cpu, prometheus.CounterValue, value, cpux, cpuFields[i%fieldsCount])
	}

	return nil
}
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)
}
1287311
func (c *textFileCollector) Update(ch chan<- prometheus.Metric) error {
	error := 0.0
	mtimes := map[string]time.Time{}

	// Iterate over files and accumulate their metrics.
	files, err := ioutil.ReadDir(c.path)
	if err != nil && c.path != "" {
		log.Errorf("Error reading textfile collector directory %q: %s", c.path, err)
		error = 1.0
	}

	for _, f := range files {
		if !strings.HasSuffix(f.Name(), ".prom") {
			continue
		}
		path := filepath.Join(c.path, f.Name())
		file, err := os.Open(path)
		if err != nil {
			log.Errorf("Error opening %q: %v", path, err)
			error = 1.0
			continue
		}
		defer file.Close()
		var parser expfmt.TextParser
		parsedFamilies, err := parser.TextToMetricFamilies(file)
		if err != nil {
			log.Errorf("Error parsing %q: %v", path, err)
			error = 1.0
			continue
		}
		if hasTimestamps(parsedFamilies) {
			log.Errorf("Textfile %q contains unsupported client-side timestamps, skipping entire file", path)
			error = 1.0
			continue
		}

		for _, mf := range parsedFamilies {
			if mf.Help == nil {
				help := fmt.Sprintf("Metric read from %s", path)
				mf.Help = &help
			}
		}

		// Only set this once it has been parsed and validated, so that
		// a failure does not appear fresh.
		stat, err := file.Stat()
		if err != nil {
			log.Errorf("Error stat'ing %q: %v", path, err)
			error = 1.0
			continue
		}
		mtimes[f.Name()] = stat.ModTime()

		for _, mf := range parsedFamilies {
			convertMetricFamily(mf, ch)
		}
	}

	c.exportMTimes(mtimes, ch)

	// Export if there were errors.
	ch <- prometheus.MustNewConstMetric(
		prometheus.NewDesc(
			"node_textfile_scrape_error",
			"1 if there was an error opening or reading a file, 0 otherwise",
			nil, nil,
		),
		prometheus.GaugeValue, error,
	)
	return nil
}
659301
func (c *xfsCollector) Update(ch chan<- prometheus.Metric) error {
	stats, err := c.fs.XFSStats()
	if err != nil {
		return fmt.Errorf("failed to retrieve XFS stats: %v", err)
	}

	for _, s := range stats {
		c.updateXFSStats(ch, s)
	}

	return nil
}
385846
func (s *Stack) Update() {
	s.m.Lock()
	defer s.m.Unlock()

	runtime.ReadMemStats(&s.mem)
	s.g.Update(int64(s.mem.StackInuse))
}
375629
func (c *projects) Update(projectResource *project.Project) (result *project.Project, err error) {
	result = &project.Project{}
	err = c.client.Put().
		Resource("projects").
		Name(projectResource.Name).
		Body(projectResource).
		Do().
		Into(result)
	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)
}
1167471
func (d *Stats) Update(x float64) {
	if d.n == 0.0 || x < d.min {
		d.min = x
	}
	if d.n == 0.0 || x > d.max {
		d.max = x
	}
	d.sum += x
	nMinus1 := d.n
	d.n += 1.0
	delta := x - d.mean
	delta_n := delta / d.n
	delta_n2 := delta_n * delta_n
	term1 := delta * delta_n * nMinus1
	d.mean += delta_n
	d.m4 += term1*delta_n2*(d.n*d.n-3*d.n+3.0) + 6*delta_n2*d.m2 - 4*delta_n*d.m3
	d.m3 += term1*delta_n*(d.n-2.0) - 3*delta_n*d.m2
	d.m2 += term1
}
739059
func (e *FGauge) Update(e2 Event) error {
	if e.Type() != e2.Type() {
		return fmt.Errorf("statsd event type conflict: %s vs %s ", e.String(), e2.String())
	}
	e.Value = e2.Payload().(float64)
	return nil
}