Skip to content

Commit caa61b5

Browse files
committed
HBASE-25591 Upgrade opentelemetry to 0.17.1 (#2971)
Signed-off-by: Guanghao Zhang <[email protected]>
1 parent 6b63b99 commit caa61b5

File tree

8 files changed

+44
-45
lines changed

8 files changed

+44
-45
lines changed

hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestAsyncTableTracing.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
import static org.mockito.Mockito.doAnswer;
2525
import static org.mockito.Mockito.mock;
2626

27-
import io.opentelemetry.api.trace.Span.Kind;
27+
import io.opentelemetry.api.trace.SpanKind;
2828
import io.opentelemetry.api.trace.StatusCode;
2929
import io.opentelemetry.sdk.testing.junit4.OpenTelemetryRule;
3030
import io.opentelemetry.sdk.trace.data.SpanData;
@@ -222,7 +222,7 @@ private void assertTrace(String methodName) {
222222
Waiter.waitFor(CONF, 1000,
223223
() -> traceRule.getSpans().stream()
224224
.anyMatch(span -> span.getName().equals("AsyncTable." + methodName) &&
225-
span.getKind() == Kind.INTERNAL && span.hasEnded()));
225+
span.getKind() == SpanKind.INTERNAL && span.hasEnded()));
226226
SpanData data = traceRule.getSpans().stream()
227227
.filter(s -> s.getName().equals("AsyncTable." + methodName)).findFirst().get();
228228
assertEquals(StatusCode.OK, data.getStatus().getStatusCode());
@@ -406,7 +406,7 @@ public void testConnClose() throws IOException {
406406
Waiter.waitFor(CONF, 1000,
407407
() -> traceRule.getSpans().stream()
408408
.anyMatch(span -> span.getName().equals("AsyncConnection.close") &&
409-
span.getKind() == Kind.INTERNAL && span.hasEnded()));
409+
span.getKind() == SpanKind.INTERNAL && span.hasEnded()));
410410
SpanData data = traceRule.getSpans().stream()
411411
.filter(s -> s.getName().equals("AsyncConnection.close")).findFirst().get();
412412
assertEquals(StatusCode.OK, data.getStatus().getStatusCode());

hbase-common/pom.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,10 @@
196196
<groupId>io.opentelemetry</groupId>
197197
<artifactId>opentelemetry-api</artifactId>
198198
</dependency>
199+
<dependency>
200+
<groupId>io.opentelemetry</groupId>
201+
<artifactId>opentelemetry-semconv</artifactId>
202+
</dependency>
199203
<dependency>
200204
<groupId>org.apache.commons</groupId>
201205
<artifactId>commons-crypto</artifactId>

hbase-common/src/main/java/org/apache/hadoop/hbase/trace/TraceUtil.java

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@
2020
import io.opentelemetry.api.GlobalOpenTelemetry;
2121
import io.opentelemetry.api.common.AttributeKey;
2222
import io.opentelemetry.api.trace.Span;
23-
import io.opentelemetry.api.trace.Span.Kind;
23+
import io.opentelemetry.api.trace.SpanKind;
2424
import io.opentelemetry.api.trace.StatusCode;
2525
import io.opentelemetry.api.trace.Tracer;
26-
import io.opentelemetry.api.trace.attributes.SemanticAttributes;
2726
import io.opentelemetry.context.Context;
2827
import io.opentelemetry.context.Scope;
28+
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes;
2929
import java.io.IOException;
3030
import java.util.List;
3131
import java.util.concurrent.CompletableFuture;
@@ -72,14 +72,14 @@ public static Tracer getGlobalTracer() {
7272
}
7373

7474
/**
75-
* Create a {@link Kind#INTERNAL} span.
75+
* Create a {@link SpanKind#INTERNAL} span.
7676
*/
7777
public static Span createSpan(String name) {
78-
return createSpan(name, Kind.INTERNAL);
78+
return createSpan(name, SpanKind.INTERNAL);
7979
}
8080

8181
/**
82-
* Create a {@link Kind#INTERNAL} span and set table related attributes.
82+
* Create a {@link SpanKind#INTERNAL} span and set table related attributes.
8383
*/
8484
public static Span createTableSpan(String spanName, TableName tableName) {
8585
return createSpan(spanName).setAttribute(NAMESPACE_KEY, tableName.getNamespaceAsString())
@@ -88,28 +88,29 @@ public static Span createTableSpan(String spanName, TableName tableName) {
8888

8989
/**
9090
* Create a span with the given {@code kind}. Notice that, OpenTelemetry only expects one
91-
* {@link Kind#CLIENT} span and one {@link Kind#SERVER} span for a traced request, so use this
92-
* with caution when you want to create spans with kind other than {@link Kind#INTERNAL}.
91+
* {@link SpanKind#CLIENT} span and one {@link SpanKind#SERVER} span for a traced request, so use
92+
* this with caution when you want to create spans with kind other than {@link SpanKind#INTERNAL}.
9393
*/
94-
private static Span createSpan(String name, Kind kind) {
94+
private static Span createSpan(String name, SpanKind kind) {
9595
return getGlobalTracer().spanBuilder(name).setSpanKind(kind).startSpan();
9696
}
9797

9898
/**
9999
* Create a span which parent is from remote, i.e, passed through rpc.
100100
* </p>
101-
* We will set the kind of the returned span to {@link Kind#SERVER}, as this should be the top
101+
* We will set the kind of the returned span to {@link SpanKind#SERVER}, as this should be the top
102102
* most span at server side.
103103
*/
104104
public static Span createRemoteSpan(String name, Context ctx) {
105-
return getGlobalTracer().spanBuilder(name).setParent(ctx).setSpanKind(Kind.SERVER).startSpan();
105+
return getGlobalTracer().spanBuilder(name).setParent(ctx).setSpanKind(SpanKind.SERVER)
106+
.startSpan();
106107
}
107108

108109
/**
109-
* Create a span with {@link Kind#CLIENT}.
110+
* Create a span with {@link SpanKind#CLIENT}.
110111
*/
111112
public static Span createClientSpan(String name) {
112-
return createSpan(name, Kind.CLIENT);
113+
return createSpan(name, SpanKind.CLIENT);
113114
}
114115

115116
/**

hbase-it/src/test/java/org/apache/hadoop/hbase/mttr/IntegrationTestMTTR.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@
5454
import org.apache.hadoop.hbase.client.RetriesExhaustedException;
5555
import org.apache.hadoop.hbase.client.Scan;
5656
import org.apache.hadoop.hbase.client.Table;
57-
import org.apache.hadoop.hbase.client.TableDescriptor;
5857
import org.apache.hadoop.hbase.client.TableDescriptorBuilder;
5958
import org.apache.hadoop.hbase.coprocessor.CoprocessorException;
6059
import org.apache.hadoop.hbase.filter.KeyOnlyFilter;
@@ -378,7 +377,7 @@ private static class TimingResult {
378377
public void addResult(long time, Span span) {
379378
stats.addValue(TimeUnit.MILLISECONDS.convert(time, TimeUnit.NANOSECONDS));
380379
if (TimeUnit.SECONDS.convert(time, TimeUnit.NANOSECONDS) >= 1) {
381-
traces.add(span.getSpanContext().getTraceIdAsHexString());
380+
traces.add(span.getSpanContext().getTraceId());
382381
}
383382
}
384383

hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/ServerRpcConnection.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
import io.opentelemetry.api.trace.Span;
2424
import io.opentelemetry.context.Context;
2525
import io.opentelemetry.context.Scope;
26-
import io.opentelemetry.context.propagation.TextMapPropagator;
26+
import io.opentelemetry.context.propagation.TextMapGetter;
2727
import java.io.ByteArrayInputStream;
2828
import java.io.Closeable;
2929
import java.io.DataOutputStream;
@@ -615,7 +615,7 @@ protected void processRequest(ByteBuff buf) throws IOException,
615615
ProtobufUtil.mergeFrom(builder, cis, headerSize);
616616
RequestHeader header = (RequestHeader) builder.build();
617617
offset += headerSize;
618-
TextMapPropagator.Getter<RPCTInfo> getter = new TextMapPropagator.Getter<RPCTInfo>() {
618+
TextMapGetter<RPCTInfo> getter = new TextMapGetter<RPCTInfo>() {
619619

620620
@Override
621621
public Iterable<String> keys(RPCTInfo carrier) {

hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/AbstractTestIPC.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
import static org.mockito.Mockito.verify;
3535
import static org.mockito.internal.verification.VerificationModeFactory.times;
3636

37-
import io.opentelemetry.api.trace.Span.Kind;
37+
import io.opentelemetry.api.trace.SpanKind;
3838
import io.opentelemetry.api.trace.StatusCode;
3939
import io.opentelemetry.sdk.testing.junit4.OpenTelemetryRule;
4040
import io.opentelemetry.sdk.trace.data.SpanData;
@@ -457,7 +457,7 @@ private SpanData waitSpan(String name) {
457457
}
458458

459459
private void assertRpcAttribute(SpanData data, String methodName, InetSocketAddress addr,
460-
Kind kind) {
460+
SpanKind kind) {
461461
assertEquals(SERVICE.getDescriptorForType().getName(),
462462
data.getAttributes().get(TraceUtil.RPC_SERVICE_KEY));
463463
assertEquals(methodName, data.getAttributes().get(TraceUtil.RPC_METHOD_KEY));
@@ -471,7 +471,7 @@ private void assertRpcAttribute(SpanData data, String methodName, InetSocketAddr
471471
private void assertRemoteSpan() {
472472
SpanData data = waitSpan("RpcServer.process");
473473
assertTrue(data.getParentSpanContext().isRemote());
474-
assertEquals(Kind.SERVER, data.getKind());
474+
assertEquals(SpanKind.SERVER, data.getKind());
475475
}
476476

477477
@Test
@@ -484,8 +484,8 @@ public void testTracing() throws IOException, ServiceException {
484484
BlockingInterface stub = newBlockingStub(client, rpcServer.getListenerAddress());
485485
stub.pause(null, PauseRequestProto.newBuilder().setMs(100).build());
486486
assertRpcAttribute(waitSpan("RpcClient.callMethod"), "pause", rpcServer.getListenerAddress(),
487-
Kind.CLIENT);
488-
assertRpcAttribute(waitSpan("RpcServer.callMethod"), "pause", null, Kind.INTERNAL);
487+
SpanKind.CLIENT);
488+
assertRpcAttribute(waitSpan("RpcServer.callMethod"), "pause", null, SpanKind.INTERNAL);
489489
assertRemoteSpan();
490490
assertSameTraceId();
491491
for (SpanData data : traceRule.getSpans()) {
@@ -499,8 +499,8 @@ public void testTracing() throws IOException, ServiceException {
499499
assertThrows(ServiceException.class,
500500
() -> stub.error(null, EmptyRequestProto.getDefaultInstance()));
501501
assertRpcAttribute(waitSpan("RpcClient.callMethod"), "error", rpcServer.getListenerAddress(),
502-
Kind.CLIENT);
503-
assertRpcAttribute(waitSpan("RpcServer.callMethod"), "error", null, Kind.INTERNAL);
502+
SpanKind.CLIENT);
503+
assertRpcAttribute(waitSpan("RpcServer.callMethod"), "error", null, SpanKind.INTERNAL);
504504
assertRemoteSpan();
505505
assertSameTraceId();
506506
for (SpanData data : traceRule.getSpans()) {

hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegionTracing.java

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import java.io.IOException;
2424
import java.util.ArrayList;
2525
import java.util.List;
26+
import org.apache.hadoop.fs.Path;
2627
import org.apache.hadoop.hbase.HBaseClassTestRule;
2728
import org.apache.hadoop.hbase.HBaseTestingUtility;
2829
import org.apache.hadoop.hbase.TableName;
@@ -48,7 +49,6 @@
4849
import org.junit.After;
4950
import org.junit.AfterClass;
5051
import org.junit.Before;
51-
import org.junit.BeforeClass;
5252
import org.junit.ClassRule;
5353
import org.junit.Rule;
5454
import org.junit.Test;
@@ -79,18 +79,12 @@ public class TestHRegionTracing {
7979
@Rule
8080
public final TableNameTestRule tableNameRule = new TableNameTestRule();
8181

82-
private static WAL WAL;
82+
private WAL wal;
8383

8484
private HRegion region;
8585

86-
@BeforeClass
87-
public static void setUpBeforeClass() throws IOException {
88-
WAL = HBaseTestingUtility.createWal(UTIL.getConfiguration(), UTIL.getDataTestDir(), null);
89-
}
90-
9186
@AfterClass
9287
public static void tearDownAfterClass() throws IOException {
93-
Closeables.close(WAL, true);
9488
UTIL.cleanupTestDir();
9589
}
9690

@@ -102,7 +96,9 @@ public void setUp() throws IOException {
10296
RegionInfo info = RegionInfoBuilder.newBuilder(tableName).build();
10397
ChunkCreator.initialize(MemStoreLAB.CHUNK_SIZE_DEFAULT, false, 0, 0, 0, null,
10498
MemStoreLAB.INDEX_CHUNK_SIZE_PERCENTAGE_DEFAULT);
105-
region = HRegion.createHRegion(info, UTIL.getDataTestDir(), UTIL.getConfiguration(), desc, WAL);
99+
wal = HBaseTestingUtility.createWal(UTIL.getConfiguration(),
100+
new Path(UTIL.getDataTestDir(), tableName.getNameAsString()), null);
101+
region = HRegion.createHRegion(info, UTIL.getDataTestDir(), UTIL.getConfiguration(), desc, wal);
106102
region = UTIL.createLocalHRegion(info, desc);
107103
}
108104

@@ -111,6 +107,7 @@ public void tearDown() throws IOException {
111107
if (region != null) {
112108
region.close();
113109
}
110+
Closeables.close(wal, true);
114111
}
115112

116113
private void assertSpan(String spanName) {

pom.xml

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1663,7 +1663,8 @@
16631663
<jruby.version>9.2.13.0</jruby.version>
16641664
<junit.version>4.13</junit.version>
16651665
<hamcrest.version>1.3</hamcrest.version>
1666-
<opentelemetry.version>0.13.1</opentelemetry.version>
1666+
<opentelemetry.version>0.17.1</opentelemetry.version>
1667+
<opentelemetry-javaagent.version>0.17.0</opentelemetry-javaagent.version>
16671668
<log4j.version>1.2.17</log4j.version>
16681669
<mockito-core.version>2.28.2</mockito-core.version>
16691670
<protobuf.plugin.version>0.6.1</protobuf.plugin.version>
@@ -2331,23 +2332,20 @@
23312332
</dependency>
23322333
<dependency>
23332334
<groupId>io.opentelemetry</groupId>
2334-
<artifactId>opentelemetry-api</artifactId>
2335-
<version>${opentelemetry.version}</version>
2336-
</dependency>
2337-
<dependency>
2338-
<groupId>io.opentelemetry</groupId>
2339-
<artifactId>opentelemetry-sdk</artifactId>
2335+
<artifactId>opentelemetry-bom</artifactId>
23402336
<version>${opentelemetry.version}</version>
2337+
<type>pom</type>
2338+
<scope>import</scope>
23412339
</dependency>
23422340
<dependency>
23432341
<groupId>io.opentelemetry</groupId>
2344-
<artifactId>opentelemetry-sdk-testing</artifactId>
2345-
<version>${opentelemetry.version}</version>
2342+
<artifactId>opentelemetry-semconv</artifactId>
2343+
<version>${opentelemetry.version}-alpha</version>
23462344
</dependency>
23472345
<dependency>
23482346
<groupId>io.opentelemetry.javaagent</groupId>
23492347
<artifactId>opentelemetry-javaagent</artifactId>
2350-
<version>${opentelemetry.version}</version>
2348+
<version>${opentelemetry-javaagent.version}</version>
23512349
<classifier>all</classifier>
23522350
</dependency>
23532351
<dependency>

0 commit comments

Comments
 (0)