Skip to content

Commit 432dc54

Browse files
authored
Use constants from semconv (#9626)
1 parent 4add634 commit 432dc54

File tree

3 files changed

+14
-29
lines changed

3 files changed

+14
-29
lines changed

instrumentation/grpc-1.6/library/src/main/java/io/opentelemetry/instrumentation/grpc/v1_6/GrpcHelper.java

Lines changed: 0 additions & 16 deletions
This file was deleted.

instrumentation/grpc-1.6/library/src/main/java/io/opentelemetry/instrumentation/grpc/v1_6/TracingClientInterceptor.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import io.opentelemetry.context.Scope;
2222
import io.opentelemetry.context.propagation.ContextPropagators;
2323
import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter;
24+
import io.opentelemetry.semconv.SemanticAttributes;
2425
import java.util.concurrent.atomic.AtomicLongFieldUpdater;
2526

2627
final class TracingClientInterceptor implements ClientInterceptor {
@@ -110,9 +111,9 @@ public void sendMessage(REQUEST message) {
110111
Span span = Span.fromContext(context);
111112
Attributes attributes =
112113
Attributes.of(
113-
GrpcHelper.MESSAGE_TYPE,
114-
"SENT",
115-
GrpcHelper.MESSAGE_ID,
114+
SemanticAttributes.MESSAGE_TYPE,
115+
SemanticAttributes.MessageTypeValues.SENT,
116+
SemanticAttributes.MESSAGE_ID,
116117
MESSAGE_ID_UPDATER.incrementAndGet(this));
117118
span.addEvent("message", attributes);
118119
}
@@ -140,9 +141,9 @@ public void onMessage(RESPONSE message) {
140141
Span span = Span.fromContext(context);
141142
Attributes attributes =
142143
Attributes.of(
143-
GrpcHelper.MESSAGE_TYPE,
144-
"RECEIVED",
145-
GrpcHelper.MESSAGE_ID,
144+
SemanticAttributes.MESSAGE_TYPE,
145+
SemanticAttributes.MessageTypeValues.RECEIVED,
146+
SemanticAttributes.MESSAGE_ID,
146147
MESSAGE_ID_UPDATER.incrementAndGet(TracingClientCall.this));
147148
span.addEvent("message", attributes);
148149
try (Scope ignored = context.makeCurrent()) {

instrumentation/grpc-1.6/library/src/main/java/io/opentelemetry/instrumentation/grpc/v1_6/TracingServerInterceptor.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import io.opentelemetry.context.Context;
2020
import io.opentelemetry.context.Scope;
2121
import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter;
22+
import io.opentelemetry.semconv.SemanticAttributes;
2223
import java.util.concurrent.atomic.AtomicLongFieldUpdater;
2324

2425
final class TracingServerInterceptor implements ServerInterceptor {
@@ -91,9 +92,9 @@ public void sendMessage(RESPONSE message) {
9192
Span span = Span.fromContext(context);
9293
Attributes attributes =
9394
Attributes.of(
94-
GrpcHelper.MESSAGE_TYPE,
95-
"SENT",
96-
GrpcHelper.MESSAGE_ID,
95+
SemanticAttributes.MESSAGE_TYPE,
96+
SemanticAttributes.MessageTypeValues.SENT,
97+
SemanticAttributes.MESSAGE_ID,
9798
MESSAGE_ID_UPDATER.incrementAndGet(this));
9899
span.addEvent("message", attributes);
99100
}
@@ -122,12 +123,11 @@ final class TracingServerCallListener
122123

123124
@Override
124125
public void onMessage(REQUEST message) {
125-
// TODO(anuraaga): Restore
126126
Attributes attributes =
127127
Attributes.of(
128-
GrpcHelper.MESSAGE_TYPE,
129-
"RECEIVED",
130-
GrpcHelper.MESSAGE_ID,
128+
SemanticAttributes.MESSAGE_TYPE,
129+
SemanticAttributes.MessageTypeValues.RECEIVED,
130+
SemanticAttributes.MESSAGE_ID,
131131
MESSAGE_ID_UPDATER.incrementAndGet(TracingServerCall.this));
132132
Span.fromContext(context).addEvent("message", attributes);
133133
delegate().onMessage(message);

0 commit comments

Comments
 (0)