-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[AWS] [S3] fix: improve object size metric calculation #41755
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,7 +36,7 @@ func init() { | |
// currentTime returns the current time. This exists to allow unit tests | ||
// simulate the passage of time. | ||
func currentTime() time.Time { | ||
clock := clockValue.Load().(clock) | ||
clock, _ := clockValue.Load().(clock) | ||
return clock.Now() | ||
} | ||
|
||
|
@@ -210,6 +210,8 @@ func newInputMetrics(id string, optionalParent *monitoring.Registry, maxWorkers | |
type monitoredReader struct { | ||
reader io.Reader | ||
totalBytesRead *monitoring.Uint | ||
|
||
trackBytes int64 | ||
Comment on lines
212
to
+214
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the naming could be more clear. "trackBytes" does not mean much to me. Maybe...
|
||
} | ||
|
||
func newMonitoredReader(r io.Reader, metric *monitoring.Uint) *monitoredReader { | ||
|
@@ -219,5 +221,10 @@ func newMonitoredReader(r io.Reader, metric *monitoring.Uint) *monitoredReader { | |
func (m *monitoredReader) Read(p []byte) (int, error) { | ||
n, err := m.reader.Read(p) | ||
m.totalBytesRead.Add(uint64(n)) | ||
m.trackBytes += int64(n) | ||
return n, err | ||
} | ||
|
||
func (m *monitoredReader) GetTrackedBytes() int64 { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The accessor seems unnecessary. The caller can read straight from the field. |
||
return m.trackBytes | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit - had to fix this to get lint correct