Use new SemanticAttribute constants (#1896)
* Use new SemanticAttribute constants * Spotless
This commit is contained in:
parent
8bcd5f1229
commit
0200081007
|
@ -5,7 +5,7 @@
|
|||
|
||||
package io.opentelemetry.javaagent.tooling;
|
||||
|
||||
import io.opentelemetry.api.common.AttributeKey;
|
||||
import io.opentelemetry.api.trace.attributes.SemanticAttributes;
|
||||
import io.opentelemetry.context.Context;
|
||||
import io.opentelemetry.sdk.common.CompletableResultCode;
|
||||
import io.opentelemetry.sdk.trace.ReadWriteSpan;
|
||||
|
@ -14,15 +14,11 @@ import io.opentelemetry.sdk.trace.SpanProcessor;
|
|||
|
||||
public class AddThreadDetailsSpanProcessor implements SpanProcessor {
|
||||
|
||||
// TODO(anuraaga): Restore these in SemanticAttributes
|
||||
static final AttributeKey<Long> THREAD_ID = AttributeKey.longKey("thread.id");
|
||||
static final AttributeKey<String> THREAD_NAME = AttributeKey.stringKey("thread.name");
|
||||
|
||||
@Override
|
||||
public void onStart(Context context, ReadWriteSpan span) {
|
||||
Thread currentThread = Thread.currentThread();
|
||||
span.setAttribute(THREAD_ID, currentThread.getId());
|
||||
span.setAttribute(THREAD_NAME, currentThread.getName());
|
||||
span.setAttribute(SemanticAttributes.THREAD_ID, currentThread.getId());
|
||||
span.setAttribute(SemanticAttributes.THREAD_NAME, currentThread.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
|
||||
package io.opentelemetry.javaagent.tooling
|
||||
|
||||
import io.opentelemetry.api.trace.attributes.SemanticAttributes
|
||||
import io.opentelemetry.context.Context
|
||||
import io.opentelemetry.sdk.trace.ReadWriteSpan
|
||||
import spock.lang.Specification
|
||||
|
@ -28,7 +29,7 @@ class AddThreadDetailsSpanProcessorTest extends Specification {
|
|||
processor.onStart(Context.root(), span)
|
||||
|
||||
then:
|
||||
1 * span.setAttribute(AddThreadDetailsSpanProcessor.THREAD_ID, currentThreadId)
|
||||
1 * span.setAttribute(AddThreadDetailsSpanProcessor.THREAD_NAME, currentThreadName)
|
||||
1 * span.setAttribute(SemanticAttributes.THREAD_ID, currentThreadId)
|
||||
1 * span.setAttribute(SemanticAttributes.THREAD_NAME, currentThreadName)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue