Support average request time for ListContainerStream #338

Closed
opened 2025-03-03 09:47:30 +00:00 by dkirillov · 0 comments
Member

After #291 the ListContainerStream operation was added to the pool. But statistics for average request time for this method isn't updated

Expected Behavior

All pool methods counts average time.

Current Behavior

ListContainerStream

methodContainerListStream

doesn't calculate time

Possible Solution

Since this operations is streaming one we can use the same approach as in GetObject

Lines 1051 to 1069 in 2b8329e
start := time.Now()
successReadHeader := rObj.ReadHeader(&res.Header)
c.incRequests(time.Since(start), methodObjectGet)
if !successReadHeader {
rObjRes, err := rObj.Close()
var st apistatus.Status
if rObjRes != nil {
st = rObjRes.Status()
}
err = c.handleError(ctx, st, err)
return res, fmt.Errorf("read header: %w", err)
}
res.Payload = &objectReadCloser{
reader: rObj,
elapsedTimeCallback: func(elapsed time.Duration) {
c.incRequests(elapsed, methodObjectGet)
},
}

Lines 2714 to 2719 in 2b8329e
func (x *objectReadCloser) Read(p []byte) (int, error) {
start := time.Now()
n, err := x.reader.Read(p)
x.elapsedTimeCallback(time.Since(start))
return n, err
}

Steps to Reproduce (for bugs)

  1. Invoke ListContainersStream
  2. Invoke Statistics
  3. There is no way to know average request time for this method

Regression

Probably no

After https://git.frostfs.info/TrueCloudLab/frostfs-sdk-go/pulls/291 the `ListContainerStream` operation was added to the pool. But statistics for average request time for this method isn't updated ## Expected Behavior All pool methods counts average time. ## Current Behavior `ListContainerStream` https://git.frostfs.info/TrueCloudLab/frostfs-sdk-go/src/commit/2b8329e026c74d310817938c6cb8243749d0d49e/pool/pool.go#L150 doesn't calculate time ## Possible Solution Since this operations is streaming one we can use the same approach as in `GetObject` https://git.frostfs.info/TrueCloudLab/frostfs-sdk-go/src/commit/2b8329e026c74d310817938c6cb8243749d0d49e/pool/pool.go#L1051-L1069 https://git.frostfs.info/TrueCloudLab/frostfs-sdk-go/src/commit/2b8329e026c74d310817938c6cb8243749d0d49e/pool/pool.go#L2714-L2719 ## Steps to Reproduce (for bugs) <!--- Provide a link to a live example, or an unambiguous set of steps to --> <!--- reproduce this bug. --> 1. Invoke `ListContainersStream` 2. Invoke `Statistics` 3. There is no way to know average request time for this method ## Regression Probably no
dkirillov added the
bug
label 2025-03-03 09:47:30 +00:00
elebedeva was assigned by fyrchik 2025-03-03 11:07:22 +00:00
fyrchik added the
internal
label 2025-03-05 07:07:11 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: TrueCloudLab/frostfs-sdk-go#338
No description provided.