Created
December 18, 2025 16:28
-
-
Save NikiforovAll/d385fdfaeb80067b5db0dad2fba6fec7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| set -euo pipefail | |
| CONTAINER_NAME="aspire-dashboard" | |
| IMAGE="mcr.microsoft.com/dotnet/aspire-dashboard" | |
| UI_PORT="18888" | |
| OTLP_PORT="4317" | |
| detect_runtime() { | |
| if command -v podman &>/dev/null; then | |
| echo "podman" | |
| elif command -v docker &>/dev/null; then | |
| echo "docker" | |
| else | |
| echo "Error: Neither podman nor docker found" >&2 | |
| exit 1 | |
| fi | |
| } | |
| RUNTIME=$(detect_runtime) | |
| print_env() { | |
| cat <<'EOF' | |
| export CLAUDE_CODE_ENABLE_TELEMETRY=1 | |
| export OTEL_LOG_USER_PROMPTS=1 | |
| export OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4317 | |
| export OTEL_EXPORTER_OTLP_PROTOCOL=grpc | |
| export OTEL_LOGS_EXPORTER=otlp | |
| export OTEL_LOGS_EXPORT_INTERVAL=5000 | |
| export OTEL_EXPORTER_OTLP_METRICS_PROTOCOL=grpc | |
| export OTEL_METRICS_EXPORTER=otlp | |
| export OTEL_METRIC_EXPORT_INTERVAL=10000 | |
| export OTEL_SERVICE_NAME=claude-code | |
| export OTEL_RESOURCE_ATTRIBUTES=service.instance.id=nikiforovall | |
| EOF | |
| } | |
| container_exists() { | |
| $RUNTIME container inspect "$CONTAINER_NAME" &>/dev/null | |
| } | |
| container_running() { | |
| [ "$($RUNTIME container inspect -f '{{.State.Running}}' "$CONTAINER_NAME" 2>/dev/null)" = "true" ] | |
| } | |
| start_container() { | |
| if container_running; then | |
| echo "Dashboard already running (using $RUNTIME)" | |
| elif container_exists; then | |
| echo "Starting existing container..." | |
| $RUNTIME start "$CONTAINER_NAME" | |
| else | |
| echo "Creating and starting container..." | |
| $RUNTIME run --rm -d \ | |
| -p "$UI_PORT:$UI_PORT" \ | |
| -p "$OTLP_PORT:$OTLP_PORT" \ | |
| --name "$CONTAINER_NAME" \ | |
| "$IMAGE" | |
| fi | |
| echo "" | |
| echo "Dashboard available at: http://localhost:$UI_PORT" | |
| echo "OTLP endpoint: http://localhost:$OTLP_PORT" | |
| } | |
| stop_container() { | |
| if container_running; then | |
| echo "Stopping dashboard..." | |
| $RUNTIME stop "$CONTAINER_NAME" | |
| echo "Dashboard stopped" | |
| else | |
| echo "Dashboard is not running" | |
| fi | |
| } | |
| show_status() { | |
| echo "Runtime: $RUNTIME" | |
| if container_running; then | |
| echo "Status: Running" | |
| echo "Dashboard: http://localhost:$UI_PORT" | |
| echo "OTLP: http://localhost:$OTLP_PORT" | |
| elif container_exists; then | |
| echo "Status: Stopped" | |
| else | |
| echo "Status: Not created" | |
| fi | |
| } | |
| show_help() { | |
| cat <<EOF | |
| ccdashboard - Claude Code Telemetry Dashboard Manager | |
| Usage: ccdashboard [command] | |
| Commands: | |
| start Start the dashboard (default) | |
| stop Stop the dashboard | |
| restart Restart the dashboard | |
| status Show dashboard status | |
| env Print environment variables for sourcing | |
| help Show this help message | |
| Examples: | |
| eval "\$(ccdashboard env)" # Load telemetry env vars | |
| ccdashboard # Start dashboard | |
| ccdashboard status # Check if running | |
| EOF | |
| } | |
| case "${1:-start}" in | |
| start) | |
| start_container | |
| ;; | |
| stop) | |
| stop_container | |
| ;; | |
| restart) | |
| stop_container | |
| start_container | |
| ;; | |
| status) | |
| show_status | |
| ;; | |
| env) | |
| print_env | |
| ;; | |
| help|--help|-h) | |
| show_help | |
| ;; | |
| *) | |
| echo "Unknown command: $1" | |
| show_help | |
| exit 1 | |
| ;; | |
| esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment