nanorth commented on code in PR #2285:
URL:
https://github.com/apache/incubator-pegasus/pull/2285#discussion_r2297865730
##########
go-client/pegasus/client.go:
##########
@@ -59,17 +63,25 @@ func NewClient(cfg Config) Client {
return c
}
-func newClientWithError(cfg Config) (Client, error) {
+func newClientWithError(cfg config.Config) (Client, error) {
var err error
cfg.MetaServers, err = session.ResolveMetaAddr(cfg.MetaServers)
if err != nil {
return nil, err
}
+ if cfg.EnablePrometheus || cfg.EnableFalcon {
+ metrics.InitMetrics(prometheus.DefaultRegisterer, cfg)
+ if cfg.EnableFalcon {
+ go metrics.GetFalconReporter(cfg.FalconServer,
cfg.FalconInterval).Start()
+ }
+ }
Review Comment:
The Prometheus register will be initialized if either Prometheus or Falcon
is enabled. When `cfg.EnablePrometheus` is false and `cfg.EnableFalcon` is
true, the Prometheus register is still initialized so that the Falcon reporter
can collect metrics from it and report. `cfg.EnablePrometheus` only ensures
Prometheus to exposing its port.
```
func InitMetrics(registry prometheus.Registerer, cfg config.Config) {
initRegistry = registry
perfCounterMap = cfg.PerfCounterTags
if cfg.EnablePrometheus {
startServerOnce.Do(func() {
port := 9090
if cfg.PrometheusPort > 0 {
port = cfg.PrometheusPort
}
go func() {
http.Handle("/metrics", promhttp.Handler())
addr := fmt.Sprintf(":%d", port)
pegalog.GetLogger().Print("Starting Prometheus
metrics server on", addr)
if err := http.ListenAndServe(addr, nil); err
!= nil {
pegalog.GetLogger().Fatal("Failed to
start Prometheus metrics server:", err)
}
}()
})
}
}
```
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]