Use new SemanticAttribute constants (#1896)

* Use new SemanticAttribute constants

* Spotless
This commit is contained in:
Trask Stalnaker 2020-12-14 01:16:33 -08:00 committed by GitHub
parent 8bcd5f1229
commit 0200081007
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 9 deletions

View File

@ -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

View File

@ -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)
}
}