little-cui commented on code in PR #315:
URL: https://github.com/apache/servicecomb-kie/pull/315#discussion_r1464251236


##########
server/datasource/metric/prometheus.go:
##########
@@ -0,0 +1,57 @@
+package metric

Review Comment:
   应该是server/metrics包



##########
server/config/struct.go:
##########
@@ -22,12 +22,18 @@ type Config struct {
        DB   DB   `yaml:"db"`
        RBAC RBAC `yaml:"rbac"`
        Sync Sync `yaml:"sync"`
-       //config from cli
+       // config from cli
        ConfigFile     string
        NodeName       string
        ListenPeerAddr string
        PeerAddr       string
        AdvertiseAddr  string
+       MetricObject   MetricObject `yaml:"metricObject"`
+}
+
+type MetricObject struct {
+       Domain  string `yaml:"domain"`
+       Project string `yaml:"project"`

Review Comment:
   不需要配置,这些通过环境变量控制即可



##########
server/datasource/metric/prometheus.go:
##########
@@ -0,0 +1,57 @@
+package metric
+
+import (
+       "context"
+       "time"
+
+       "github.com/go-chassis/go-chassis/v2/pkg/metrics"
+       "github.com/go-chassis/openlog"
+
+       "github.com/apache/servicecomb-kie/server/config"
+       "github.com/apache/servicecomb-kie/server/datasource"
+)
+
+const ReportInterval = 15

Review Comment:
   这个需要可配置



##########
server/datasource/metric/prometheus.go:
##########
@@ -0,0 +1,57 @@
+package metric
+
+import (
+       "context"
+       "time"
+
+       "github.com/go-chassis/go-chassis/v2/pkg/metrics"
+       "github.com/go-chassis/openlog"
+
+       "github.com/apache/servicecomb-kie/server/config"
+       "github.com/apache/servicecomb-kie/server/datasource"
+)
+
+const ReportInterval = 15
+
+func InitMetric(m config.MetricObject) error {
+       err := metrics.CreateGauge(metrics.GaugeOpts{
+               Key:    "servicecomb_kie_config_count",
+               Help:   "use to show the number of config under a specifical 
domain and project pair",
+               Labels: []string{"domain", "project"},
+       })
+       if err != nil {
+               openlog.Error("init servicecomb_kie_config_count Gauge fail:" + 
err.Error())
+               return err
+       }
+       if m.Domain == "" {
+               m.Domain = "default"
+       }
+       if m.Project == "" {
+               m.Project = "default"
+       }
+       ReportTicker := time.NewTicker(ReportInterval * time.Second)

Review Comment:
   局部变量命名大写开头不规范



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to