code: func (s *Server) monitorRuntime() {
  	// Disable metrics when poll interval is zero.
  	if s.metricInterval <= 0 {
  		return
  	}
  
  	var m runtime.MemStats
  	ticker := time.NewTicker(s.metricInterval)
  	defer ticker.Stop()
  
  	defer s.gcNotifier.Close()
  
  	s.logger.Printf("runtime stats initializing (%s interval)", s.metricInterval)
  
  	for {
  		// Wait for tick or a close.
  		select {
  		case <-s.closing:
  			return
  		case <-s.gcNotifier.AfterGC():
  			// GC just ran.
  			s.holder.Stats.Count("garbage_collection", 1, 1.0)
  		case <-ticker.C:
  		}
  
  		// Record the number of go routines.
  		s.holder.Stats.Gauge("goroutines", float64(runtime.NumGoroutine()), 1.0)
  
  		openFiles, err := countOpenFiles()
  		// Open File handles.
  		if err == nil {
  			s.holder.Stats.Gauge("OpenFiles", float64(openFiles), 1.0)
  		}
  
  		// Runtime memory metrics.
  		runtime.ReadMemStats(&m)
  		s.holder.Stats.Gauge("HeapAlloc", float64(m.HeapAlloc), 1.0)
  		s.holder.Stats.Gauge("HeapInuse", float64(m.HeapInuse), 1.0)
  		s.holder.Stats.Gauge("StackInuse", float64(m.StackInuse), 1.0)
  		s.holder.Stats.Gauge("Mallocs", float64(m.Mallocs), 1.0)
  		s.holder.Stats.Gauge("Frees", float64(m.Frees), 1.0)
  	}
  }
docs: // monitorRuntime periodically polls the Go runtime metrics.