Skip to content

Commit

Permalink
HBASE-29099 Avoid expensive BlockCacheKey.toString() calls when traci…
Browse files Browse the repository at this point in the history
…ng is disabled (#6642)

Signed-off-by: Ray Mattingly <[email protected]>
  • Loading branch information
jbewing authored Jan 28, 2025
1 parent b89c825 commit f14c3ac
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -1289,11 +1289,15 @@ public HFileBlock readBlock(long dataBlockOffset, long onDiskBlockSize, final bo

BlockCacheKey cacheKey =
new BlockCacheKey(path, dataBlockOffset, this.isPrimaryReplicaReader(), expectedBlockType);
Attributes attributes = Attributes.of(BLOCK_CACHE_KEY_KEY, cacheKey.toString());

boolean useLock = false;
IdLock.Entry lockEntry = null;
final Span span = Span.current();
// BlockCacheKey#toString() is quite expensive to call, so if tracing isn't enabled, don't
// record
Attributes attributes = span.isRecording()
? Attributes.of(BLOCK_CACHE_KEY_KEY, cacheKey.toString())
: Attributes.empty();
try {
while (true) {
// Check cache for block. If found return.
Expand Down

0 comments on commit f14c3ac

Please sign in to comment.