18
18
package config
19
19
20
20
import (
21
+ "fmt"
21
22
"strconv"
22
23
23
24
"github.com/emicklei/go-restful/v3"
@@ -27,6 +28,10 @@ import (
27
28
28
29
httpcommon "github.com/polarismesh/polaris/apiserver/httpserver/utils"
29
30
api "github.com/polarismesh/polaris/common/api/v1"
31
+ "github.com/polarismesh/polaris/common/metrics"
32
+ commontime "github.com/polarismesh/polaris/common/time"
33
+ "github.com/polarismesh/polaris/common/utils"
34
+ "github.com/polarismesh/polaris/plugin"
30
35
)
31
36
32
37
func (h * HTTPServer ) ClientGetConfigFile (req * restful.Request , rsp * restful.Response ) {
@@ -43,7 +48,20 @@ func (h *HTTPServer) ClientGetConfigFile(req *restful.Request, rsp *restful.Resp
43
48
Version : & wrapperspb.UInt64Value {Value : version },
44
49
}
45
50
46
- response := h .configServer .GetConfigFileForClient (handler .ParseHeaderContext (), configFile )
51
+ ctx := handler .ParseHeaderContext ()
52
+ startTime := commontime .CurrentMillisecond ()
53
+ defer func () {
54
+ plugin .GetStatis ().ReportDiscoverCall (metrics.ClientDiscoverMetric {
55
+ ClientIP : utils .ParseClientAddress (ctx ),
56
+ Namespace : configFile .GetNamespace ().GetValue (),
57
+ Resource : fmt .Sprintf ("CONFIG_FILE:%s|%s|%d" , configFile .GetGroup ().GetValue (),
58
+ configFile .GetFileName ().GetValue (), version ),
59
+ Timestamp : startTime ,
60
+ CostTime : commontime .CurrentMillisecond () - startTime ,
61
+ })
62
+ }()
63
+
64
+ response := h .configServer .GetConfigFileForClient (ctx , configFile )
47
65
handler .WriteHeaderAndProto (response )
48
66
}
49
67
@@ -82,6 +100,19 @@ func (h *HTTPServer) GetConfigFileMetadataList(req *restful.Request, rsp *restfu
82
100
handler .WriteHeaderAndProto (api .NewResponseWithMsg (apimodel .Code_ParseException , err .Error ()))
83
101
return
84
102
}
103
+
104
+ startTime := commontime .CurrentMillisecond ()
105
+ defer func () {
106
+ plugin .GetStatis ().ReportDiscoverCall (metrics.ClientDiscoverMetric {
107
+ ClientIP : utils .ParseClientAddress (ctx ),
108
+ Namespace : in .GetConfigFileGroup ().GetNamespace ().GetValue (),
109
+ Resource : fmt .Sprintf ("CONFIG_FILE_LIST:%s|%s" , in .GetConfigFileGroup ().GetName ().GetValue (),
110
+ in .GetRevision ().GetValue ()),
111
+ Timestamp : startTime ,
112
+ CostTime : commontime .CurrentMillisecond () - startTime ,
113
+ })
114
+ }()
115
+
85
116
out := h .configServer .GetConfigFileNamesWithCache (ctx , in )
86
117
handler .WriteHeaderAndProto (out )
87
118
}
0 commit comments