mirror of
				https://github.com/openimsdk/open-im-server.git
				synced 2025-10-26 05:02:11 +08:00 
			
		
		
		
	* pb * fix: Modifying other fields while setting IsPrivateChat does not take effect * fix: quote message error revoke * refactoring scheduled tasks * refactoring scheduled tasks * refactoring scheduled tasks * refactoring scheduled tasks * refactoring scheduled tasks * refactoring scheduled tasks * upgrading pkg tools * fix * fix * optimize log output * feat: support GetLastMessage * feat: support GetLastMessage * feat: s3 switch * feat: s3 switch * fix: GetUsersOnline * feat: SendBusinessNotification supported configuration parameters * feat: SendBusinessNotification supported configuration parameters * feat: SendBusinessNotification supported configuration parameters * feat: seq conversion failed without exiting * monolithic * fix: DeleteDoc crash * fix: DeleteDoc crash * fix: monolithic * fix: monolithic * fix: fill send time * fix: fill send time * fix: crash caused by withdrawing messages from users who have left the group * fix: mq * fix: mq * fix: user msg timestamp * fix: mq * 1 * 1 * 1 * 1 * 1 * 1 * 1 * seq read config * seq read config * 1 * 1 * fix: the source message of the reference is withdrawn, and the referenced message is deleted * 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1
		
			
				
	
	
		
			49 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			49 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
| package prommetrics
 | |
| 
 | |
| import (
 | |
| 	"net"
 | |
| 	"strconv"
 | |
| 
 | |
| 	"github.com/prometheus/client_golang/prometheus"
 | |
| 	"github.com/prometheus/client_golang/prometheus/promhttp"
 | |
| )
 | |
| 
 | |
| var (
 | |
| 	apiCounter = prometheus.NewCounterVec(
 | |
| 		prometheus.CounterOpts{
 | |
| 			Name: "api_count",
 | |
| 			Help: "Total number of API calls",
 | |
| 		},
 | |
| 		[]string{"path", "method", "code"},
 | |
| 	)
 | |
| 	httpCounter = prometheus.NewCounterVec(
 | |
| 		prometheus.CounterOpts{
 | |
| 			Name: "http_count",
 | |
| 			Help: "Total number of HTTP calls",
 | |
| 		},
 | |
| 		[]string{"path", "method", "status"},
 | |
| 	)
 | |
| )
 | |
| 
 | |
| func RegistryApi() {
 | |
| 	registry.MustRegister(apiCounter, httpCounter)
 | |
| }
 | |
| 
 | |
| func ApiInit(listener net.Listener) error {
 | |
| 	apiRegistry := prometheus.NewRegistry()
 | |
| 	cs := append(
 | |
| 		baseCollector,
 | |
| 		apiCounter,
 | |
| 		httpCounter,
 | |
| 	)
 | |
| 	return Init(apiRegistry, listener, commonPath, promhttp.HandlerFor(apiRegistry, promhttp.HandlerOpts{}), cs...)
 | |
| }
 | |
| 
 | |
| func APICall(path string, method string, apiCode int) {
 | |
| 	apiCounter.With(prometheus.Labels{"path": path, "method": method, "code": strconv.Itoa(apiCode)}).Inc()
 | |
| }
 | |
| 
 | |
| func HttpCall(path string, method string, status int) {
 | |
| 	httpCounter.With(prometheus.Labels{"path": path, "method": method, "status": strconv.Itoa(status)}).Inc()
 | |
| }
 |