forked from TrueCloudLab/frostfs-node
[#426] service/object: Fix put duration
At object.Put operation node does not transfer any data. It is done in the stream inside, so we should register duration from `object.Put` invocation until `CloseAndRecv` on the stream. Signed-off-by: Alex Vanin <alexey@nspcc.ru>
This commit is contained in:
parent
b8e10571c6
commit
892b4f4f12
1 changed files with 6 additions and 1 deletions
|
@ -23,6 +23,7 @@ type (
|
|||
putStreamMetric struct {
|
||||
stream object.PutObjectStreamer
|
||||
metrics MetricRegister
|
||||
start time.Time
|
||||
}
|
||||
|
||||
MetricRegister interface {
|
||||
|
@ -72,7 +73,6 @@ func (m MetricCollector) Put(ctx context.Context) (object.PutObjectStreamer, err
|
|||
t := time.Now()
|
||||
defer func() {
|
||||
m.metrics.IncPutReqCounter()
|
||||
m.metrics.AddPutReqDuration(time.Since(t))
|
||||
}()
|
||||
|
||||
stream, err := m.next.Put(ctx)
|
||||
|
@ -83,6 +83,7 @@ func (m MetricCollector) Put(ctx context.Context) (object.PutObjectStreamer, err
|
|||
return &putStreamMetric{
|
||||
stream: stream,
|
||||
metrics: m.metrics,
|
||||
start: t,
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
@ -155,5 +156,9 @@ func (s putStreamMetric) Send(req *object.PutRequest) error {
|
|||
}
|
||||
|
||||
func (s putStreamMetric) CloseAndRecv() (*object.PutResponse, error) {
|
||||
defer func() {
|
||||
s.metrics.AddPutReqDuration(time.Since(s.start))
|
||||
}()
|
||||
|
||||
return s.stream.CloseAndRecv()
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue