You've already forked focalboard
							
							
				mirror of
				https://github.com/mattermost/focalboard.git
				synced 2025-10-31 00:17:42 +02:00 
			
		
		
		
	As an SRE team we would like to expose standard metrics and grouped by version of the application. Right now will expose only metrics related to Go but instrumentor should be used in other parts of the codebase so we can track other metrics, eg. number of tasks, boards, users etc. Similar as we do in MM. It will run in port `localhost:9092` and it is a new config `prometheus_address`. Also in the commit we introduced, `group.Add` which helps us to handle gracefully errors for goroutines. It's a good practice and there are couple of articles by Golang for this.
		
			
				
	
	
		
			34 lines
		
	
	
		
			694 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			34 lines
		
	
	
		
			694 B
		
	
	
	
		
			Go
		
	
	
	
	
	
| package prometheus
 | |
| 
 | |
| import (
 | |
| 	"net/http"
 | |
| 
 | |
| 	"github.com/pkg/errors"
 | |
| 	"github.com/prometheus/client_golang/prometheus/promhttp"
 | |
| )
 | |
| 
 | |
| // Service prometheus to run the server
 | |
| type Service struct {
 | |
| 	*http.Server
 | |
| }
 | |
| 
 | |
| // New Factory method to create a new prometheus server
 | |
| func New(address string) *Service {
 | |
| 	return &Service{
 | |
| 		&http.Server{
 | |
| 			Addr:    address,
 | |
| 			Handler: promhttp.Handler(),
 | |
| 		},
 | |
| 	}
 | |
| }
 | |
| 
 | |
| // Run will start the prometheus server
 | |
| func (h *Service) Run() error {
 | |
| 	return errors.Wrap(h.Server.ListenAndServe(), "prometheus ListenAndServe")
 | |
| }
 | |
| 
 | |
| // Shutdown will shutdown the prometheus server
 | |
| func (h *Service) Shutdown() error {
 | |
| 	return errors.Wrap(h.Server.Close(), "prometheus Close")
 | |
| }
 |