agent/tcs/client/client.go
func (cs *clientServer) publishMetrics() {
	if cs.publishTicker == nil {
		seelog.Debug("Skipping publishing metrics. Publish ticker is uninitialized")
		return
	}

	// Publish metrics immediately after we connect and wait for ticks. This makes
	// sure that there is no data loss when a scheduled metrics publishing fails
	// due to a connection reset.
	err := cs.publishMetricsOnce()
	if err != nil && err != stats.EmptyMetricsError {
		seelog.Warnf("Error publishing metrics: %v", err)
	}
	// don't simply range over the ticker since its channel doesn't ever get closed
	for {
		select {
		case <-cs.publishTicker.C:
			err := cs.publishMetricsOnce()
			if err != nil {
				seelog.Warnf("Error publishing metrics: %v", err)
			}
		case <-cs.ctx.Done():
			return
		}
	}
}
func (cs *clientServer) publishMetrics() {
	if cs.publishTicker == nil {
		seelog.Debug("Skipping publishing metrics. Publish ticker is uninitialized")
		return
	}

	// Publish metrics immediately after we connect and wait for ticks. This makes
	// sure that there is no data loss when a scheduled metrics publishing fails
	// due to a connection reset.
	err := cs.publishMetricsOnce()
	if err != nil && err != stats.EmptyMetricsError {
		seelog.Warnf("Error publishing metrics: %v", err)
	}
	// don't simply range over the ticker since its channel doesn't ever get closed
	for {
		select {
		case <-cs.publishTicker.C:
			err := cs.publishMetricsOnce()
			if err != nil {
				seelog.Warnf("Error publishing metrics: %v", err)
			}
		case <-cs.ctx.Done():
			return
		}
	}
}
// publishMetrics invokes the PublishMetricsRequest on the clientserver object.