5.1 KiB
Go OTel Debugger
A debug receiver for OpenTelemetry telemetry data (traces, metrics, and logs) that provides real-time visualization and historical data access. It accepts OTLP data via HTTP and gRPC protocols, stores a configurable history of received telemetry, and broadcasts updates to connected WebSocket clients for live debugging.
Features
- OTLP Support: Receives traces, metrics, and logs via both HTTP (JSON/Protobuf) and gRPC (Protobuf) protocols on standard OTLP ports.
- Real-time Broadcasting: Uses WebSocket connections to broadcast incoming telemetry data to all connected clients instantly.
- Historical Data: Maintains a configurable ring buffer of recent telemetry data, accessible via REST API endpoints.
- Web Interface: Includes a built-in HTML interface for visualizing telemetry data in real-time with counters and clear buttons.
- Docker Support: Containerized for easy deployment.
- Kubernetes Ready: Includes deployment manifests for Kubernetes clusters.
Architecture
The application consists of several key components:
- HTTP/gRPC Servers: Handle incoming OTLP requests on ports 8080 (HTTP) and 4317 (gRPC).
- Collector: Processes and stores telemetry data in a ring buffer for history. Implements OpenTelemetry consumer interfaces.
- WebSocket Server: Manages client connections and broadcasts new telemetry data as JSON messages.
- Web Interface: Static HTML page served on the root path that connects to the WebSocket for real-time updates.
- History API: REST endpoints to retrieve stored telemetry data by type or all combined.
Data flow:
OTLP Client → HTTP/gRPC Server → Collector → WebSocket Broadcast → Connected Clients
↓
History Storage → REST API → Clients
Getting Started
Prerequisites
- Go 1.25+ (for local development)
- Docker (optional, for containerized deployment)
Running Locally
-
Clone the repository:
git clone https://git.tornberg.me/go-otel.git cd go-otel -
Run the server:
go run ./cmd/server
The server will start on ports 8080 (HTTP/WebSocket) and 4317 (gRPC).
Running with Docker
-
Build the Docker image:
docker build -t go-otel . -
Run the container:
docker run -p 8080:8080 -p 4317:4317 go-otel
Kubernetes Deployment
Apply the included Kubernetes manifests:
kubectl apply -f k8s/
This deploys the application with a Service and Ingress for external access.
API Endpoints
OTLP HTTP Endpoints (Port 8080)
POST /v1/traces- Receive OTLP tracesPOST /v1/metrics- Receive OTLP metricsPOST /v1/logs- Receive OTLP logs
Supported Content-Types: application/json, application/x-protobuf
OTLP gRPC Endpoints (Port 4317)
gRPC services for traces, metrics, and logs using standard OTLP protobuf definitions.
WebSocket Endpoint (Port 8080)
GET /ws- WebSocket connection for real-time telemetry streaming
History API Endpoints (Port 8080)
GET /api/history- Retrieve all historical telemetry dataGET /api/history/traces- Retrieve only trace historyGET /api/history/metrics- Retrieve only metrics historyGET /api/history/logs- Retrieve only logs history
Web Interface
GET /- Serves the HTML visualization interface
Usage
Sending Telemetry Data
Send OTLP data to the appropriate endpoints. The data will be stored in history and broadcast to all connected WebSocket clients.
HTTP Example (JSON)
curl -X POST http://localhost:8080/v1/traces \
-H "Content-Type: application/json" \
-d '{"resourceSpans":[{"resource":{"attributes":[{"key":"service.name","value":{"stringValue":"test-service"}}]},"scopeSpans":[{"scope":{"name":"test-scope"},"spans":[{"traceId":"0102030405060708090a0b0c0d0e0f10","spanId":"0102030405060708","name":"test-span","startTimeUnixNano":"1640995200000000000","endTimeUnixNano":"1640995260000000000","attributes":[{"key":"test.key","value":{"stringValue":"test-value"}}]}]}]}]}'
gRPC Example
Use any OTLP gRPC client library to send data to localhost:4317.
Real-time Visualization
- Open
http://localhost:8080in your browser - The interface will automatically connect via WebSocket
- Send telemetry data to see it appear in real-time
- Use the "Clear" buttons to reset individual data sections
- View message counters for each telemetry type
Accessing Historical Data
Use the history API endpoints to retrieve previously received data:
curl http://localhost:8080/api/history/traces
This returns JSON arrays of historical entries with timestamps.
Configuration
Currently, the history buffer size is hardcoded to 100 entries. This can be made configurable in future versions.
Development
To modify the application:
- Edit source files in
cmd/server/andinternal/ - Run locally with
go run ./cmd/server - For UI changes, edit
index.htmldirectly
The application uses standard Go modules and OpenTelemetry collector libraries for data processing.