Skip to content

Commit 0d78c20

Browse files
committed
convert test to java
1 parent c634f71 commit 0d78c20

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

sdk-autoconfigure-support/src/main/java/io/opentelemetry/instrumentation/tracer/AddThreadDetailsSpanProcessor.java

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,28 @@
55

66
package io.opentelemetry.instrumentation.tracer;
77

8+
import static io.opentelemetry.api.common.AttributeKey.longKey;
9+
import static io.opentelemetry.api.common.AttributeKey.stringKey;
10+
11+
import io.opentelemetry.api.common.AttributeKey;
812
import io.opentelemetry.context.Context;
913
import io.opentelemetry.sdk.common.CompletableResultCode;
1014
import io.opentelemetry.sdk.trace.ReadWriteSpan;
1115
import io.opentelemetry.sdk.trace.ReadableSpan;
1216
import io.opentelemetry.sdk.trace.SpanProcessor;
13-
import io.opentelemetry.semconv.incubating.ThreadIncubatingAttributes;
1417

1518
public class AddThreadDetailsSpanProcessor implements SpanProcessor {
1619

20+
// attributes are not stable yet
21+
public static final AttributeKey<Long> THREAD_ID = longKey("thread.id");
22+
public static final AttributeKey<String> THREAD_NAME = stringKey("thread.name");
23+
24+
1725
@Override
1826
public void onStart(Context context, ReadWriteSpan span) {
1927
Thread currentThread = Thread.currentThread();
20-
span.setAttribute(ThreadIncubatingAttributes.THREAD_ID, currentThread.getId());
21-
span.setAttribute(ThreadIncubatingAttributes.THREAD_NAME, currentThread.getName());
28+
span.setAttribute(THREAD_ID, currentThread.getId());
29+
span.setAttribute(THREAD_NAME, currentThread.getName());
2230
}
2331

2432
@Override

sdk-autoconfigure-support/src/test/java/io/opentelemetry/instrumentation/tracer/AddThreadDetailsSpanProcessorTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@
1818

1919
class AddThreadDetailsSpanProcessorTest {
2020

21-
private ReadWriteSpan span = mock(ReadWriteSpan.class);
21+
private final ReadWriteSpan span = mock(ReadWriteSpan.class);
2222

23-
private SpanProcessor spanProcessor = new AddThreadDetailsSpanProcessor();
23+
private final SpanProcessor spanProcessor = new AddThreadDetailsSpanProcessor();
2424

2525
@Test
2626
void onStart() {

0 commit comments

Comments
 (0)