Skip to content
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

Add Read Metrics #18160

Merged
merged 3 commits into from
Sep 25, 2023
Merged

Add Read Metrics #18160

merged 3 commits into from
Sep 25, 2023

Conversation

huanghua78
Copy link
Contributor

What changes are proposed in this pull request?

Add client read metrics

Why are the changes needed?

These metrics are helpful.

Does this PR introduce any user facing changes?

N/A

return read(byteBuffer.array(), off, len);
totalBytesRead = read(byteBuffer.array(), off, len);
if (totalBytesRead > 0) {
Metrics.BYTES_READ_UFS.inc(totalBytesRead);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of adding the metric accounting logic in one specific class, I'd recommend making this logic a dedicated wrapper, e.g. MetricAccountingInputStream, which takes in an underlying generic InputStream, and the metric key that the number of bytes read from the underlying stream would be attributed to. The read methods then delegate to the underlying stream, and adjust the metric according to the bytes read from it.

This approach has the advantage of

  1. the metric accounting logic is separated from the main IO path, reducing the noise in code.
  2. the metric accounting logic is pluggable and composable. You can use any combination of input stream and metric key. The metric key will not be tied to a particular class like UfsFileInStream. If some one creates a new stream WorkerFirstThenFallbackToUfsInputStream and forgets about plugging in the metric accounting, then you lose track of the bytes read from UFS there.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

UfsFileInStream is the only top-level FileInStream that is created and used in UfsBaseFileSystem.
Various UFS will be opened in the UfsFileInStream.

I agree with you that your suggestion is a good idea. But let's do it later.

Signed-off-by: Huang Hua <huanghua78@msn.com>
Signed-off-by: Huang Hua <huanghua78@msn.com>
@huanghua78
Copy link
Contributor Author

@dbw9580 please review again.

Copy link
Contributor

@elega elega left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

Copy link
Contributor

@dbw9580 dbw9580 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@huanghua78
Copy link
Contributor Author

alluxio-bot, merge this please

@alluxio-bot
Copy link
Contributor

merge failed:
Merge refused because pull request does not have label start with type-

@huanghua78 huanghua78 added the type-feature This issue is a feature request label Sep 25, 2023
@huanghua78
Copy link
Contributor Author

alluxio-bot, merge this please

@alluxio-bot alluxio-bot merged commit fe55fc9 into Alluxio:main Sep 25, 2023
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-feature This issue is a feature request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants