Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .qualops/.qualopsrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,3 @@
"maxInlineComments": 50
}
}

4 changes: 1 addition & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@ RUN pnpm run build

FROM node:22-bookworm-slim AS runtime
WORKDIR /app
ENV NODE_ENV=production \
PORT=3000 \
CONFIG_PATH=/etc/configurable-agent/config.yaml
ENV NODE_ENV=production PORT=3000
RUN corepack enable && corepack prepare pnpm@10.30.2 --activate
COPY package.json pnpm-lock.yaml ./
COPY pnpm-workspace.yaml* ./
Expand Down
51 changes: 51 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
services:
agent:
build:
context: .
dockerfile: ./Dockerfile
ports:
- "3000:3000"
environment:
- CONFIG_PATH=/app/example.config.yaml
- OTEL_EXPORTER_OTLP_ENDPOINT=http://tempo:4318
- OTEL_SERVICE_NAME=configurable-agent
- ANTHROPIC_API_KEY=${ANTHROPIC_API_KEY}
volumes:
- ./example.config.yaml:/app/example.config.yaml:ro
healthcheck:
test: ["CMD", "node", "-e", "fetch('http://localhost:3000/health').then(r => process.exit(r.ok ? 0 : 1)).catch(() => process.exit(1))"]
interval: 30s
timeout: 10s
retries: 5
start_period: 30s
depends_on:
- tempo

tempo:
image: grafana/tempo:2.6.1
command: ["-config.file=/etc/tempo.yaml"]
volumes:
- ./docker/tempo.yaml:/etc/tempo.yaml
- tempo_data:/var/tempo
ports:
- "3200:3200" # HTTP API
- "4317:4317" # OTLP gRPC
- "4318:4318" # OTLP HTTP

grafana:
image: grafana/grafana:latest
volumes:
- ./docker/grafana-datasources.yaml:/etc/grafana/provisioning/datasources/datasources.yaml
- ./docker/grafana-provisioning.yaml:/etc/grafana/provisioning/dashboards/dashboard.yaml
environment:
- GF_AUTH_ANONYMOUS_ENABLED=true
- GF_AUTH_ANONYMOUS_ORG_ROLE=Admin
- GF_AUTH_DISABLE_LOGIN_FORM=true
- GF_FEATURE_TOGGLES_ENABLE=traceqlEditor
ports:
- "3001:3000"
depends_on:
- tempo

volumes:
tempo_data:
20 changes: 20 additions & 0 deletions docker/grafana-datasources.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
apiVersion: 1

datasources:
- name: Tempo
type: tempo
access: proxy
orgId: 1
url: http://tempo:3200
basicAuth: false
isDefault: true
version: 1
editable: false
apiVersion: 1
uid: tempo
jsonData:
httpMethod: GET
search:
hide: false
nodeGraph:
enabled: true
11 changes: 11 additions & 0 deletions docker/grafana-provisioning.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: 1

providers:
- name: "default"
orgId: 1
folder: ""
type: file
disableDeletion: false
updateIntervalSeconds: 10
options:
path: /var/lib/grafana/dashboards
26 changes: 26 additions & 0 deletions docker/tempo.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
server:
http_listen_port: 3200

distributor:
receivers:
otlp:
protocols:
http:
endpoint: 0.0.0.0:4318
grpc:
endpoint: 0.0.0.0:4317

ingester:
max_block_duration: 5m

compactor:
compaction:
block_retention: 1h

storage:
trace:
backend: local
wal:
path: /var/tempo/wal
local:
path: /var/tempo/blocks
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"engines": {
"node": ">=22"
},
"packageManager": "pnpm@10.28.2",
"scripts": {
"dev": "tsx watch src/index.ts",
"build": "tsc -p tsconfig.build.json && chmod +x dist/index.js",
Expand All @@ -28,6 +29,7 @@
"@ai-sdk/openai": "^2.0.0",
"@ai-sdk/openai-compatible": "^1.0.36",
"@hono/node-server": "^1.14.0",
"@hono/otel": "1.1.2",
"@opentelemetry/api": "^1.9.0",
"@opentelemetry/auto-instrumentations-node": "^0.54.0",
"@opentelemetry/exporter-trace-otlp-http": "^0.55.0",
Expand Down
14 changes: 14 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions src/api/server.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { httpInstrumentationMiddleware } from '@hono/otel';
import type { ModelMessage, ToolSet } from 'ai';
import { Hono } from 'hono';
import { streamSSE } from 'hono/streaming';
Expand All @@ -20,6 +21,8 @@ export function buildServer(config: AgentConfig, options: BuildServerOptions) {
const app = new Hono();
const { tools } = options;

app.use('*', httpInstrumentationMiddleware());

app.get('/health', (c) => c.json({ status: 'ok' }));

app.get('/ready', (c) => {
Expand Down
2 changes: 1 addition & 1 deletion src/modes/serve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export async function runServe(): Promise<void> {
let registry: Awaited<ReturnType<typeof buildMcpRegistry>>;
try {
registry = await buildMcpRegistry(config);

logger.info(
{ tools: Object.keys(registry.tools).length, servers: config.mcpTools.length },
'mcp registry ready',
Expand Down
8 changes: 7 additions & 1 deletion src/observability/tracing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,13 @@ export function startTracing(): void {
[SemanticResourceAttributes.SERVICE_VERSION]: process.env.OTEL_SERVICE_VERSION ?? '0.1.0',
}),
traceExporter: new OTLPTraceExporter(),
instrumentations: [getNodeAutoInstrumentations()],
instrumentations: [
getNodeAutoInstrumentations({
'@opentelemetry/instrumentation-http': {
requireParentforIncomingSpans: true,
},
}),
],
});
sdk.start();
}
Expand Down
Loading