@@ -29,6 +29,7 @@ PROJECT_NAME="$(basename "$P_DIR")"
2929GO_SERVER_LOG=" /tmp/.${PROJECT_NAME} .go-server.log"
3030JAVA_SERVER_LOG=" /tmp/.${PROJECT_NAME} .java-server.log"
3131PID_FILE=" /tmp/.${PROJECT_NAME} .pid"
32+ GO_CLIENT_BIN=" "
3233GO_CLIENT_TIMEOUT_SECONDS=" ${GO_CLIENT_TIMEOUT_SECONDS:- 90} "
3334JAVA_SERVER_READY_TIMEOUT_SECONDS=" ${JAVA_SERVER_READY_TIMEOUT_SECONDS:- 60} "
3435JAVA_SERVER_HOST=" ${JAVA_SERVER_HOST:- 127.0.0.1} "
@@ -47,6 +48,7 @@ GO_AUX_PIDS=()
4748SAMPLE_COMPOSE_FILE=" "
4849SAMPLE_COMPOSE_SERVICES=()
4950DOCKER_COMPOSE_CMD=()
51+ OBSERVABILITY_SEMANTICS_VERIFIED=false
5052
5153if [ " $SAMPLE " = " observability/integration" ]; then
5254 SAMPLE_COMPOSE_FILE=" $P_DIR /docker-compose.yaml"
@@ -89,6 +91,9 @@ cleanup() {
8991 if [ -n " $SAMPLE_COMPOSE_FILE " ]; then
9092 wait_for_tcp_port_closed " 127.0.0.1" " 4318" 30 || true
9193 fi
94+ if [ -n " $GO_CLIENT_BIN " ]; then
95+ rm -f " $GO_CLIENT_BIN "
96+ fi
9297 run_make_target stop > /dev/null 2>&1 || true
9398}
9499trap cleanup EXIT
@@ -150,10 +155,14 @@ verify_observability_semantics() {
150155 return 0
151156 fi
152157
158+ local client_pid=" ${1:- } "
159+
153160 echo " Verifying observability telemetry semantics before teardown..."
154- if ! python3 << 'PY '
161+ if ! python3 - " ${client_pid :- } " << 'PY '
155162import base64
156163import json
164+ import os
165+ import sys
157166import time
158167import urllib.request
159168
@@ -233,6 +242,12 @@ pending = checks
233242last_errors = {}
234243deadline = time.monotonic() + 90
235244while pending and time.monotonic() < deadline:
245+ if sys.argv[1]:
246+ try:
247+ os.kill(int(sys.argv[1]), 0)
248+ except OSError:
249+ print("observability client exited before semantic verification completed")
250+ raise SystemExit(1)
236251 next_pending = []
237252 for check, description in pending:
238253 try:
@@ -433,19 +448,44 @@ run_go_client() {
433448 fi
434449
435450 local client_conf
451+ local client_args=()
436452 client_conf=" $( resolve_config_path " go-client" || true) "
437453
454+ if [ " $SAMPLE " = " observability/integration" ]; then
455+ # Keep the client alive while the semantic checks poll its metrics target.
456+ # The test stops it only after Prometheus, Jaeger, and Grafana are verified.
457+ client_args=(-requests 0 -interval 500ms)
458+ GO_CLIENT_BIN=" /tmp/.${PROJECT_NAME} .go-client.bin"
459+ fi
460+
438461 echo " Running Go client..."
439462 (
440463 cd " $P_DIR "
441464 if [ -n " $client_conf " ]; then
442465 export DUBBO_GO_CONFIG_PATH=" $client_conf "
443466 fi
444- go run ./go-client/cmd/* .go
467+ if [ " $SAMPLE " = " observability/integration" ]; then
468+ go build -o " $GO_CLIENT_BIN " ./go-client/cmd
469+ exec " $GO_CLIENT_BIN " " ${client_args[@]} "
470+ fi
471+ go run ./go-client/cmd/* .go " ${client_args[@]} "
445472 ) &
446473 local go_client_pid=$!
447474 local elapsed=0
448475
476+ if [ " $SAMPLE " = " observability/integration" ]; then
477+ if ! verify_observability_semantics " $go_client_pid " ; then
478+ echo " Observability telemetry semantic verification failed for: $SAMPLE "
479+ kill_if_running " $go_client_pid "
480+ wait " $go_client_pid " 2> /dev/null || true
481+ return 1
482+ fi
483+ kill_if_running " $go_client_pid "
484+ wait " $go_client_pid " 2> /dev/null || true
485+ OBSERVABILITY_SEMANTICS_VERIFIED=true
486+ return 0
487+ fi
488+
449489 while kill -0 " $go_client_pid " 2> /dev/null; do
450490 if [ " $elapsed " -ge " $GO_CLIENT_TIMEOUT_SECONDS " ]; then
451491 echo " Go client timed out after ${GO_CLIENT_TIMEOUT_SECONDS} s: $SAMPLE "
@@ -705,18 +745,13 @@ main() {
705745 start_sample_dependencies
706746 start_aux_go_servers
707747
708- if [ " $SAMPLE " = " observability/integration" ]; then
709- if ! run_go_client; then
710- echo " Observability integration client validation failed for: $SAMPLE "
711- return 1
712- fi
713- else
714- run_go_client
715- fi
748+ run_go_client
716749 run_java_client_if_present
717750
718- if ! verify_observability_semantics; then
719- return 1
751+ if [ " $OBSERVABILITY_SEMANTICS_VERIFIED " != " true" ]; then
752+ if ! verify_observability_semantics; then
753+ return 1
754+ fi
720755 fi
721756
722757 if [ -n " $SAMPLE_COMPOSE_FILE " ]; then
0 commit comments