-
Notifications
You must be signed in to change notification settings - Fork 595
HDDS-10467. Reduce metrics visibility #6332
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
Conversation
| return totalWriteChunkBytes; | ||
| } | ||
|
|
||
| @VisibleForTesting |
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.
As tests for this class are in the same package, the VisibleForTesting annotation can be also removed.
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.
I also considered removing the annotation. Here's why I kept it (so far):
Javadoc of @VisibleForTesting says it should not be used on public or protected members, since that indicates bad design. By that logic it should only be applied to members with package-private (default) visibility. So removing it when tests are in the same package means we would never use the annotation.
On the other hand, I'm not sure if it's worth sprinkling all over the code for trivial accessors. Maybe we should limit it to methods with actual logic. Such methods exist in their own right for the class itself, only visibility is affected by usage in tests.
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.
VisibleForTesting annotation is overused in the codebase. I think a ticket named "Reduce metrics visibility" is a good chance to put things in order there, including the annotation.
If removing an annotation doesn't break tests, the annotation is not needed and should be removed.
myskov
left a comment
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.
Thanks for updating the patch, LGTM @adoroszlai
|
Thanks @kerneltime, @myskov for the review. |
(cherry picked from commit 87d8d61) Change-Id: Ic803fb7f3f28dd5dc9a279f1f74602e49a5ab9c2
What changes were proposed in this pull request?
Metrics sources should try to avoid exposing mutable metric objects as
public.value()instead of the mutable metric itselfOzoneManagerDoubleBufferMetricsto the package whereOzoneManagerDoubleBufferishttps://issues.apache.org/jira/browse/HDDS-10467
How was this patch tested?
CI:
https://github.com/adoroszlai/ozone/actions/runs/8160490612