// Timing tracks timing information for a metric.
540594
func (c *expvarStatsClient) Timing(name string, value time.Duration, rate float64) {
	c.mu.Lock()
	d, _ := c.m.Get(name).(time.Duration)
	c.m.Set(name, d+value)
	c.mu.Unlock()
}
173285
func (e *Event) Time(key string, t time.Time) *Event {
	if e == nil {
		return e
	}
	e.buf = enc.AppendTime(enc.AppendKey(e.buf, key), t, TimeFieldFormat)
	return e
}
112622
func (logger *Logger) time(r *record) interface{} {
	return r.time.Format(logger.timeFormat)
}
94953
func (h *Histo) Metric() (*metricpb.Metric, error) {
	return &metricpb.Metric{
		Name: h.Name,
		Tags: h.Tags,
		Type: metricpb.Type_Histogram,
		Value: &metricpb.Metric_Histogram{&metricpb.HistogramValue{
			TDigest: h.Value.Data(),
		}},
	}, nil
}
739078
func (samplerOptions) Metrics(m *Metrics) SamplerOption {
	return func(o *samplerOptions) {
		o.metrics = m
	}
}
1148279
func Metrics(harness metrics.Harness, labeler Labeler) Rule {
	if harness == nil {
		panic("harness is a required parameter")
	}
	if labeler == nil {
		labeler = defaultLabeler
	}
	return func(ctx context.Context, e *scheduler.Event, err error, ch Chain) (context.Context, *scheduler.Event, error) {
		labels := labeler(ctx, e)
		harness(func() error {
			ctx, e, err = ch(ctx, e, err)
			return err
		}, labels...)
		return ctx, e, err
	}
}
616128
func (t ntpTime) Duration() time.Duration {
	sec := (t >> 32) * nanoPerSec
	frac := (t & 0xffffffff) * nanoPerSec >> 32
	return time.Duration(sec + frac)
}
667985
func (w *Worker) ProcessMetric(m *samplers.UDPMetric) {
	w.mutex.Lock()
	defer w.mutex.Unlock()
	w.processed++
	w.wm.Upsert(m.MetricKey, m.Scope, m.Tags)

	switch m.Type {
	case counterTypeName:
		if m.Scope == samplers.GlobalOnly {
			w.wm.globalCounters[m.MetricKey].Sample(m.Value.(float64), m.SampleRate)
		} else {
			w.wm.counters[m.MetricKey].Sample(m.Value.(float64), m.SampleRate)
		}
	case gaugeTypeName:
		if m.Scope == samplers.GlobalOnly {
			w.wm.globalGauges[m.MetricKey].Sample(m.Value.(float64), m.SampleRate)
		} else {
			w.wm.gauges[m.MetricKey].Sample(m.Value.(float64), m.SampleRate)
		}
	case histogramTypeName:
		if m.Scope == samplers.LocalOnly {
			w.wm.localHistograms[m.MetricKey].Sample(m.Value.(float64), m.SampleRate)
		} else if m.Scope == samplers.GlobalOnly {
			w.wm.globalHistograms[m.MetricKey].Sample(m.Value.(float64), m.SampleRate)
		} else {
			w.wm.histograms[m.MetricKey].Sample(m.Value.(float64), m.SampleRate)
		}
	case setTypeName:
		if m.Scope == samplers.LocalOnly {
			w.wm.localSets[m.MetricKey].Sample(m.Value.(string), m.SampleRate)
		} else {
			w.wm.sets[m.MetricKey].Sample(m.Value.(string), m.SampleRate)
		}
	case timerTypeName:
		if m.Scope == samplers.LocalOnly {
			w.wm.localTimers[m.MetricKey].Sample(m.Value.(float64), m.SampleRate)
		} else if m.Scope == samplers.GlobalOnly {
			w.wm.globalTimers[m.MetricKey].Sample(m.Value.(float64), m.SampleRate)
		} else {
			w.wm.timers[m.MetricKey].Sample(m.Value.(float64), m.SampleRate)
		}
	case statusTypeName:
		v := float64(m.Value.(ssf.SSFSample_Status))
		w.wm.localStatusChecks[m.MetricKey].Sample(v, m.SampleRate, m.Message, m.HostName)
	default:
		log.WithField("type", m.Type).Error("Unknown metric type for processing")
	}
}
75150
func Time(timeFormat string) Formatter {
	return func(buffer Buffer, event *cue.Event) {
		buffer.AppendString(event.Time.Format(timeFormat))
	}
}
909335
func (c *MetricsCollector) Metrics() *InvocationMetrics {
	c.Lock()
	defer c.Unlock()
	return c.metrics
}
352230
func (c *Clock) Time() float32 {
	currStamp := theTimer.Now()
	return float32(float64(currStamp-c.startStamp) / float64(secondsInNano))
}
32004
func (s *Statsd) Timing(sampleRate float32, bucket string, d ...time.Duration) {
	samp, ok := maybeSample(sampleRate)
	if !ok {
		return
	}

	msgs := make([]sendable, len(d))
	for i, di := range d {
		msgs[i] = &timingUpdate{
			prefix:   s.prefix,
			bucket:   bucket,
			ms:       int(di.Nanoseconds() / 1e6),
			sampling: samp,
		}
	}

	s.publish(msgs)
}
181555
func (e *eventTimestamper) Time() time.Time {
	e.lock.RLock()
	t := e.timestamp
	e.lock.RUnlock()
	return t
}
977341
func (tt Timetag) Time() time.Time {
	secs := (uint64(tt) >> 32) - SecondsFrom1900To1970
	return time.Unix(int64(secs), int64(tt)&0xFFFFFFFF).UTC()
}
282661
func NopMetrics() *Metrics {
	return &Metrics{
		Size:         discard.NewGauge(),
		TxSizeBytes:  discard.NewHistogram(),
		FailedTxs:    discard.NewCounter(),
		RecheckTimes: discard.NewCounter(),
	}
}
776137
func (s *NoopClient) Timing(stat string, delta int64, rate float32) error {
	return nil
}
1059172
func (c *Counter) Metric() (*metricpb.Metric, error) {
	return &metricpb.Metric{
		Name:  c.Name,
		Tags:  c.Tags,
		Type:  metricpb.Type_Counter,
		Value: &metricpb.Metric_Counter{&metricpb.CounterValue{Value: c.value}},
	}, nil
}