// Record the metrics and write using storage.PointWriter interface.
963509
func (s PointWriter) Record(collected MetricsCollection) error {
	ps, err := collected.MetricsSlice.Points()
	if err != nil {
		return err
	}
	ps, err = tsdb.ExplodePoints(collected.OrgID, collected.BucketID, ps)
	if err != nil {
		return err
	}

	return s.Writer.WritePoints(context.TODO(), ps)
}
1352835
func (s *XPackWatcherStatsService) Metric(metric string) *XPackWatcherStatsService {
	s.metric = metric
	return s
}
37858
func (l *logger) Write(p []byte) (n int, err error) {
	l.locker.Lock()
	for _, w := range l.writers {
		n, err = w.Output().Write(p)
		if err != nil {
			return
		}
	}
	l.locker.Unlock()
	return
}
1302552
func MeasuringPointsWrite(w io.Writer, ff func(MeasuringPoint) bool) error {
	fmt.Fprint(w, etmTLine)
	fmt.Fprint(w, etmHeader)
	fmt.Fprint(w, etmTLine)
	if err := MeasuringPointsDo(func(mp MeasuringPoint) {
		if ff(mp) {
			fmt.Fprintf(w, etmFormat, mp.ID(), mp.Count(), mp.MinDuration(), mp.MaxDuration(), mp.AvgDuration())
		}
	}); err != nil {
		return err
	}
	fmt.Fprint(w, etmTLine)
	return nil
}
1184162
func (c *CountingWriter) Write(buf []byte) (int, error) {
	amount, err := c.Writer.Write(buf)
	c.Count += int64(amount)
	return amount, err
}
346701
func (w *BufferedLogWriter) Write(entry loggo.Entry) {
	w.in <- &LogRecord{
		Time:     entry.Timestamp,
		Module:   entry.Module,
		Location: fmt.Sprintf("%s:%d", filepath.Base(entry.Filename), entry.Line),
		Level:    entry.Level,
		Message:  entry.Message,
	}
}
421074
func (m *MockGauge) Write(arg0 *go0.Metric) error {
	ret := m.ctrl.Call(m, "Write", arg0)
	ret0, _ := ret[0].(error)
	return ret0
}
1326774
func (this Table) Write(writer io.WriteSeeker) (err error) {
	this.Header.PartitionsCRC = this.calcPartitionsCRC()
	if headerPos, ok := mul(int64(this.SectorSize), int64(this.Header.HeaderStartLBA)); ok {
		writer.Seek(headerPos, 0)
	}
	err = this.Header.write(writer, true)
	if err != nil {
		return
	}
	if partTablePos, ok := mul(int64(this.SectorSize), int64(this.Header.PartitionsTableStartLBA)); ok {
		writer.Seek(partTablePos, 0)
	}
	for _, part := range this.Partitions {
		err = part.write(writer, this.Header.PartitionEntrySize)
		if err != nil {
			return
		}
	}
	return
}
1213501
func (s *NodesInfoService) Metric(metric ...string) *NodesInfoService {
	s.metric = make([]string, 0)
	s.metric = append(s.metric, metric...)
	return s
}
404794
func WriteMetrics(r metrics.Registry, w io.Writer) {
	var namedMetrics namedMetricSlice
	r.Each(func(name string, i interface{}) {
		namedMetrics = append(namedMetrics, namedMetric{name, i})
	})

	sort.Sort(namedMetrics)
	for _, namedMetric := range namedMetrics {
		switch metric := namedMetric.m.(type) {
		case metrics.Counter:
			fmt.Fprintf(w, "counter %s\n", namedMetric.name)
			fmt.Fprintf(w, "  count: %9d\n", metric.Count())
		case metrics.Gauge:
			fmt.Fprintf(w, "gauge %s\n", namedMetric.name)
			fmt.Fprintf(w, "  value: %9d\n", metric.Value())
		case metrics.GaugeFloat64:
			fmt.Fprintf(w, "gauge %s\n", namedMetric.name)
			fmt.Fprintf(w, "  value: %f\n", metric.Value())
		case metrics.Healthcheck:
			metric.Check()
			fmt.Fprintf(w, "healthcheck %s\n", namedMetric.name)
			fmt.Fprintf(w, "  error: %v\n", metric.Error())
		case metrics.Histogram:
			h := metric.Snapshot()
			ps := h.Percentiles([]float64{0.5, 0.75, 0.95, 0.99, 0.999})
			fmt.Fprintf(w, "histogram %s\n", namedMetric.name)
			fmt.Fprintf(w, "  count=%d, mean=%.2f, stddef=%.2f\n", h.Count(), h.Mean(), h.StdDev())
			fmt.Fprintf(w, "  min=%.2fms median=%.2fms max=%.2fms\n",
				float64(h.Min())/float64(time.Millisecond),
				ps[0]/float64(time.Millisecond),
				float64(h.Max())/float64(time.Millisecond))
			fmt.Fprintf(w, "  %%iles (ms): 75=%.2f 95=%.2f 99=%.2f 99.9=%.2f\n",
				ps[1]/float64(time.Millisecond),
				ps[2]/float64(time.Millisecond),
				ps[3]/float64(time.Millisecond),
				ps[4]/float64(time.Millisecond))
		case metrics.Meter:
			m := metric.Snapshot()
			fmt.Fprintf(w, "meter %s\n", namedMetric.name)
			fmt.Fprintf(w, "  count: %d\n", m.Count())
			fmt.Fprintf(w, "  rates: 1m=%.2f 5m=%.2f 15m=%.2f mean=%.2f\n", m.Rate1(), m.Rate5(), m.Rate15(), m.RateMean())
		case metrics.Timer:
			t := metric.Snapshot()
			ps := t.Percentiles([]float64{0.5, 0.75, 0.95, 0.99, 0.999})
			fmt.Fprintf(w, "timer %s\n", namedMetric.name)
			fmt.Fprintf(w, "  count=%d, mean=%.2fms, stddev=%.2fms\n",
				t.Count(), t.Mean()/float64(time.Millisecond), t.StdDev()/float64(time.Millisecond))
			fmt.Fprintf(w, "  min=%.2fms median=%.2fms max=%.2fms\n",
				float64(t.Min())/float64(time.Millisecond),
				ps[0]/float64(time.Millisecond),
				float64(t.Max())/float64(time.Millisecond))
			fmt.Fprintf(w, "  %%iles (ms): 75=%.2f 95=%.2f 99=%.2f 99.9=%.2f\n",
				ps[1]/float64(time.Millisecond),
				ps[2]/float64(time.Millisecond),
				ps[3]/float64(time.Millisecond),
				ps[4]/float64(time.Millisecond))
			fmt.Fprintf(w, "  rates: 1m=%.2f 5m=%.2f 15m=%.2f mean=%.2f\n", t.Rate1(), t.Rate5(), t.Rate15(), t.RateMean())
		}
	}
}
1283755
func (p *promProducer) writeObjectToStore(d producers.Datapoint, m producers.MetricsMessage, prefix string) {
	newMessage := producers.MetricsMessage{
		Name:       m.Name,
		Datapoints: []producers.Datapoint{d},
		Dimensions: m.Dimensions,
		Timestamp:  m.Timestamp,
	}
	// e.g. dcos.metrics.app.[ContainerId].kafka.server.ReplicaFetcherManager.MaxLag
	qualifiedName := joinMetricName(prefix, d.Name)
	for _, pair := range prodHelpers.SortTags(d.Tags) {
		k, v := pair[0], pair[1]
		// e.g. dcos.metrics.node.[MesosId].network.out.errors.#interface:eth0
		serializedTag := fmt.Sprintf("#%s:%s", k, v)
		qualifiedName = joinMetricName(qualifiedName, serializedTag)
	}
	p.store.Set(qualifiedName, newMessage)
}
941116
func (w *influxDBWriter) Write(bp influxdb.BatchPoints) error {
	c, err := w.initWriteClient()
	if err != nil {
		return err
	}

	defer c.Close()

	if writeErr := c.Write(bp); writeErr != nil {
		ctx := log.With(context.Background(), log.Str(log.MetricsProviderName, "influxdb"))
		log.FromContext(ctx).Errorf("Error while writing to InfluxDB: %s", writeErr.Error())

		if handleErr := w.handleWriteError(ctx, c, writeErr); handleErr != nil {
			return handleErr
		}
		// Retry write after successful handling of writeErr
		return c.Write(bp)
	}
	return nil
}
854668
func (w *CountWriter) Write(b []byte) (n int, err error) {
	if n, err = w.W.Write(b); n > 0 {
		w.N += n
	}
	return
}
795796
func (d *compressor) write(b []byte) (n int, err error) {
	if d.err != nil {
		return 0, d.err
	}
	n = len(b)
	for len(b) > 0 {
		d.step(d)
		b = b[d.fill(d, b):]
		if d.err != nil {
			return 0, d.err
		}
	}
	return n, d.err
}
563030
func (s serverErrLogger) Write(b []byte) (int, error) {
	s.log.Debug(string(b))
	return 0, nil
}
814374
func (m *multiWriter) Write(p []byte) (n int, err error) {
	// lock and make a local copy of available writers:
	getWriters := func() (writers []writerWrapper) {
		m.RLock()
		defer m.RUnlock()
		writers = make([]writerWrapper, 0, len(m.writers))
		for _, w := range m.writers {
			writers = append(writers, w)
		}

		// add the recent write chunk to the "instant replay" buffer
		// of the session, to be replayed to newly joining parties:
		m.lockedAddRecentWrite(p)
		return writers
	}

	// unlock and multiplex the write to all writers:
	for _, w := range getWriters() {
		n, err = w.Write(p)
		if err != nil {
			if w.closeOnError {
				return
			}
			continue
		}
		if n != len(p) {
			err = io.ErrShortWrite
			return
		}
	}
	return len(p), nil
}
195061
func (et *ErrorTracker) Write(p []byte) (n int, err error) {
	if et.err != nil {
		return 0, et.err
	}
	n, err = et.Writer.Write(p)
	if err != nil {
		et.err = err
	}
	return n, err
}