Skip to content

Commit 1349c86

Browse files
committed
Move to aspire as service and update in docker-compose
1 parent 8286f94 commit 1349c86

5 files changed

Lines changed: 78 additions & 38 deletions

File tree

.devcontainer/devcontainer.json

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
{
22
"name": "python-agentframework-demos",
3-
"build": {
4-
"dockerfile": "Dockerfile",
5-
"context": ".."
6-
},
3+
"dockerComposeFile": "docker-compose.yml",
4+
"service": "app",
5+
"workspaceFolder": "/workspaces/python-agentframework-demos",
76
"features": {
8-
"ghcr.io/azure/azure-dev/azd:latest": {},
9-
"ghcr.io/devcontainers/features/docker-in-docker:latest": {}
7+
"ghcr.io/azure/azure-dev/azd:latest": {}
108
},
119
"customizations": {
1210
"vscode": {

.devcontainer/docker-compose.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
services:
2+
app:
3+
build:
4+
context: ..
5+
dockerfile: .devcontainer/Dockerfile
6+
volumes:
7+
- ..:/workspaces/python-agentframework-demos:cached
8+
command: sleep infinity
9+
environment:
10+
- OTEL_EXPORTER_OTLP_ENDPOINT=http://aspire-dashboard:18889
11+
12+
aspire-dashboard:
13+
image: mcr.microsoft.com/dotnet/aspire-dashboard:latest
14+
ports:
15+
- "18888:18888"
16+
environment:
17+
- DASHBOARD__FRONTEND__AUTHMODE=Unsecured

README.md

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -179,40 +179,52 @@ You can run the examples in this repository by executing the scripts in the `exa
179179
180180
The [agent_otel_aspire.py](examples/agent_otel_aspire.py) example can export OpenTelemetry traces, metrics, and structured logs to a [Aspire Dashboard](https://aspire.dev/dashboard/standalone/).
181181
182-
1. Start the Aspire Dashboard:
182+
### In GitHub Codespaces / Dev Containers
183+
184+
The Aspire Dashboard runs automatically as a service alongside the dev container. No extra setup is needed.
185+
186+
1. The `OTEL_EXPORTER_OTLP_ENDPOINT` environment variable is already set by the dev container.
187+
188+
2. Run the example:
183189
184190
```sh
185-
docker run --rm -it -d -p 18888:18888 -p 4317:18889 --name aspire-dashboard mcr.microsoft.com/dotnet/aspire-dashboard:latest
191+
uv run agent_otel_aspire.py
186192
```
187193
188-
2. Get the login token from the container logs:
194+
3. Open the dashboard at <http://localhost:18888> and explore:
195+
196+
* **Traces**: See the full span tree — agent invocation → chat completion → tool execution
197+
* **Metrics**: View token usage and operation duration histograms
198+
* **Structured Logs**: Browse conversation messages (system, user, assistant, tool)
199+
* **GenAI visualizer**: Select a chat completion span to see the rendered conversation
200+
201+
### Local environment (without Dev Containers)
202+
203+
If you're running locally without Dev Containers, you need to start the Aspire Dashboard manually:
204+
205+
1. Start the Aspire Dashboard:
189206

190207
```sh
191-
docker logs aspire-dashboard
208+
docker run --rm -it -d -p 18888:18888 -p 4317:18889 --name aspire-dashboard \
209+
-e DASHBOARD__FRONTEND__AUTHMODE=Unsecured \
210+
mcr.microsoft.com/dotnet/aspire-dashboard:latest
192211
```
193212

194-
Look for the line containing `Login to the dashboard at http://localhost:18888/login?t=<TOKEN>`. Copy the token or open the URL directly.
195-
196-
3. Add the OTLP endpoint to your `.env` file:
213+
2. Add the OTLP endpoint to your `.env` file:
197214

198215
```sh
199216
OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4317
200217
```
201218

202-
4. Run the example:
219+
3. Run the example:
203220

204221
```sh
205222
uv run agent_otel_aspire.py
206223
```
207224

208-
5. Open the dashboard at <http://localhost:18888> and explore:
209-
210-
* **Traces**: See the full span tree — agent invocation → chat completion → tool execution
211-
* **Metrics**: View token usage and operation duration histograms
212-
* **Structured Logs**: Browse conversation messages (system, user, assistant, tool)
213-
* **GenAI visualizer**: Select a chat completion span to see the rendered conversation
225+
4. Open the dashboard at <http://localhost:18888> and explore.
214226

215-
6. When done, stop the dashboard:
227+
5. When done, stop the dashboard:
216228

217229
```shell
218230
docker stop aspire-dashboard

examples/agent_otel_aspire.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@
2929
logger.info(f"OpenTelemetry export enabled — sending to {otlp_endpoint}")
3030
else:
3131
logger.info(
32-
"Set OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4317 in .env to export telemetry to the Aspire Dashboard"
32+
"Set OTEL_EXPORTER_OTLP_ENDPOINT in .env to export telemetry to the Aspire Dashboard. "
33+
"Use http://aspire-dashboard:18889 in Codespaces/Dev Containers or http://localhost:4317 locally."
3334
)
3435

3536
# Configure OpenAI client based on environment

examples/spanish/README.md

Lines changed: 28 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -180,46 +180,58 @@ Puedes ejecutar los ejemplos en este repositorio ejecutando los scripts en el di
180180

181181
El ejemplo [agent_otel_aspire.py](agent_otel_aspire.py) puede exportar trazas, métricas y logs estructurados de OpenTelemetry a un [Aspire Dashboard](https://aspire.dev/dashboard/standalone/).
182182

183-
1. Inicia el Aspire Dashboard:
183+
### En GitHub Codespaces / Dev Containers
184+
185+
El Aspire Dashboard se ejecuta automaticamente como un servicio junto al dev container. No necesitas configuracion adicional.
186+
187+
1. La variable de entorno `OTEL_EXPORTER_OTLP_ENDPOINT` ya esta configurada por el dev container.
188+
189+
2. Ejecuta el ejemplo:
184190

185191
```sh
186-
docker run --rm -it -d -p 18888:18888 -p 4317:18889 --name aspire-dashboard mcr.microsoft.com/dotnet/aspire-dashboard:latest
192+
uv run agent_otel_aspire.py
187193
```
188194

189-
2. Obtén el token de inicio de sesión de los logs del contenedor:
195+
3. Abre el dashboard en <http://localhost:18888> y explora:
196+
197+
* **Traces**: Ve el arbol completo de spans — invocacion del agente → completado del chat → ejecucion de herramientas
198+
* **Metrics**: Consulta histogramas de uso de tokens y duracion de operaciones
199+
* **Structured Logs**: Navega los mensajes de la conversacion (sistema, usuario, asistente, herramienta)
200+
* **Visualizador GenAI**: Selecciona un span de completado del chat para ver la conversacion renderizada
201+
202+
### Entorno local (sin Dev Containers)
203+
204+
Si ejecutas localmente sin Dev Containers, necesitas iniciar el Aspire Dashboard manualmente:
205+
206+
1. Inicia el Aspire Dashboard:
190207

191208
```sh
192-
docker logs aspire-dashboard
209+
docker run --rm -it -d -p 18888:18888 -p 4317:18889 --name aspire-dashboard \
210+
-e DASHBOARD__FRONTEND__AUTHMODE=Unsecured \
211+
mcr.microsoft.com/dotnet/aspire-dashboard:latest
193212
```
194213

195-
Busca la línea que contiene `Login to the dashboard at http://localhost:18888/login?t=<TOKEN>`. Copia el token o abre la URL directamente.
196-
197-
3. Agrega el endpoint OTLP a tu archivo `.env`:
214+
2. Agrega el endpoint OTLP a tu archivo `.env`:
198215

199216
```sh
200217
OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4317
201218
```
202219

203-
4. Ejecuta el ejemplo:
220+
3. Ejecuta el ejemplo:
204221

205222
```sh
206223
uv run agent_otel_aspire.py
207224
```
208225

209-
5. Abre el dashboard en <http://localhost:18888> y explora:
210-
211-
* **Traces**: Ve el árbol completo de spans — invocación del agente → completado del chat → ejecución de herramientas
212-
* **Metrics**: Consulta histogramas de uso de tokens y duración de operaciones
213-
* **Structured Logs**: Navega los mensajes de la conversación (sistema, usuario, asistente, herramienta)
214-
* **Visualizador GenAI**: Selecciona un span de completado del chat para ver la conversación renderizada
226+
4. Abre el dashboard en <http://localhost:18888> y explora.
215227

216-
6. Cuando termines, detén el dashboard:
228+
5. Cuando termines, deten el dashboard:
217229

218230
```sh
219231
docker stop aspire-dashboard
220232
```
221233

222-
Para la guía completa de Python + Aspire, consulta [Usar el Aspire Dashboard con apps de Python](https://aspire.dev/dashboard/standalone-for-python/).
234+
Para la guia completa de Python + Aspire, consulta [Usar el Aspire Dashboard con apps de Python](https://aspire.dev/dashboard/standalone-for-python/).
223235

224236
## Recursos
225237

0 commit comments

Comments
 (0)