@@ -97,6 +97,8 @@ void tearDown() {
9797 // F1.1: HTTP no traces emitted unless enabled.
9898 @ Test
9999 void testTracingDisabled_httpjson () throws Exception {
100+ // Verifies that when OpenTelemetry tracing is not configured on the client settings,
101+ // no spans are recorded for HTTP/JSON calls.
100102 EchoSettings settings = createEchoSettings (true );
101103 try (EchoClient client = EchoClient .create (settings )) {
102104 client .echo (EchoRequest .newBuilder ().setContent ("test-f1-1" ).build ());
@@ -108,6 +110,10 @@ void testTracingDisabled_httpjson() throws Exception {
108110 // F1.2: HTTP T3 success case name and attributes conform to requirements.
109111 @ Test
110112 void testT3Success_httpjson () throws Exception {
113+ // Verifies that a successful HTTP/JSON call produces a T3 INTERNAL span with proper
114+ // semantic convention attributes (http rpc.system, server.address, server.port, 200
115+ // http.response.status_code,
116+ // url.template) and UNSET status.
111117 OpenTelemetryTracingFactory tracingFactory = new OpenTelemetryTracingFactory (openTelemetrySdk );
112118 EchoSettings settings = createEchoSettings (true );
113119 EchoStub stub = createStubWithServiceName (settings , tracingFactory );
@@ -170,6 +176,8 @@ void testT3Success_httpjson() throws Exception {
170176 // F1.3: HTTP T3 server failures case name and attributes conform to requirements.
171177 @ Test
172178 void testT3ServerFailure_httpjson () throws Exception {
179+ // Verifies that a server-side error on HTTP/JSON produces a T3 INTERNAL span with ERROR status,
180+ // 400 http.response.status_code, and error.type.
173181 OpenTelemetryTracingFactory tracingFactory = new OpenTelemetryTracingFactory (openTelemetrySdk );
174182 EchoSettings settings = createEchoSettings (true );
175183 EchoStub stub = createStubWithServiceName (settings , tracingFactory );
@@ -218,6 +226,9 @@ void testT3ServerFailure_httpjson() throws Exception {
218226 // F1.4: HTTP T3 client failures case name and attributes conform to requirements.
219227 @ Test
220228 void testT3ClientFailure_httpjson () throws Exception {
229+ // Verifies that a client-side timeout on HTTP/JSON produces a T3 INTERNAL span with ERROR
230+ // status,
231+ // 504 http.response.status_code, and error.type.
221232 OpenTelemetryTracingFactory tracingFactory = new OpenTelemetryTracingFactory (openTelemetrySdk );
222233 EchoSettings settings = createEchoSettings (true );
223234 // Configure 1000ms timeout for blockCallable
@@ -269,6 +280,8 @@ void testT3ClientFailure_httpjson() throws Exception {
269280 // F1.5: gRPC no traces emitted unless enabled.
270281 @ Test
271282 void testTracingDisabled_grpc () throws Exception {
283+ // Verifies that when OpenTelemetry tracing is not configured on the client settings,
284+ // no spans are recorded for gRPC calls.
272285 EchoSettings settings = createEchoSettings (false );
273286 try (EchoClient client = EchoClient .create (settings )) {
274287 client .echo (EchoRequest .newBuilder ().setContent ("test-f1-5" ).build ());
@@ -280,6 +293,10 @@ void testTracingDisabled_grpc() throws Exception {
280293 // F1.6: gRPC T3 success case name and attributes conform to requirements.
281294 @ Test
282295 void testT3Success_grpc () throws Exception {
296+ // Verifies that a successful gRPC call produces a T3 INTERNAL span with proper
297+ // semantic convention attributes (grpc rpc.system, server.address, server.port, OK
298+ // rpc.response.status_code)
299+ // and UNSET status.
283300 OpenTelemetryTracingFactory tracingFactory = new OpenTelemetryTracingFactory (openTelemetrySdk );
284301 EchoSettings settings = createEchoSettings (false );
285302 EchoStub stub = createStubWithServiceName (settings , tracingFactory );
@@ -338,6 +355,8 @@ void testT3Success_grpc() throws Exception {
338355 // F1.7: gRPC T3 server failures case name and attributes conform to requirements.
339356 @ Test
340357 void testT3ServerFailure_grpc () throws Exception {
358+ // Verifies that a server-side error on gRPC produces a T3 INTERNAL span with ERROR status,
359+ // INVALID_ARGUMENT rpc.response.status_code, and error.type.
341360 OpenTelemetryTracingFactory tracingFactory = new OpenTelemetryTracingFactory (openTelemetrySdk );
342361 EchoSettings settings = createEchoSettings (false );
343362 EchoStub stub = createStubWithServiceName (settings , tracingFactory );
@@ -387,6 +406,8 @@ void testT3ServerFailure_grpc() throws Exception {
387406 // F1.8: gRPC T3 client failures case name and attributes conform to requirements.
388407 @ Test
389408 void testT3ClientFailure_grpc () throws Exception {
409+ // Verifies that a client-side timeout on gRPC produces a T3 INTERNAL span with ERROR status,
410+ // DEADLINE_EXCEEDED rpc.response.status_code, and error.type.
390411 OpenTelemetryTracingFactory tracingFactory = new OpenTelemetryTracingFactory (openTelemetrySdk );
391412 EchoSettings settings = createEchoSettings (false );
392413 // Configure 1000ms timeout for blockCallable
@@ -435,13 +456,26 @@ void testT3ClientFailure_grpc() throws Exception {
435456 }
436457 }
437458
459+ /**
460+ * Waits until the in-memory span exporter records at least {@code minSpans} completed spans.
461+ *
462+ * @param minSpans the minimum number of spans expected
463+ * @return the list of completed {@link SpanData} items
464+ */
438465 private List <SpanData > waitAndCollectSpans (int minSpans ) {
439466 Awaitility .await ()
440467 .atMost (Duration .ofSeconds (5 ))
441468 .until (() -> spanExporter .getFinishedSpanItems ().size () >= minSpans );
442469 return spanExporter .getFinishedSpanItems ();
443470 }
444471
472+ /**
473+ * Constructs {@link EchoSettings} configured for the local Showcase test server.
474+ *
475+ * @param isHttpJson {@code true} for HTTP/JSON transport; {@code false} for gRPC transport
476+ * @return the configured {@link EchoSettings}
477+ * @throws Exception if transport provider initialization fails
478+ */
445479 private EchoSettings createEchoSettings (boolean isHttpJson ) throws Exception {
446480 if (isHttpJson ) {
447481 return EchoSettings .newHttpJsonBuilder ()
@@ -464,6 +498,14 @@ private EchoSettings createEchoSettings(boolean isHttpJson) throws Exception {
464498 }
465499 }
466500
501+ /**
502+ * Instantiates an {@link EchoStub} with custom service name and tracer factory.
503+ *
504+ * @param settings the client settings to base the stub on
505+ * @param tracingFactory the tracer factory to register with the stub
506+ * @return the initialized {@link EchoStub}
507+ * @throws IOException if stub creation fails
508+ */
467509 private EchoStub createStubWithServiceName (
468510 EchoSettings settings , OpenTelemetryTracingFactory tracingFactory ) throws IOException {
469511 EchoStubSettings .Builder builder =
@@ -472,7 +514,14 @@ private EchoStub createStubWithServiceName(
472514 return new ExtendedEchoStubSettings (builder ).createStub ();
473515 }
474516
517+ /** Extended {@link EchoStubSettings} that overrides {@link #getServiceName()} for testing. */
475518 private static class ExtendedEchoStubSettings extends EchoStubSettings {
519+ /**
520+ * Constructs settings wrapping the specified builder.
521+ *
522+ * @param builder the settings builder
523+ * @throws IOException if base settings construction fails
524+ */
476525 protected ExtendedEchoStubSettings (EchoStubSettings .Builder builder ) throws IOException {
477526 super (builder );
478527 }
0 commit comments