mirror of
https://github.com/bendtherules/ask262.git
synced 2026-08-18 13:21:55 +00:00
Add Langfuse as an OTel trace transport for MCP request lifecycle tracking.
Changes:
- New src/lib/langfuse-transport.ts: initializes LangfuseSpanProcessor when
ASK262_LANGFUSE_ENABLED=true with valid credentials
- src/lib/tracing.ts: add metadata to TraceContext, propagate it to child spans,
use startActiveSpan for proper OTel context, add setupTracing() entry point,
add getSessionMetadata() for version/transport metadata
- src/lib/logger.ts: include TraceContext.metadata in JSON log mixin
- src/mcp-server-{http,stdio}.ts: call setupTracing() at startup, pass
version/transport metadata through withSpan/withSpanContext
- src/lib/fireworks-embeddings.ts: wrap API calls in withSpan() with gen_ai
attributes for Langfuse generation/cost tracking
- .env.example: add LANGFUSE_* configuration variables
- AGENTS.md: document Langfuse integration
- package.json: add @langfuse/tracing, @langfuse/otel, @opentelemetry/sdk-node
79 lines
3.1 KiB
Bash
79 lines
3.1 KiB
Bash
# Ask262 Environment Configuration
|
|
# Copy this file to .env and fill in your actual values
|
|
# Bun automatically loads .env files - no dotenv package needed!
|
|
|
|
# =============================================================================
|
|
# EMBEDDING PROVIDER CONFIGURATION
|
|
# =============================================================================
|
|
|
|
# Choose your embedding provider: "ollama" (local) or "fireworks" (cloud)
|
|
# Default: "ollama"
|
|
ASK262_EMBEDDING_PROVIDER=ollama
|
|
|
|
# =============================================================================
|
|
# OLLAMA (LOCAL) CONFIGURATION
|
|
# =============================================================================
|
|
|
|
# Ollama server URL (optional, defaults to http://localhost:11434)
|
|
# OLLAMA_HOST=http://localhost:11434
|
|
|
|
# =============================================================================
|
|
# FIREWORKS.AI (CLOUD) CONFIGURATION
|
|
# =============================================================================
|
|
|
|
# Required if using Fireworks embeddings
|
|
# Get your API key from: https://app.fireworks.ai/models/fireworks/qwen3-embedding-8b
|
|
# FIREWORKS_API_KEY=fw_xxxxxxxxxxxxxxxxxxxxxxxx
|
|
|
|
# Fireworks base URL (optional, defaults to https://api.fireworks.ai/inference/v1)
|
|
# FIREWORKS_BASE_URL=https://api.fireworks.ai/inference/v1
|
|
|
|
# =============================================================================
|
|
# HTTP SERVER CONFIGURATION
|
|
# =============================================================================
|
|
|
|
# Port for the HTTP MCP server (optional, defaults to 8081)
|
|
# ASK262_PORT=8081
|
|
|
|
# Public URL for the MCP server (used by MCP Inspector to auto-connect)
|
|
# Required when running behind a reverse proxy or in production
|
|
# Example: https://ask262.bendtherules.in or https://your-server.com
|
|
# MCP_PUBLIC_URL=http://localhost:8081
|
|
|
|
# =============================================================================
|
|
# LOGGING CONFIGURATION
|
|
# =============================================================================
|
|
|
|
# Log level: trace, debug, info, warn, error
|
|
# Defaults to 'debug' for file logging when not set
|
|
# ASK262_LOG_LEVEL=info
|
|
|
|
# Console logging is opt-in to avoid corrupting stdio MCP protocol and noisy tests.
|
|
# Set to 'true' to enable pretty-printed console output (goes to stderr).
|
|
# ASK262_LOG_CONSOLE=true
|
|
|
|
# Directory for log files (optional, defaults to ./logs)
|
|
# ASK262_LOG_DIR=./logs
|
|
|
|
# Max log file size in MB before rotation (optional, defaults to 100)
|
|
# System logrotate handles rotation, this is for reference
|
|
# ASK262_LOG_MAX_SIZE=100
|
|
|
|
# Days to keep rotated logs before deletion (optional, defaults to 30)
|
|
# Set to 0 to keep forever
|
|
# ASK262_LOG_RETENTION_DAYS=30
|
|
|
|
# =============================================================================
|
|
# LANGFUSE OBSERVABILITY (opt-in)
|
|
# =============================================================================
|
|
|
|
# Enable Langfuse trace export (defaults to false)
|
|
# ASK262_LANGFUSE_ENABLED=true
|
|
|
|
# Langfuse credentials (required when enabled)
|
|
# LANGFUSE_PUBLIC_KEY=pk-lf-...
|
|
# LANGFUSE_SECRET_KEY=sk-lf-...
|
|
|
|
# Langfuse host (optional, defaults to https://cloud.langfuse.com)
|
|
# LANGFUSE_BASE_URL=https://cloud.langfuse.com
|