mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-10-25 04:32:10 +08:00
fix: prometheus
This commit is contained in:
parent
36810b99a4
commit
95d383d656
@ -2,6 +2,7 @@ package api
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"errors"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
@ -38,10 +39,13 @@ func (p *PrometheusDiscoveryApi) Enable(c *gin.Context) {
|
|||||||
func (p *PrometheusDiscoveryApi) discovery(c *gin.Context, key string) {
|
func (p *PrometheusDiscoveryApi) discovery(c *gin.Context, key string) {
|
||||||
value, err := p.client.GetKeyWithPrefix(c, prommetrics.BuildDiscoveryKeyPrefix(key))
|
value, err := p.client.GetKeyWithPrefix(c, prommetrics.BuildDiscoveryKeyPrefix(key))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
if errors.Is(err, discovery.ErrNotSupported) {
|
||||||
|
c.JSON(http.StatusOK, []struct{}{})
|
||||||
|
return
|
||||||
|
}
|
||||||
apiresp.GinError(c, errs.WrapMsg(err, "get key value"))
|
apiresp.GinError(c, errs.WrapMsg(err, "get key value"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(value) == 0 {
|
if len(value) == 0 {
|
||||||
c.JSON(http.StatusOK, []*prommetrics.RespTarget{})
|
c.JSON(http.StatusOK, []*prommetrics.RespTarget{})
|
||||||
return
|
return
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user