28
28
import io .grpc .ServerBuilder ;
29
29
import io .grpc .Status ;
30
30
import io .grpc .stub .StreamObserver ;
31
+ import io .opentelemetry .api .common .AttributeKey ;
31
32
import io .opentelemetry .api .trace .Span ;
32
33
import io .opentelemetry .api .trace .SpanKind ;
33
34
import io .opentelemetry .api .trace .Tracer ;
52
53
53
54
public abstract class AbstractGrpcStreamingTest {
54
55
56
+ private static final AttributeKey <Long > RPC_CLIENT_REQUEST_BODY_SIZE =
57
+ AttributeKey .longKey ("rpc.client.request.body.size" );
58
+ private static final AttributeKey <Long > RPC_CLIENT_RESPONSE_BODY_SIZE =
59
+ AttributeKey .longKey ("rpc.client.response.body.size" );
60
+ private static final AttributeKey <Long > RPC_SERVER_REQUEST_BODY_SIZE =
61
+ AttributeKey .longKey ("rpc.server.request.body.size" );
62
+ private static final AttributeKey <Long > RPC_SERVER_RESPONSE_BODY_SIZE =
63
+ AttributeKey .longKey ("rpc.server.response.body.size" );
64
+
55
65
protected abstract ServerBuilder <?> configureServer (ServerBuilder <?> server );
56
66
57
67
protected abstract ManagedChannelBuilder <?> configureClient (ManagedChannelBuilder <?> client );
@@ -159,6 +169,9 @@ public void onCompleted() {
159
169
.sorted ()
160
170
.collect (Collectors .toList ()));
161
171
172
+ Helloworld .Response message = Helloworld .Response .newBuilder ().setMessage ("call " + 1 ).build ();
173
+ int requestSerializedSize = message .getSerializedSize ();
174
+
162
175
List <Consumer <EventData >> clientEvents = new ArrayList <>();
163
176
List <Consumer <EventData >> serverEvents = new ArrayList <>();
164
177
for (long i = 0 ; i < clientMessageCount ; i ++) {
@@ -229,6 +242,8 @@ public void onCompleted() {
229
242
equalTo (RPC_GRPC_STATUS_CODE , (long ) Status .Code .OK .value ()),
230
243
equalTo (SERVER_ADDRESS , "localhost" ),
231
244
equalTo (SERVER_PORT , (long ) server .getPort ())))
245
+ equalTo (RPC_CLIENT_RESPONSE_BODY_SIZE , requestSerializedSize ),
246
+ equalTo (RPC_CLIENT_REQUEST_BODY_SIZE , requestSerializedSize ),
232
247
.satisfies (
233
248
spanData ->
234
249
assertThat (spanData .getEvents ())
@@ -246,6 +261,8 @@ public void onCompleted() {
246
261
equalTo (SERVER_PORT , server .getPort ()),
247
262
equalTo (NETWORK_TYPE , "ipv4" ),
248
263
equalTo (NETWORK_PEER_ADDRESS , "127.0.0.1" ),
264
+ equalTo (RPC_SERVER_REQUEST_BODY_SIZE , requestSerializedSize ),
265
+ equalTo (RPC_SERVER_RESPONSE_BODY_SIZE , requestSerializedSize ),
249
266
satisfies (NETWORK_PEER_PORT , val -> assertThat (val ).isNotNull ()))
250
267
.satisfies (
251
268
spanData ->
0 commit comments