@@ -131,18 +131,6 @@ func (g *DiscoverServer) Discover(server apiservice.PolarisGRPC_DiscoverServer)
131131 var out * apiservice.DiscoverResponse
132132 var action string
133133 startTime := commontime .CurrentMillisecond ()
134- defer func () {
135- plugin .GetStatis ().ReportDiscoverCall (metrics.ClientDiscoverMetric {
136- Action : action ,
137- ClientIP : utils .ParseClientAddress (ctx ),
138- Namespace : in .GetService ().GetNamespace ().GetValue (),
139- Resource : in .GetType ().String () + ":" + in .GetService ().GetName ().GetValue (),
140- Timestamp : startTime ,
141- CostTime : commontime .CurrentMillisecond () - startTime ,
142- Revision : out .GetService ().GetRevision ().GetValue (),
143- Success : out .GetCode ().GetValue () > uint32 (apimodel .Code_DataNoChange ),
144- })
145- }()
146134
147135 // 兼容。如果请求中带了token,优先使用该token
148136 if in .GetService ().GetToken ().GetValue () != "" {
@@ -176,6 +164,17 @@ func (g *DiscoverServer) Discover(server apiservice.PolarisGRPC_DiscoverServer)
176164 if err != nil {
177165 return err
178166 }
167+
168+ plugin .GetStatis ().ReportDiscoverCall (metrics.ClientDiscoverMetric {
169+ Action : action ,
170+ ClientIP : utils .ParseClientAddress (ctx ),
171+ Namespace : in .GetService ().GetNamespace ().GetValue (),
172+ Resource : in .GetType ().String () + ":" + in .GetService ().GetName ().GetValue (),
173+ Timestamp : startTime ,
174+ CostTime : commontime .CurrentMillisecond () - startTime ,
175+ Revision : out .GetService ().GetRevision ().GetValue (),
176+ Success : out .GetCode ().GetValue () > uint32 (apimodel .Code_DataNoChange ),
177+ })
179178 }
180179}
181180
0 commit comments