-
Notifications
You must be signed in to change notification settings - Fork 3.4k
HBASE-29222 Avoid expensive tracing calls if tracing is disabled #6863
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
HBASE-29222 Avoid expensive tracing calls if tracing is disabled #6863
Conversation
|
🎊 +1 overall
This message was automatically generated. |
|
🎊 +1 overall
This message was automatically generated. |
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.
Pull Request Overview
This PR optimizes tracing by skipping the construction of expensive OpenTelemetry attributes when spans are not recorded.
- Introduce helper methods to build attributes only when
span.isRecording()is true. - Refactor existing
span.addEventcalls inHFileBlockandBlockIOUtilsto use these helpers. - Add Javadoc for the new helper methods.
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/HFileBlock.java | Added getReadDataBlockInternalAttributes and replaced inline attribute building in readBlockDataInternal with calls to the helper. |
| hbase-common/src/main/java/org/apache/hadoop/hbase/io/util/BlockIOUtils.java | Introduced getDirectAndHeapBytesReadAttributes and getHeapBytesReadAttributes, and refactored multiple span.addEvent calls to use these helpers. |
Comments suppressed due to low confidence (3)
hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/HFileBlock.java:2208
- Add unit tests for
getReadDataBlockInternalAttributesto verify that attributes are correctly built whenspan.isRecording()is true and that no attributes are added when it is false.
private static Attributes getReadDataBlockInternalAttributes(Span span) {
hbase-common/src/main/java/org/apache/hadoop/hbase/io/util/BlockIOUtils.java:408
- Introduce tests for
getDirectAndHeapBytesReadAttributesto ensure that bytes-read attributes are correctly recorded only whenspan.isRecording()is enabled.
private static Attributes getDirectAndHeapBytesReadAttributes(Span span, int directBytesRead, int heapBytesRead) {
hbase-common/src/main/java/org/apache/hadoop/hbase/io/util/BlockIOUtils.java:430
- Add unit tests for
getHeapBytesReadAttributesto cover both enabled and disabled tracing scenarios.
private static Attributes getHeapBytesReadAttributes(Span span, int heapBytesRead) {
ndimiduk
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.
This looks good. I think there's more places where this approach is applicable. Please take those up if you're so inclined!
…che#6863) Signed-off-by: Nick Dimiduk <[email protected]>
…che#6863) Signed-off-by: Nick Dimiduk <[email protected]>
…che#6863) Signed-off-by: Nick Dimiduk <[email protected]>
Signed-off-by: Nick Dimiduk <[email protected]>
Signed-off-by: Nick Dimiduk <[email protected]>
Signed-off-by: Nick Dimiduk <[email protected]>
…che#6863) Signed-off-by: Nick Dimiduk <[email protected]>
What
This PR updates expensive tracing calls if tracing is disabled. In particular, the expensive tracing calls as determined by a flamegraph are in BlockIOUtils & HFileBlock. I've audited for other places where tracing is used to eliminate any other expensive calls as well (but couldn't find any outside of BlockIOUtils & HFileBlock).
This generally just follows the pattern of refactoring to use empty Attributes if we can determine that the Span isn't going to be persisted/saved anywhere via Span.isRecordingEnabled e.g. the same approach taken in #6642 / HBASE-29099
How
I used the Span.isRecordingEnabled API (OpenTelemetry Docs). Based on the following docsnippet, I believe that this will work if OpenTelemetry isn't enabled for HBase:
HBASE-29222