diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncConnectionImpl.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncConnectionImpl.java index 28e3456c90e..1ba4d6d6489 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncConnectionImpl.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncConnectionImpl.java @@ -1,4 +1,4 @@ -/** +/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information @@ -25,6 +25,7 @@ import static org.apache.hadoop.hbase.client.ConnectionUtils.NO_NONCE_GENERATOR; import static org.apache.hadoop.hbase.client.ConnectionUtils.getStubKey; import static org.apache.hadoop.hbase.client.MetricsConnection.CLIENT_SIDE_METRICS_ENABLED_KEY; import static org.apache.hadoop.hbase.client.NonceGenerator.CLIENT_NONCES_ENABLED_KEY; +import static org.apache.hadoop.hbase.trace.HBaseSemanticAttributes.SERVER_NAME_KEY; import static org.apache.hadoop.hbase.util.FutureUtils.addListener; import io.opentelemetry.api.trace.Span; @@ -410,7 +411,7 @@ class AsyncConnectionImpl implements AsyncConnection { } private Hbck getHbckInternal(ServerName masterServer) { - Span.current().setAttribute(TraceUtil.SERVER_NAME_KEY, masterServer.getServerName()); + Span.current().setAttribute(SERVER_NAME_KEY, masterServer.getServerName()); // we will not create a new connection when creating a new protobuf stub, and for hbck there // will be no performance consideration, so for simplification we will create a new stub every // time instead of caching the stub here. diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncRegionLocator.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncRegionLocator.java index 716598af432..5110b46d225 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncRegionLocator.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncRegionLocator.java @@ -18,8 +18,8 @@ package org.apache.hadoop.hbase.client; import static org.apache.hadoop.hbase.TableName.META_TABLE_NAME; -import static org.apache.hadoop.hbase.trace.TraceUtil.REGION_NAMES_KEY; -import static org.apache.hadoop.hbase.trace.TraceUtil.SERVER_NAME_KEY; +import static org.apache.hadoop.hbase.trace.HBaseSemanticAttributes.REGION_NAMES_KEY; +import static org.apache.hadoop.hbase.trace.HBaseSemanticAttributes.SERVER_NAME_KEY; import static org.apache.hadoop.hbase.trace.TraceUtil.createSpan; import static org.apache.hadoop.hbase.trace.TraceUtil.createTableSpan; import static org.apache.hadoop.hbase.util.FutureUtils.addListener; diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/ipc/AbstractRpcClient.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/ipc/AbstractRpcClient.java index ee516ae9dd6..9b50ae2c70e 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/ipc/AbstractRpcClient.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/ipc/AbstractRpcClient.java @@ -1,4 +1,4 @@ -/** +/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information @@ -20,6 +20,10 @@ package org.apache.hadoop.hbase.ipc; import static org.apache.hadoop.hbase.ipc.IPCUtil.toIOE; import static org.apache.hadoop.hbase.ipc.IPCUtil.wrapException; +import static org.apache.hadoop.hbase.trace.HBaseSemanticAttributes.REMOTE_HOST_KEY; +import static org.apache.hadoop.hbase.trace.HBaseSemanticAttributes.REMOTE_PORT_KEY; +import static org.apache.hadoop.hbase.trace.HBaseSemanticAttributes.RPC_METHOD_KEY; +import static org.apache.hadoop.hbase.trace.HBaseSemanticAttributes.RPC_SERVICE_KEY; import io.opentelemetry.api.trace.Span; import io.opentelemetry.api.trace.StatusCode; @@ -396,10 +400,10 @@ public abstract class AbstractRpcClient implements RpcC final Message param, Message returnType, final User ticket, final Address addr, final RpcCallback callback) { Span span = TraceUtil.createClientSpan("RpcClient.callMethod") - .setAttribute(TraceUtil.RPC_SERVICE_KEY, md.getService().getName()) - .setAttribute(TraceUtil.RPC_METHOD_KEY, md.getName()) - .setAttribute(TraceUtil.REMOTE_HOST_KEY, addr.getHostName()) - .setAttribute(TraceUtil.REMOTE_PORT_KEY, addr.getPort()); + .setAttribute(RPC_SERVICE_KEY, md.getService().getName()) + .setAttribute(RPC_METHOD_KEY, md.getName()) + .setAttribute(REMOTE_HOST_KEY, addr.getHostName()) + .setAttribute(REMOTE_PORT_KEY, addr.getPort()); try (Scope scope = span.makeCurrent()) { final MetricsConnection.CallStats cs = MetricsConnection.newCallStats(); cs.setStartTime(EnvironmentEdgeManager.currentTime()); diff --git a/hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestAsyncConnectionTracing.java b/hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestAsyncConnectionTracing.java index eef0b1392f7..b344ff5febc 100644 --- a/hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestAsyncConnectionTracing.java +++ b/hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestAsyncConnectionTracing.java @@ -33,7 +33,7 @@ import org.apache.hadoop.hbase.Waiter; import org.apache.hadoop.hbase.security.UserProvider; import org.apache.hadoop.hbase.testclassification.ClientTests; import org.apache.hadoop.hbase.testclassification.MediumTests; -import org.apache.hadoop.hbase.trace.TraceUtil; +import org.apache.hadoop.hbase.trace.HBaseSemanticAttributes; import org.apache.hadoop.hbase.util.EnvironmentEdgeManager; import org.junit.After; import org.junit.Before; @@ -89,7 +89,7 @@ public class TestAsyncConnectionTracing { assertEquals(StatusCode.OK, data.getStatus().getStatusCode()); if (serverName != null) { assertEquals(serverName.getServerName(), - data.getAttributes().get(TraceUtil.SERVER_NAME_KEY)); + data.getAttributes().get(HBaseSemanticAttributes.SERVER_NAME_KEY)); } } diff --git a/hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestAsyncRegionLocatorTracing.java b/hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestAsyncRegionLocatorTracing.java index 15b00f6e65f..83a71db3b96 100644 --- a/hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestAsyncRegionLocatorTracing.java +++ b/hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestAsyncRegionLocatorTracing.java @@ -38,7 +38,7 @@ import org.apache.hadoop.hbase.Waiter; import org.apache.hadoop.hbase.security.UserProvider; import org.apache.hadoop.hbase.testclassification.ClientTests; import org.apache.hadoop.hbase.testclassification.MediumTests; -import org.apache.hadoop.hbase.trace.TraceUtil; +import org.apache.hadoop.hbase.trace.HBaseSemanticAttributes; import org.apache.hadoop.hbase.util.EnvironmentEdgeManager; import org.junit.After; import org.junit.Before; @@ -109,7 +109,7 @@ public class TestAsyncRegionLocatorTracing { conn.getLocator().clearCache(sn); SpanData span = waitSpan("AsyncRegionLocator.clearCache"); assertEquals(StatusCode.OK, span.getStatus().getStatusCode()); - assertEquals(sn.toString(), span.getAttributes().get(TraceUtil.SERVER_NAME_KEY)); + assertEquals(sn.toString(), span.getAttributes().get(HBaseSemanticAttributes.SERVER_NAME_KEY)); } @Test @@ -118,9 +118,9 @@ public class TestAsyncRegionLocatorTracing { SpanData span = waitSpan("AsyncRegionLocator.clearCache"); assertEquals(StatusCode.OK, span.getStatus().getStatusCode()); assertEquals(TableName.META_TABLE_NAME.getNamespaceAsString(), - span.getAttributes().get(TraceUtil.NAMESPACE_KEY)); + span.getAttributes().get(HBaseSemanticAttributes.NAMESPACE_KEY)); assertEquals(TableName.META_TABLE_NAME.getNameAsString(), - span.getAttributes().get(TraceUtil.TABLE_KEY)); + span.getAttributes().get(HBaseSemanticAttributes.TABLE_KEY)); } @Test @@ -130,10 +130,10 @@ public class TestAsyncRegionLocatorTracing { SpanData span = waitSpan("AsyncRegionLocator.getRegionLocation"); assertEquals(StatusCode.OK, span.getStatus().getStatusCode()); assertEquals(TableName.META_TABLE_NAME.getNamespaceAsString(), - span.getAttributes().get(TraceUtil.NAMESPACE_KEY)); + span.getAttributes().get(HBaseSemanticAttributes.NAMESPACE_KEY)); assertEquals(TableName.META_TABLE_NAME.getNameAsString(), - span.getAttributes().get(TraceUtil.TABLE_KEY)); - List regionNames = span.getAttributes().get(TraceUtil.REGION_NAMES_KEY); + span.getAttributes().get(HBaseSemanticAttributes.TABLE_KEY)); + List regionNames = span.getAttributes().get(HBaseSemanticAttributes.REGION_NAMES_KEY); assertEquals(1, regionNames.size()); assertEquals(locs.getDefaultRegionLocation().getRegion().getRegionNameAsString(), regionNames.get(0)); @@ -146,10 +146,10 @@ public class TestAsyncRegionLocatorTracing { SpanData span = waitSpan("AsyncRegionLocator.getRegionLocations"); assertEquals(StatusCode.OK, span.getStatus().getStatusCode()); assertEquals(TableName.META_TABLE_NAME.getNamespaceAsString(), - span.getAttributes().get(TraceUtil.NAMESPACE_KEY)); + span.getAttributes().get(HBaseSemanticAttributes.NAMESPACE_KEY)); assertEquals(TableName.META_TABLE_NAME.getNameAsString(), - span.getAttributes().get(TraceUtil.TABLE_KEY)); - List regionNames = span.getAttributes().get(TraceUtil.REGION_NAMES_KEY); + span.getAttributes().get(HBaseSemanticAttributes.TABLE_KEY)); + List regionNames = span.getAttributes().get(HBaseSemanticAttributes.REGION_NAMES_KEY); assertEquals(3, regionNames.size()); for (int i = 0; i < 3; i++) { assertEquals(locs.getRegionLocation(i).getRegion().getRegionNameAsString(), diff --git a/hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestAsyncTableTracing.java b/hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestAsyncTableTracing.java index 0be9bdbd82e..a1770e7004a 100644 --- a/hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestAsyncTableTracing.java +++ b/hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestAsyncTableTracing.java @@ -1,4 +1,4 @@ -/** +/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information @@ -17,6 +17,8 @@ */ package org.apache.hadoop.hbase.client; +import static org.apache.hadoop.hbase.trace.HBaseSemanticAttributes.NAMESPACE_KEY; +import static org.apache.hadoop.hbase.trace.HBaseSemanticAttributes.TABLE_KEY; import static org.junit.Assert.assertEquals; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyInt; @@ -48,7 +50,6 @@ import org.apache.hadoop.hbase.ipc.HBaseRpcController; import org.apache.hadoop.hbase.security.UserProvider; import org.apache.hadoop.hbase.testclassification.ClientTests; import org.apache.hadoop.hbase.testclassification.MediumTests; -import org.apache.hadoop.hbase.trace.TraceUtil; import org.apache.hadoop.hbase.util.Bytes; import org.junit.After; import org.junit.Before; @@ -227,9 +228,8 @@ public class TestAsyncTableTracing { .filter(s -> s.getName().equals("AsyncTable." + methodName)).findFirst().get(); assertEquals(StatusCode.OK, data.getStatus().getStatusCode()); TableName tableName = table.getName(); - assertEquals(tableName.getNamespaceAsString(), - data.getAttributes().get(TraceUtil.NAMESPACE_KEY)); - assertEquals(tableName.getNameAsString(), data.getAttributes().get(TraceUtil.TABLE_KEY)); + assertEquals(tableName.getNamespaceAsString(), data.getAttributes().get(NAMESPACE_KEY)); + assertEquals(tableName.getNameAsString(), data.getAttributes().get(TABLE_KEY)); } @Test diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/trace/HBaseSemanticAttributes.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/trace/HBaseSemanticAttributes.java new file mode 100644 index 00000000000..1eb5d820d99 --- /dev/null +++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/trace/HBaseSemanticAttributes.java @@ -0,0 +1,48 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.hadoop.hbase.trace; + +import io.opentelemetry.api.common.AttributeKey; +import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; +import java.util.List; +import org.apache.yetus.audience.InterfaceAudience; + +/** + * The constants in this class correspond with the guidance outlined by the OpenTelemetry + * Semantic Conventions. +*/ +@InterfaceAudience.Private +public final class HBaseSemanticAttributes { + public static final AttributeKey NAMESPACE_KEY = SemanticAttributes.DB_HBASE_NAMESPACE; + public static final AttributeKey TABLE_KEY = AttributeKey.stringKey("db.hbase.table"); + public static final AttributeKey> REGION_NAMES_KEY = + AttributeKey.stringArrayKey("db.hbase.regions"); + public static final AttributeKey RPC_SERVICE_KEY = + AttributeKey.stringKey("db.hbase.rpc.service"); + public static final AttributeKey RPC_METHOD_KEY = + AttributeKey.stringKey("db.hbase.rpc.method"); + public static final AttributeKey SERVER_NAME_KEY = + AttributeKey.stringKey("db.hbase.server.name"); + public static final AttributeKey REMOTE_HOST_KEY = SemanticAttributes.NET_PEER_NAME; + public static final AttributeKey REMOTE_PORT_KEY = SemanticAttributes.NET_PEER_PORT; + public static final AttributeKey ROW_LOCK_READ_LOCK_KEY = + AttributeKey.booleanKey("db.hbase.rowlock.readlock"); + public static final AttributeKey WAL_IMPL = AttributeKey.stringKey("db.hbase.wal.impl"); + + private HBaseSemanticAttributes() { } +} diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/trace/TraceUtil.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/trace/TraceUtil.java index 74e6daa1ed7..e360705916d 100644 --- a/hbase-common/src/main/java/org/apache/hadoop/hbase/trace/TraceUtil.java +++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/trace/TraceUtil.java @@ -1,4 +1,4 @@ -/** +/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information @@ -17,15 +17,15 @@ */ package org.apache.hadoop.hbase.trace; +import static org.apache.hadoop.hbase.trace.HBaseSemanticAttributes.NAMESPACE_KEY; +import static org.apache.hadoop.hbase.trace.HBaseSemanticAttributes.TABLE_KEY; import io.opentelemetry.api.GlobalOpenTelemetry; -import io.opentelemetry.api.common.AttributeKey; import io.opentelemetry.api.trace.Span; import io.opentelemetry.api.trace.SpanKind; import io.opentelemetry.api.trace.StatusCode; import io.opentelemetry.api.trace.Tracer; import io.opentelemetry.context.Context; import io.opentelemetry.context.Scope; -import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import java.io.IOException; import java.util.List; import java.util.concurrent.CompletableFuture; @@ -38,31 +38,6 @@ import org.apache.yetus.audience.InterfaceAudience; @InterfaceAudience.Private public final class TraceUtil { - public static final AttributeKey NAMESPACE_KEY = SemanticAttributes.DB_HBASE_NAMESPACE; - - public static final AttributeKey TABLE_KEY = AttributeKey.stringKey("db.hbase.table"); - - public static final AttributeKey> REGION_NAMES_KEY = - AttributeKey.stringArrayKey("db.hbase.regions"); - - public static final AttributeKey RPC_SERVICE_KEY = - AttributeKey.stringKey("db.hbase.rpc.service"); - - public static final AttributeKey RPC_METHOD_KEY = - AttributeKey.stringKey("db.hbase.rpc.method"); - - public static final AttributeKey SERVER_NAME_KEY = - AttributeKey.stringKey("db.hbase.server.name"); - - public static final AttributeKey REMOTE_HOST_KEY = SemanticAttributes.NET_PEER_NAME; - - public static final AttributeKey REMOTE_PORT_KEY = SemanticAttributes.NET_PEER_PORT; - - public static final AttributeKey ROW_LOCK_READ_LOCK_KEY = - AttributeKey.booleanKey("db.hbase.rowlock.readlock"); - - public static final AttributeKey WAL_IMPL = AttributeKey.stringKey("db.hbase.wal.impl"); - private TraceUtil() { } @@ -81,7 +56,8 @@ public final class TraceUtil { * Create a {@link SpanKind#INTERNAL} span and set table related attributes. */ public static Span createTableSpan(String spanName, TableName tableName) { - return createSpan(spanName).setAttribute(NAMESPACE_KEY, tableName.getNamespaceAsString()) + return createSpan(spanName) + .setAttribute(NAMESPACE_KEY, tableName.getNamespaceAsString()) .setAttribute(TABLE_KEY, tableName.getNameAsString()); } diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/CallRunner.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/CallRunner.java index 6e2c37e3a8c..ef37247f412 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/CallRunner.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/CallRunner.java @@ -1,4 +1,4 @@ -/** +/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information @@ -17,6 +17,8 @@ */ package org.apache.hadoop.hbase.ipc; +import static org.apache.hadoop.hbase.trace.HBaseSemanticAttributes.RPC_METHOD_KEY; +import static org.apache.hadoop.hbase.trace.HBaseSemanticAttributes.RPC_SERVICE_KEY; import io.opentelemetry.api.trace.Span; import io.opentelemetry.api.trace.StatusCode; import io.opentelemetry.context.Context; @@ -124,8 +126,8 @@ public class CallRunner { String methodName = getMethodName(); Span span = TraceUtil.getGlobalTracer().spanBuilder("RpcServer.callMethod") .setParent(Context.current().with(((ServerCall) call).getSpan())).startSpan() - .setAttribute(TraceUtil.RPC_SERVICE_KEY, serviceName) - .setAttribute(TraceUtil.RPC_METHOD_KEY, methodName); + .setAttribute(RPC_SERVICE_KEY, serviceName) + .setAttribute(RPC_METHOD_KEY, methodName); try (Scope traceScope = span.makeCurrent()) { if (!this.rpcServer.isStarted()) { InetSocketAddress address = rpcServer.getListenerAddress(); diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java index b534f684740..63992dc97a4 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java @@ -1,4 +1,4 @@ -/** +/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information @@ -19,6 +19,8 @@ package org.apache.hadoop.hbase.regionserver; import static org.apache.hadoop.hbase.HConstants.REPLICATION_SCOPE_LOCAL; import static org.apache.hadoop.hbase.regionserver.HStoreFile.MAJOR_COMPACTION_KEY; +import static org.apache.hadoop.hbase.trace.HBaseSemanticAttributes.REGION_NAMES_KEY; +import static org.apache.hadoop.hbase.trace.HBaseSemanticAttributes.ROW_LOCK_READ_LOCK_KEY; import static org.apache.hadoop.hbase.util.ConcurrentMapUtils.computeIfAbsent; import edu.umd.cs.findbugs.annotations.Nullable; @@ -6591,8 +6593,8 @@ public class HRegion implements HeapSize, PropagatingConfigurationObserver, Regi } Span createRegionSpan(String name) { - return TraceUtil.createSpan(name).setAttribute(TraceUtil.REGION_NAMES_KEY, - Arrays.asList(getRegionInfo().getRegionNameAsString())); + return TraceUtil.createSpan(name).setAttribute(REGION_NAMES_KEY, + Collections.singletonList(getRegionInfo().getRegionNameAsString())); } // will be override in tests @@ -6679,7 +6681,7 @@ public class HRegion implements HeapSize, PropagatingConfigurationObserver, Regi private RowLock getRowLock(byte[] row, boolean readLock, final RowLock prevRowLock) throws IOException { return TraceUtil.trace(() -> getRowLockInternal(row, readLock, prevRowLock), - () -> createRegionSpan("Region.getRowLock").setAttribute(TraceUtil.ROW_LOCK_READ_LOCK_KEY, + () -> createRegionSpan("Region.getRowLock").setAttribute(ROW_LOCK_READ_LOCK_KEY, readLock)); } diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/AbstractFSWAL.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/AbstractFSWAL.java index 002d9b776dc..2e99fa8a13f 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/AbstractFSWAL.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/AbstractFSWAL.java @@ -1,4 +1,4 @@ -/** +/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information @@ -20,6 +20,7 @@ package org.apache.hadoop.hbase.regionserver.wal; import static org.apache.hadoop.hbase.regionserver.wal.WALActionsListener.RollRequestReason.ERROR; import static org.apache.hadoop.hbase.regionserver.wal.WALActionsListener.RollRequestReason.LOW_REPLICATION; import static org.apache.hadoop.hbase.regionserver.wal.WALActionsListener.RollRequestReason.SLOW_SYNC; +import static org.apache.hadoop.hbase.trace.HBaseSemanticAttributes.WAL_IMPL; import static org.apache.hadoop.hbase.wal.AbstractFSWALProvider.WAL_FILE_NAME_DELIMITER; import static org.apache.hbase.thirdparty.com.google.common.base.Preconditions.checkArgument; import static org.apache.hbase.thirdparty.com.google.common.base.Preconditions.checkNotNull; @@ -841,7 +842,7 @@ public abstract class AbstractFSWAL implements WAL { } private Span createSpan(String name) { - return TraceUtil.createSpan(name).setAttribute(TraceUtil.WAL_IMPL, implClassName); + return TraceUtil.createSpan(name).setAttribute(WAL_IMPL, implClassName); } /** diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/AbstractTestIPC.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/AbstractTestIPC.java index ce753430b33..030b052cb1e 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/AbstractTestIPC.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/AbstractTestIPC.java @@ -53,7 +53,7 @@ import org.apache.hadoop.hbase.KeyValue; import org.apache.hadoop.hbase.Server; import org.apache.hadoop.hbase.Waiter; import org.apache.hadoop.hbase.ipc.RpcServer.BlockingServiceAndInterface; -import org.apache.hadoop.hbase.trace.TraceUtil; +import org.apache.hadoop.hbase.trace.HBaseSemanticAttributes; import org.apache.hadoop.hbase.util.Bytes; import org.apache.hadoop.io.compress.GzipCodec; import org.apache.hadoop.util.StringUtils; @@ -459,11 +459,15 @@ public abstract class AbstractTestIPC { private void assertRpcAttribute(SpanData data, String methodName, InetSocketAddress addr, SpanKind kind) { assertEquals(SERVICE.getDescriptorForType().getName(), - data.getAttributes().get(TraceUtil.RPC_SERVICE_KEY)); - assertEquals(methodName, data.getAttributes().get(TraceUtil.RPC_METHOD_KEY)); + data.getAttributes().get(HBaseSemanticAttributes.RPC_SERVICE_KEY)); + assertEquals(methodName, data.getAttributes().get(HBaseSemanticAttributes.RPC_METHOD_KEY)); if (addr != null) { - assertEquals(addr.getHostName(), data.getAttributes().get(TraceUtil.REMOTE_HOST_KEY)); - assertEquals(addr.getPort(), data.getAttributes().get(TraceUtil.REMOTE_PORT_KEY).intValue()); + assertEquals( + addr.getHostName(), + data.getAttributes().get(HBaseSemanticAttributes.REMOTE_HOST_KEY)); + assertEquals( + addr.getPort(), + data.getAttributes().get(HBaseSemanticAttributes.REMOTE_PORT_KEY).intValue()); } assertEquals(kind, data.getKind()); } diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegionTracing.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegionTracing.java index 0b4ec8f6a99..62f8a150bcf 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegionTracing.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegionTracing.java @@ -43,7 +43,7 @@ import org.apache.hadoop.hbase.client.TableDescriptor; import org.apache.hadoop.hbase.client.TableDescriptorBuilder; import org.apache.hadoop.hbase.testclassification.MediumTests; import org.apache.hadoop.hbase.testclassification.RegionServerTests; -import org.apache.hadoop.hbase.trace.TraceUtil; +import org.apache.hadoop.hbase.trace.HBaseSemanticAttributes; import org.apache.hadoop.hbase.util.Bytes; import org.apache.hadoop.hbase.wal.WAL; import org.junit.After; @@ -115,7 +115,7 @@ public class TestHRegionTracing { if (!span.getName().equals(spanName)) { return false; } - List regionNames = span.getAttributes().get(TraceUtil.REGION_NAMES_KEY); + List regionNames = span.getAttributes().get(HBaseSemanticAttributes.REGION_NAMES_KEY); return regionNames != null && regionNames.size() == 1 && regionNames.get(0).equals(region.getRegionInfo().getRegionNameAsString()); }));