Skip to content

Commit

Permalink
[feat]:精简日志
Browse files Browse the repository at this point in the history
  • Loading branch information
zianazhao committed Apr 24, 2023
1 parent 461f035 commit 6a1a417
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
3 changes: 0 additions & 3 deletions pkg/collector/handler_qaap.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,6 @@ func (h *QaapHandler) getQaapListenerRsSeries(m *metric.TcmMetric, ins instance.
// if err != nil {
// return nil, err
// }
// fmt.Println(ins.GetMonitorQueryKey(), "getTcpSeries耗时", time.Since(start).Milliseconds(), "series", len(series))
// for _, tcpListenersInfo := range tcpListenersInfos.Response.ListenerSet {
// for _, realServerSet := range tcpListenersInfo.RealServerSet {
// ql := map[string]string{
Expand All @@ -224,12 +223,10 @@ func (h *QaapHandler) getQaapListenerRsSeries(m *metric.TcmMetric, ins instance.
// series = append(series, s)
// }
// }
// start1 := time.Now()
// udpListenersInfos, err := h.qaapInstanceInfoRepo.GetUDPListenersInfo(ins.GetInstanceId())
// if err != nil {
// return nil, err
// }
// fmt.Println(ins.GetMonitorQueryKey(), "getUdpSeries耗时", time.Since(start1).Milliseconds(), "series", len(series))
// for _, udpListenersInfo := range udpListenersInfos.Response.ListenerSet {
// for _, realServerSet := range udpListenersInfo.RealServerSet {
// ql := map[string]string{
Expand Down
7 changes: 1 addition & 6 deletions pkg/collector/product.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,21 +102,18 @@ func (c *TcProductCollector) LoadMetricsByProductConf() error {
series, err := c.handler.GetSeries(nm)
if err != nil {
level.Error(c.logger).Log("msg", "create metric series err", "err", err, "Namespace", c.Namespace, "name", mname)
// continue
}
level.Info(c.logger).Log("msg", "found instances", "count", len(series), "Namespace", c.Namespace, "name", mname, "cost", time.Since(start).Milliseconds())
err = nm.LoadSeries(series)
if err != nil {
level.Error(c.logger).Log("msg", "load metric series err", "err", err, "Namespace", c.Namespace, "name", mname)
// continue
}
group.Done()
}(mname, wg)
}
wg.Wait()
} else {
for _, mname := range metricNames {
start := time.Now()
nm, err := c.createMetricWithProductConf(mname, pconf)
if err != nil {
level.Warn(c.logger).Log("msg", "Create metric fail", "err", err, "Namespace", c.Namespace, "name", mname)
Expand All @@ -134,7 +131,7 @@ func (c *TcProductCollector) LoadMetricsByProductConf() error {
level.Error(c.logger).Log("msg", "create metric series err", "err", err, "Namespace", c.Namespace, "name", mname)
continue
}
level.Info(c.logger).Log("msg", "found instances", "count", len(series), "Namespace", c.Namespace, "name", mname, "cost", time.Since(start).Milliseconds())
level.Info(c.logger).Log("msg", "found instances", "count", len(series), "Namespace", c.Namespace, "name", mname, "cost")
err = nm.LoadSeries(series)
if err != nil {
level.Error(c.logger).Log("msg", "load metric series err", "err", err, "Namespace", c.Namespace, "name", mname)
Expand Down Expand Up @@ -380,12 +377,10 @@ func NewTcProductCollector(namespace string, metricRepo metric.TcmMetricReposito
if err != nil {
return nil, err
}
start := time.Now()
err = c.LoadMetricsByProductConf()
if err != nil {
return nil, err
}
fmt.Println("耗时", time.Since(start).Milliseconds())
err = c.initQuerys()
if err != nil {
return nil, err
Expand Down
10 changes: 10 additions & 0 deletions pkg/instance/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -554,8 +554,10 @@ func (c *TcGaapInstanceInfosCache) GetTCPListenersInfo(instanceId string) (*gaap
if err != nil {
return nil, err
}
c.mu.Lock()
c.tcpCache[instanceId] = tcpListeners
c.lastReloadTime[instanceId] = time.Now()
c.mu.Unlock()
level.Debug(c.logger).Log("msg", "Get gaap Namespaces info from api", "instanceId", instanceId)
return tcpListeners, nil
}
Expand All @@ -572,8 +574,10 @@ func (c *TcGaapInstanceInfosCache) GetUDPListenersInfo(instanceId string) (*gaap
if err != nil {
return nil, err
}
c.mu.Lock()
c.udpCache[instanceId] = udpListeners
c.lastReloadTime[instanceId] = time.Now()
c.mu.Unlock()
level.Debug(c.logger).Log("msg", "Get gaap Namespaces info from api", "instanceId", instanceId)
return udpListeners, nil
}
Expand All @@ -590,8 +594,10 @@ func (c *TcGaapInstanceInfosCache) GetProxyGroupList(instanceId string) (*gaap.D
if err != nil {
return nil, err
}
c.mu.Lock()
c.groupCache[instanceId] = proxyGroupList
c.lastReloadTime[instanceId] = time.Now()
c.mu.Unlock()
level.Debug(c.logger).Log("msg", "Get gaap Namespaces info from api", "instanceId", instanceId)
return proxyGroupList, nil
}
Expand Down Expand Up @@ -633,8 +639,10 @@ func (c *TcCommonGaapInstanceInfosCache) GetCommonQaapProxyInstances(instanceId
if err != nil {
return ProxyInstancesRsp{}, err
}
c.mu.Lock()
c.proxyInstancesCache[instanceId] = proxyGroupList
c.lastReloadTime[instanceId] = time.Now()
c.mu.Unlock()
level.Debug(c.logger).Log("msg", "Get gaap Namespaces info from api", "instanceId", instanceId)
return proxyGroupList, nil
}
Expand All @@ -651,8 +659,10 @@ func (c *TcCommonGaapInstanceInfosCache) GetCommonQaapNoneBgpIpList(instanceId s
if err != nil {
return NoneBgpIpListRsp{}, err
}
c.mu.Lock()
c.noneBgpIpListCache[instanceId] = proxyGroupList
c.lastReloadTime[instanceId] = time.Now()
c.mu.Unlock()
level.Debug(c.logger).Log("msg", "Get gaap Namespaces info from api", "instanceId", instanceId)
return proxyGroupList, nil
}
Expand Down

0 comments on commit 6a1a417

Please sign in to comment.