diff options
| author | Konstantin Lebedev <9497591+kmlebedev@users.noreply.github.com> | 2022-08-01 21:16:57 +0500 |
|---|---|---|
| committer | Konstantin Lebedev <9497591+kmlebedev@users.noreply.github.com> | 2022-08-01 21:16:57 +0500 |
| commit | ab50f21ad92c994ebe514017493e70c051ef175a (patch) | |
| tree | 8051dde2c49bc7ef869df97feebbb286a3fa14e2 | |
| parent | f0e0073b84a58cc83895b4cb919d424a7833e7ec (diff) | |
| download | seaweedfs-ab50f21ad92c994ebe514017493e70c051ef175a.tar.xz seaweedfs-ab50f21ad92c994ebe514017493e70c051ef175a.zip | |
Detailed metrics VolumeServerRequestHistogram for writing to disk and replication
| -rw-r--r-- | weed/topology/store_replicate.go | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/weed/topology/store_replicate.go b/weed/topology/store_replicate.go index e426e15de..578cf758d 100644 --- a/weed/topology/store_replicate.go +++ b/weed/topology/store_replicate.go @@ -9,6 +9,7 @@ import ( "net/url" "strconv" "strings" + "time" "github.com/seaweedfs/seaweedfs/weed/glog" "github.com/seaweedfs/seaweedfs/weed/operation" @@ -43,7 +44,9 @@ func ReplicatedWrite(masterFn operation.GetMasterFn, grpcDialOption grpc.DialOpt } if s.GetVolume(volumeId) != nil { + start := time.Now() isUnchanged, err = s.WriteVolumeNeedle(volumeId, n, true, fsync) + stats.VolumeServerRequestHistogram.WithLabelValues("write").Observe(time.Since(start).Seconds()) if err != nil { stats.VolumeServerRequestCounter.WithLabelValues(stats.ErrorWriteToLocalDisk).Inc() err = fmt.Errorf("failed to write to local disk: %v", err) @@ -53,7 +56,8 @@ func ReplicatedWrite(masterFn operation.GetMasterFn, grpcDialOption grpc.DialOpt } if len(remoteLocations) > 0 { //send to other replica locations - if err = DistributedOperation(remoteLocations, func(location operation.Location) error { + start := time.Now() + err = DistributedOperation(remoteLocations, func(location operation.Location) error { u := url.URL{ Scheme: "http", Host: location.Url, @@ -97,7 +101,9 @@ func ReplicatedWrite(masterFn operation.GetMasterFn, grpcDialOption grpc.DialOpt } _, err := operation.UploadData(n.Data, uploadOption) return err - }); err != nil { + }) + stats.VolumeServerRequestHistogram.WithLabelValues("replicate").Observe(time.Since(start).Seconds()) + if err != nil { stats.VolumeServerRequestCounter.WithLabelValues(stats.ErrorWriteToReplicas).Inc() err = fmt.Errorf("failed to write to replicas for volume %d: %v", volumeId, err) glog.V(0).Infoln(err) |
