@@ -8,6 +8,7 @@ This project showcases a complete Generative AI interface that includes:
88- React/TypeScript frontend with a responsive chat UI
99- Go backend server for API handling
1010- Integration with Docker's Model Runner to run Llama 3.2 locally
11+ - Comprehensive observability with metrics, logging, and tracing
1112
1213## Features
1314
@@ -18,17 +19,27 @@ This project showcases a complete Generative AI interface that includes:
1819- 🏠 Run AI models locally without cloud API dependencies
1920- 🔒 Cross-origin resource sharing (CORS) enabled
2021- 🧪 Integration testing using Testcontainers
22+ - 📊 Metrics and performance monitoring
23+ - 📝 Structured logging with zerolog
24+ - 🔍 Distributed tracing with OpenTelemetry
25+ - 📈 Grafana dashboards for visualization
2126
2227## Architecture
2328
24- The application consists of three main components:
29+ The application consists of these main components:
2530
2631```
2732┌─────────────┐ ┌─────────────┐ ┌─────────────┐
2833│ Frontend │ >>> │ Backend │ >>> │ Model Runner│
2934│ (React/TS) │ │ (Go) │ │ (Llama 3.2) │
3035└─────────────┘ └─────────────┘ └─────────────┘
3136 :3000 :8080 :12434
37+ │ │
38+ ┌─────────────┐ ┌─────┘ └─────┐ ┌─────────────┐
39+ │ Grafana │ <<< │ Prometheus │ │ Jaeger │
40+ │ Dashboards │ │ Metrics │ │ Tracing │
41+ └─────────────┘ └─────────────┘ └─────────────┘
42+ :3001 :9091 :16686
3243```
3344
3445## Connection Methods
@@ -75,6 +86,11 @@ docker model pull ignaciolopezluna020/llama3.2:1B
7586
76873 . Access the frontend at [ http://localhost:3000 ] ( http://localhost:3000 )
7788
89+ 4 . Access observability dashboards:
90+ - Grafana: [ http://localhost:3001 ] ( http://localhost:3001 ) (admin/admin)
91+ - Jaeger UI: [ http://localhost:16686 ] ( http://localhost:16686 )
92+ - Prometheus: [ http://localhost:9091 ] ( http://localhost:9091 )
93+
7894## Development Setup
7995
8096### Frontend
@@ -102,6 +118,10 @@ Make sure to set the required environment variables from `backend.env`:
102118- ` BASE_URL ` : URL for the model runner
103119- ` MODEL ` : Model identifier to use
104120- ` API_KEY ` : API key for authentication (defaults to "ollama")
121+ - ` LOG_LEVEL ` : Logging level (debug, info, warn, error)
122+ - ` LOG_PRETTY ` : Whether to output pretty-printed logs
123+ - ` TRACING_ENABLED ` : Enable OpenTelemetry tracing
124+ - ` OTLP_ENDPOINT ` : OpenTelemetry collector endpoint
105125
106126## How It Works
107127
@@ -110,6 +130,7 @@ Make sure to set the required environment variables from `backend.env`:
1101303 . The LLM processes the input and generates a response
1111314 . The backend streams the tokens back to the frontend as they're generated
1121325 . The frontend displays the incoming tokens in real-time
133+ 6 . Observability components collect metrics, logs, and traces throughout the process
113134
114135## Project Structure
115136
@@ -122,17 +143,51 @@ Make sure to set the required environment variables from `backend.env`:
122143│ │ ├── components/ # React components
123144│ │ ├── App.tsx # Main application component
124145│ │ └── ...
125- │ ├── package.json # NPM dependencies
126- │ └── ...
146+ ├── pkg/ # Go packages
147+ │ ├── logger/ # Structured logging
148+ │ ├── metrics/ # Prometheus metrics
149+ │ ├── middleware/ # HTTP middleware
150+ │ ├── tracing/ # OpenTelemetry tracing
151+ │ └── health/ # Health check endpoints
152+ ├── prometheus/ # Prometheus configuration
153+ ├── grafana/ # Grafana dashboards and configuration
154+ ├── observability/ # Observability documentation
127155└── ...
128156```
129157
158+ ## Observability Features
159+
160+ The project includes comprehensive observability features:
161+
162+ ### Metrics
163+
164+ - Model performance (latency, time to first token)
165+ - Token usage (input and output counts)
166+ - Request rates and error rates
167+ - Active request monitoring
168+
169+ ### Logging
170+
171+ - Structured JSON logs with zerolog
172+ - Log levels (debug, info, warn, error, fatal)
173+ - Request logging middleware
174+ - Error tracking
175+
176+ ### Tracing
177+
178+ - Request flow tracing with OpenTelemetry
179+ - Integration with Jaeger for visualization
180+ - Span context propagation
181+
182+ For more information, see [ Observability Documentation] ( ./observability/README.md ) .
183+
130184## Customization
131185
132186You can customize the application by:
1331871 . Changing the model in ` backend.env ` to use a different LLM
1341882 . Modifying the frontend components for a different UI experience
1351893 . Extending the backend API with additional functionality
190+ 4 . Customizing the Grafana dashboards for different metrics
136191
137192## Testing
138193
@@ -148,6 +203,7 @@ go test -v
148203- ** Model not loading** : Ensure you've pulled the model with ` docker model pull `
149204- ** Connection errors** : Verify Docker network settings and that Model Runner is running
150205- ** Streaming issues** : Check CORS settings in the backend code
206+ - ** Metrics not showing** : Verify that Prometheus can reach the backend metrics endpoint
151207
152208## License
153209
0 commit comments