Skip to content

Commit ae3f6ac

Browse files
authored
Implementing ExtendedTextMapGetter in grpc-1.6 instrumentation (#13011)
Signed-off-by: xiepuhuan <[email protected]>
1 parent 324fdbd commit ae3f6ac

File tree

1 file changed

+20
-2
lines changed
  • instrumentation/grpc-1.6/library/src/main/java/io/opentelemetry/instrumentation/grpc/v1_6

1 file changed

+20
-2
lines changed

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

+20-2
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,14 @@
55

66
package io.opentelemetry.instrumentation.grpc.v1_6;
77

8+
import static java.util.Collections.emptyIterator;
9+
810
import io.grpc.Metadata;
9-
import io.opentelemetry.context.propagation.TextMapGetter;
11+
import io.opentelemetry.context.propagation.internal.ExtendedTextMapGetter;
12+
import java.util.Iterator;
1013
import javax.annotation.Nullable;
1114

12-
enum GrpcRequestGetter implements TextMapGetter<GrpcRequest> {
15+
enum GrpcRequestGetter implements ExtendedTextMapGetter<GrpcRequest> {
1316
INSTANCE;
1417

1518
@Override
@@ -25,4 +28,19 @@ public String get(@Nullable GrpcRequest request, String key) {
2528
}
2629
return request.getMetadata().get(Metadata.Key.of(key, Metadata.ASCII_STRING_MARSHALLER));
2730
}
31+
32+
@Override
33+
public Iterator<String> getAll(@Nullable GrpcRequest request, String key) {
34+
if (request == null) {
35+
return emptyIterator();
36+
}
37+
38+
Iterable<String> values =
39+
request.getMetadata().getAll(Metadata.Key.of(key, Metadata.ASCII_STRING_MARSHALLER));
40+
41+
if (values == null) {
42+
return emptyIterator();
43+
}
44+
return values.iterator();
45+
}
2846
}

0 commit comments

Comments
 (0)