Skip to content

Commit 58a26b5

Browse files
authored
Observability scripts (#80)
* Add --observability option * Add --help to show available options * Update README.md
1 parent 05f3000 commit 58a26b5

File tree

9 files changed

+142
-10
lines changed

9 files changed

+142
-10
lines changed

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -514,6 +514,24 @@ cd scripts/java && shell.cmd --docker-tools # Advanced Docker integration
514514

515515
Uses Maven profile: `enable-shell-mcp-client`
516516

517+
### **With Observability (Zipkin Tracing)**
518+
519+
Enable distributed tracing with Zipkin by adding the `--observability` flag:
520+
521+
```bash
522+
cd scripts/kotlin && ./shell.sh --observability # Enable observability
523+
cd scripts/kotlin && shell.cmd --observability # Enable observability (Windows)
524+
# or
525+
cd scripts/java && ./shell.sh --observability # Enable observability
526+
cd scripts/java && shell.cmd --observability # Enable observability (Windows)
527+
```
528+
529+
Make sure to run `docker compose up` in the project root to start Zipkin trace collector:
530+
531+
```bash
532+
docker compose up
533+
```
534+
517535
### **MCP Server Mode**
518536

519537
```bash

scripts/java/shell.cmd

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,29 @@
11
@echo off
22
setlocal
33

4+
REM Check for help flag
5+
if "%~1"=="--help" goto show_help
6+
if "%~1"=="-h" goto show_help
7+
48
set AGENT_APPLICATION=..\..\examples-java
59

610
call ..\support\shell_template.bat %*
711

8-
endlocal
12+
endlocal
13+
exit /b 0
14+
15+
:show_help
16+
echo.
17+
echo Java Agent Shell - Available Options:
18+
echo.
19+
echo --help, -h Show this help message
20+
echo --observability Enable observability features (Zipkin tracing)
21+
echo --no-docker-tools Disable Docker tool integration (basic features only)
22+
echo.
23+
echo Examples:
24+
echo shell.cmd
25+
echo shell.cmd --observability
26+
echo shell.cmd --observability --no-docker-tools
27+
echo.
28+
exit /b 0
29+
endlocal

scripts/java/shell.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,22 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
66
# Set the path relative to this script's directory
77
export AGENT_APPLICATION="$SCRIPT_DIR/../../examples-java"
88

9+
# Check for help flag
10+
if [[ "$1" == "--help" || "$1" == "-h" ]]; then
11+
echo
12+
echo "Java Agent Shell - Available Options:"
13+
echo
14+
echo " --help, -h Show this help message"
15+
echo " --observability Enable observability features (Zipkin tracing)"
16+
echo " --no-docker-tools Disable Docker tool integration (basic features only)"
17+
echo
18+
echo "Examples:"
19+
echo " ./shell.sh"
20+
echo " ./shell.sh --observability"
21+
echo " ./shell.sh --observability --no-docker-tools"
22+
echo
23+
exit 0
24+
fi
25+
926
# Call the shell_template.sh relative to this script's location
1027
"$SCRIPT_DIR/../support/shell_template.sh" "$@"

scripts/kotlin/shell.cmd

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,29 @@
11
@echo off
22
setlocal
33

4+
REM Check for help flag
5+
if "%~1"=="--help" goto show_help
6+
if "%~1"=="-h" goto show_help
7+
48
set AGENT_APPLICATION=..\..\examples-kotlin
59

610
call ..\support\shell_template.bat %*
711

8-
endlocal
12+
endlocal
13+
exit /b 0
14+
15+
:show_help
16+
echo.
17+
echo Kotlin Agent Shell - Available Options:
18+
echo.
19+
echo --help, -h Show this help message
20+
echo --observability Enable observability features (Zipkin tracing)
21+
echo --no-docker-tools Disable Docker tool integration (basic features only)
22+
echo.
23+
echo Examples:
24+
echo shell.cmd
25+
echo shell.cmd --observability
26+
echo shell.cmd --observability --no-docker-tools
27+
echo.
28+
exit /b 0
29+
endlocal

scripts/kotlin/shell.sh

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,22 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
66
# Set the path relative to this script's directory
77
export AGENT_APPLICATION="$SCRIPT_DIR/../../examples-kotlin"
88

9+
# Check for help flag
10+
if [[ "$1" == "--help" || "$1" == "-h" ]]; then
11+
echo
12+
echo "Kotlin Agent Shell - Available Options:"
13+
echo
14+
echo " --help, -h Show this help message"
15+
echo " --observability Enable observability features (Zipkin tracing)"
16+
echo " --no-docker-tools Disable Docker tool integration (basic features only)"
17+
echo
18+
echo "Examples:"
19+
echo " ./shell.sh"
20+
echo " ./shell.sh --observability"
21+
echo " ./shell.sh --observability --no-docker-tools"
22+
echo
23+
exit 0
24+
fi
25+
926
# Call the shell_template.sh relative to this script's location
10-
"$SCRIPT_DIR/../support/shell_template.sh" "$@"
27+
"$SCRIPT_DIR/../support/shell_template.sh" "$@"

scripts/support/agent.bat

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ REM Display what we're running
2929
echo Starting application with profile: %MAVEN_PROFILE%
3030
echo Application path: %AGENT_APPLICATION%
3131

32-
cmd /c "..\..\mvnw -U -P %MAVEN_PROFILE% -f "%POM_FILE%" -Dmaven.test.skip=true clean spring-boot:run"
32+
if defined SPRING_PROFILES_ACTIVE (
33+
echo Spring profiles: %SPRING_PROFILES_ACTIVE%
34+
)
35+
36+
REM Run Maven Spring Boot application
37+
call ..\..\mvnw -U -P %MAVEN_PROFILE% -f "%POM_FILE%" -Dmaven.test.skip=true -Dspring.profiles.active=%SPRING_PROFILES_ACTIVE% clean spring-boot:run
3338

34-
endlocal
39+
endlocal

scripts/support/agent.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,5 +42,9 @@ fi
4242
echo "Starting application with profile: $MAVEN_PROFILE"
4343
echo "Application path: $AGENT_APPLICATION"
4444

45+
if [ -n "$SPRING_PROFILES_ACTIVE" ]; then
46+
echo "Spring profiles: $SPRING_PROFILES_ACTIVE"
47+
fi
48+
4549
# Run Maven Spring Boot application
46-
$SCRIPT_DIR/../../mvnw -U -P "$MAVEN_PROFILE" -f "$POM_FILE" -Dmaven.test.skip=true clean spring-boot:run
50+
$SCRIPT_DIR/../../mvnw -U -P "$MAVEN_PROFILE" -f "$POM_FILE" -Dmaven.test.skip=true -Dspring.profiles.active=$SPRING_PROFILES_ACTIVE clean spring-boot:run

scripts/support/shell_template.bat

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,22 @@ if not defined AGENT_APPLICATION (
99
REM Default: Docker tools enabled (reversed from original logic)
1010
set MAVEN_PROFILE=enable-shell-mcp-client
1111

12-
REM Check for --no-docker-tools parameter to disable tools
12+
REM Default: No observability profile
13+
set SPRING_PROFILES_ACTIVE=
14+
15+
REM Check for optional parameters
1316
:parse_args
1417
if "%~1"=="" goto end_parse
1518
if "%~1"=="--no-docker-tools" (
1619
set MAVEN_PROFILE=enable-shell
1720
shift
1821
goto parse_args
1922
)
23+
if "%~1"=="--observability" (
24+
set SPRING_PROFILES_ACTIVE=observability
25+
shift
26+
goto parse_args
27+
)
2028
REM Skip unknown parameters
2129
shift
2230
goto parse_args
@@ -37,5 +45,12 @@ if "%MAVEN_PROFILE%"=="enable-shell" (
3745
echo.
3846
)
3947

48+
REM Display observability status
49+
if defined SPRING_PROFILES_ACTIVE (
50+
powershell -Command "Write-Host 'INFO: Observability profile is enabled' -ForegroundColor Magenta"
51+
powershell -Command "Write-Host 'Make sure to run docker compose up to start Zipkin trace collector' -ForegroundColor Cyan"
52+
echo.
53+
)
54+
4055
call %~dp0..\support\agent.bat
41-
endlocal
56+
endlocal

scripts/support/shell_template.sh

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,20 @@ fi
88
# Default: Docker tools enabled (reversed from original logic)
99
export MAVEN_PROFILE=enable-shell-mcp-client
1010

11-
# Check for --no-docker-tools parameter to disable tools
11+
# Default: No observability profile
12+
export SPRING_PROFILES_ACTIVE=""
13+
14+
# Check for optional parameters
1215
while [[ $# -gt 0 ]]; do
1316
case $1 in
1417
--no-docker-tools)
1518
export MAVEN_PROFILE=enable-shell
1619
shift
1720
;;
21+
--observability)
22+
export SPRING_PROFILES_ACTIVE=observability
23+
shift
24+
;;
1825
*)
1926
# Skip unknown parameters
2027
shift
@@ -36,6 +43,13 @@ if [ "$MAVEN_PROFILE" = "enable-shell" ]; then
3643
echo
3744
fi
3845

46+
# Display observability status
47+
if [ -n "$SPRING_PROFILES_ACTIVE" ]; then
48+
echo -e "\033[35mINFO: Observability profile is enabled\033[0m"
49+
echo -e "\033[36mMake sure to run 'docker compose up' to start Zipkin trace collector\033[0m"
50+
echo
51+
fi
52+
3953
# Get the directory where this script is located and call agent.sh
4054
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
41-
"$SCRIPT_DIR/../support/agent.sh"
55+
"$SCRIPT_DIR/../support/agent.sh"

0 commit comments

Comments
 (0)