3535
3636import com .google .api .client .http .HttpTransport ;
3737import com .google .api .gax .core .NoCredentialsProvider ;
38+ import com .google .api .gax .rpc .StatusCode ;
3839import com .google .api .gax .rpc .TransportChannelProvider ;
3940import com .google .api .gax .rpc .UnavailableException ;
4041import com .google .api .gax .tracing .GoldenSignalsMetricsTracerFactory ;
4142import com .google .api .gax .tracing .ObservabilityAttributes ;
4243import com .google .common .collect .ImmutableList ;
44+ import com .google .rpc .Status ;
4345import com .google .showcase .v1beta1 .EchoClient ;
4446import com .google .showcase .v1beta1 .EchoRequest ;
47+ import com .google .showcase .v1beta1 .EchoResponse ;
4548import com .google .showcase .v1beta1 .EchoSettings ;
4649import com .google .showcase .v1beta1 .it .util .TestClientInitializer ;
4750import com .google .showcase .v1beta1 .stub .EchoStubSettings ;
4851import io .grpc .CallOptions ;
4952import io .grpc .Channel ;
5053import io .grpc .ClientCall ;
5154import io .grpc .ClientInterceptor ;
52- import io .grpc .Metadata ;
5355import io .grpc .MethodDescriptor ;
56+ import io .grpc .Metadata ;
5457import io .opentelemetry .api .common .AttributeKey ;
5558import io .opentelemetry .sdk .OpenTelemetrySdk ;
5659import io .opentelemetry .sdk .metrics .SdkMeterProvider ;
@@ -100,8 +103,7 @@ void testMetrics_successfulEcho_grpc() throws Exception {
100103
101104 // The end of an operation is tracked in a separate thread.
102105 // Add a small sleep to make sure the tracking is completed.
103- // This is implemented by adding a TraceFinisher to ApiFuture as a callback in
104- // TracedUnaryCallable,
106+ // This is implemented by adding a TraceFinisher to ApiFuture as a callback in TracedUnaryCallable,
105107 // which could be executed in a different thread.
106108 Thread .sleep (100 );
107109 Collection <MetricData > metrics = metricReader .collectAllMetrics ();
@@ -120,27 +122,22 @@ void testMetrics_successfulEcho_grpc() throws Exception {
120122 durationMetric .getHistogramData ().getPoints ().iterator ().next ().getAttributes ();
121123
122124 assertThat (
123- attributes .get (
124- AttributeKey .stringKey (ObservabilityAttributes .SERVER_ADDRESS_ATTRIBUTE )))
125+ attributes .get (AttributeKey .stringKey (ObservabilityAttributes .SERVER_ADDRESS_ATTRIBUTE )))
125126 .isEqualTo (SHOWCASE_SERVER_ADDRESS );
126127 assertThat (
127128 attributes .get (AttributeKey .longKey (ObservabilityAttributes .SERVER_PORT_ATTRIBUTE )))
128129 .isEqualTo (SHOWCASE_SERVER_PORT );
129130 assertThat (
130- attributes .get (
131- AttributeKey .stringKey (ObservabilityAttributes .RPC_SYSTEM_NAME_ATTRIBUTE )))
131+ attributes .get (AttributeKey .stringKey (ObservabilityAttributes .RPC_SYSTEM_NAME_ATTRIBUTE )))
132132 .isEqualTo ("grpc" );
133133 assertThat (
134- attributes .get (
135- AttributeKey .stringKey (ObservabilityAttributes .GCP_CLIENT_SERVICE_ATTRIBUTE )))
134+ attributes .get (AttributeKey .stringKey (ObservabilityAttributes .GCP_CLIENT_SERVICE_ATTRIBUTE )))
136135 .isEqualTo ("showcase" );
137136 assertThat (
138- attributes .get (
139- AttributeKey .stringKey (ObservabilityAttributes .GRPC_RPC_METHOD_ATTRIBUTE )))
137+ attributes .get (AttributeKey .stringKey (ObservabilityAttributes .GRPC_RPC_METHOD_ATTRIBUTE )))
140138 .isEqualTo ("google.showcase.v1beta1.Echo/Echo" );
141139 assertThat (
142- attributes .get (
143- AttributeKey .stringKey (ObservabilityAttributes .RPC_RESPONSE_STATUS_ATTRIBUTE )))
140+ attributes .get (AttributeKey .stringKey (ObservabilityAttributes .RPC_RESPONSE_STATUS_ATTRIBUTE )))
144141 .isEqualTo ("OK" );
145142 }
146143 }
@@ -204,8 +201,7 @@ public void sendMessage(ReqT message) {}
204201 durationMetric .getHistogramData ().getPoints ().iterator ().next ().getAttributes ();
205202
206203 assertThat (
207- attributes .get (
208- AttributeKey .stringKey (ObservabilityAttributes .RPC_RESPONSE_STATUS_ATTRIBUTE )))
204+ attributes .get (AttributeKey .stringKey (ObservabilityAttributes .RPC_RESPONSE_STATUS_ATTRIBUTE )))
209205 .isEqualTo ("UNAVAILABLE" );
210206 assertThat (
211207 attributes .get (AttributeKey .stringKey (ObservabilityAttributes .ERROR_TYPE_ATTRIBUTE )))
@@ -240,36 +236,29 @@ void testMetrics_successfulEcho_httpjson() throws Exception {
240236 durationMetric .getHistogramData ().getPoints ().iterator ().next ().getAttributes ();
241237
242238 assertThat (
243- attributes .get (
244- AttributeKey .stringKey (ObservabilityAttributes .SERVER_ADDRESS_ATTRIBUTE )))
239+ attributes .get (AttributeKey .stringKey (ObservabilityAttributes .SERVER_ADDRESS_ATTRIBUTE )))
245240 .isEqualTo (SHOWCASE_SERVER_ADDRESS );
246241 assertThat (
247242 attributes .get (AttributeKey .longKey (ObservabilityAttributes .SERVER_PORT_ATTRIBUTE )))
248243 .isEqualTo (SHOWCASE_SERVER_PORT );
249244 assertThat (
250- attributes .get (
251- AttributeKey .stringKey (ObservabilityAttributes .RPC_SYSTEM_NAME_ATTRIBUTE )))
245+ attributes .get (AttributeKey .stringKey (ObservabilityAttributes .RPC_SYSTEM_NAME_ATTRIBUTE )))
252246 .isEqualTo ("http" );
253247 assertThat (
254- attributes .get (
255- AttributeKey .stringKey (ObservabilityAttributes .GCP_CLIENT_SERVICE_ATTRIBUTE )))
248+ attributes .get (AttributeKey .stringKey (ObservabilityAttributes .GCP_CLIENT_SERVICE_ATTRIBUTE )))
256249 .isEqualTo ("showcase" );
257250 assertThat (
258- attributes .get (
259- AttributeKey .stringKey (ObservabilityAttributes .RPC_RESPONSE_STATUS_ATTRIBUTE )))
251+ attributes .get (AttributeKey .stringKey (ObservabilityAttributes .RPC_RESPONSE_STATUS_ATTRIBUTE )))
260252 .isEqualTo ("OK" );
261253 assertThat (
262- attributes .get (
263- AttributeKey .longKey (ObservabilityAttributes .HTTP_RESPONSE_STATUS_ATTRIBUTE )))
254+ attributes .get (AttributeKey .longKey (ObservabilityAttributes .HTTP_RESPONSE_STATUS_ATTRIBUTE )))
264255 .isEqualTo (200L );
265256 assertThat (
266- attributes .get (
267- AttributeKey .stringKey (ObservabilityAttributes .URL_TEMPLATE_ATTRIBUTE )))
257+ attributes .get (AttributeKey .stringKey (ObservabilityAttributes .URL_TEMPLATE_ATTRIBUTE )))
268258 .isEqualTo ("v1beta1/echo:echo" );
269259 assertThat (
270- attributes .get (
271- AttributeKey .stringKey (ObservabilityAttributes .GRPC_RPC_METHOD_ATTRIBUTE )))
272- .isEqualTo ("google.showcase.v1beta1.Echo/Echo" );
260+ attributes .get (AttributeKey .stringKey (ObservabilityAttributes .GRPC_RPC_METHOD_ATTRIBUTE )))
261+ .isEqualTo ("google.showcase.v1beta1.Echo/Echo" );
273262 }
274263 }
275264
@@ -380,12 +369,10 @@ public String getHeaderValue(int index) {
380369 durationMetric .getHistogramData ().getPoints ().iterator ().next ().getAttributes ();
381370
382371 assertThat (
383- attributes .get (
384- AttributeKey .stringKey (ObservabilityAttributes .RPC_RESPONSE_STATUS_ATTRIBUTE )))
372+ attributes .get (AttributeKey .stringKey (ObservabilityAttributes .RPC_RESPONSE_STATUS_ATTRIBUTE )))
385373 .isEqualTo ("UNAVAILABLE" );
386374 assertThat (
387- attributes .get (
388- AttributeKey .longKey (ObservabilityAttributes .HTTP_RESPONSE_STATUS_ATTRIBUTE )))
375+ attributes .get (AttributeKey .longKey (ObservabilityAttributes .HTTP_RESPONSE_STATUS_ATTRIBUTE )))
389376 .isEqualTo (503L );
390377 assertThat (
391378 attributes .get (AttributeKey .stringKey (ObservabilityAttributes .ERROR_TYPE_ATTRIBUTE )))
0 commit comments