mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2025-08-24 06:31:59 +08:00
refactoring
This commit is contained in:
parent
8b43679ae3
commit
ff6a6dd11e
@ -1,7 +1,6 @@
|
|||||||
package weed_server
|
package weed_server
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
@ -88,15 +87,7 @@ func NewFilerServer(defaultMux, readonlyMux *http.ServeMux, option *FilerOption)
|
|||||||
readonlyMux.HandleFunc("/", fs.readonlyFilerHandler)
|
readonlyMux.HandleFunc("/", fs.readonlyFilerHandler)
|
||||||
}
|
}
|
||||||
|
|
||||||
stats.StartPushingMetric("filer", sourceName(option.Port), stats.FilerGather, option.MetricsAddress, option.MetricsIntervalSec)
|
stats.StartPushingMetric("filer", stats.SourceName(option.Port), stats.FilerGather, option.MetricsAddress, option.MetricsIntervalSec)
|
||||||
|
|
||||||
return fs, nil
|
return fs, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func sourceName(port int) string {
|
|
||||||
hostname, err := os.Hostname()
|
|
||||||
if err != nil {
|
|
||||||
return "unknown"
|
|
||||||
}
|
|
||||||
return fmt.Sprintf("%s_%d", hostname, port)
|
|
||||||
}
|
|
||||||
|
@ -19,7 +19,9 @@ func (vs *VolumeServer) PostHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
|
|
||||||
stats.VolumeServerRequestCounter.WithLabelValues("post").Inc()
|
stats.VolumeServerRequestCounter.WithLabelValues("post").Inc()
|
||||||
start := time.Now()
|
start := time.Now()
|
||||||
defer func() { stats.VolumeServerRequestHistogram.WithLabelValues("post").Observe(time.Since(start).Seconds()) }()
|
defer func() {
|
||||||
|
stats.VolumeServerRequestHistogram.WithLabelValues("post").Observe(time.Since(start).Seconds())
|
||||||
|
}()
|
||||||
|
|
||||||
if e := r.ParseForm(); e != nil {
|
if e := r.ParseForm(); e != nil {
|
||||||
glog.V(0).Infoln("form parse error:", e)
|
glog.V(0).Infoln("form parse error:", e)
|
||||||
@ -69,7 +71,9 @@ func (vs *VolumeServer) DeleteHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
|
|
||||||
stats.VolumeServerRequestCounter.WithLabelValues("delete").Inc()
|
stats.VolumeServerRequestCounter.WithLabelValues("delete").Inc()
|
||||||
start := time.Now()
|
start := time.Now()
|
||||||
defer func() { stats.VolumeServerRequestHistogram.WithLabelValues("delete").Observe(time.Since(start).Seconds()) }()
|
defer func() {
|
||||||
|
stats.VolumeServerRequestHistogram.WithLabelValues("delete").Observe(time.Since(start).Seconds())
|
||||||
|
}()
|
||||||
|
|
||||||
n := new(needle.Needle)
|
n := new(needle.Needle)
|
||||||
vid, fid, _, _, _ := parseURLPath(r.URL.Path)
|
vid, fid, _, _, _ := parseURLPath(r.URL.Path)
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
package stats
|
package stats
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/chrislusf/seaweedfs/weed/glog"
|
"github.com/chrislusf/seaweedfs/weed/glog"
|
||||||
@ -87,3 +89,11 @@ func loopPushMetrics(name, instance string, gatherer *prometheus.Registry, addr
|
|||||||
time.Sleep(time.Duration(intervalSeconds) * time.Second)
|
time.Sleep(time.Duration(intervalSeconds) * time.Second)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func SourceName(port int) string {
|
||||||
|
hostname, err := os.Hostname()
|
||||||
|
if err != nil {
|
||||||
|
return "unknown"
|
||||||
|
}
|
||||||
|
return fmt.Sprintf("%s_%d", hostname, port)
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user