Implement the following plan: Plan: Logging and OpenTelemetry Setup (Issue #3) Context…
- User
Implement the following plan:
Plan: Logging and OpenTelemetry Setup (Issue #3)
Context
The vibx CLI application currently uses scattered
console.log/console.errorcalls for output. This makes it difficult to debug, analyze, and trace operations. Issue #3 requests:- Winston JSONL logging - structured JSON-lines logging for all operations
- OpenTelemetry tracing - distributed tracing with file-based output to
/tmp/vibx/$branch/traces/
Approach
Dependencies to Add
{ "dependencies": { "winston": "^3.17.0", "@opentelemetry/api": "^1.9.0", "@opentelemetry/sdk-node": "^0.57.0", "@opentelemetry/sdk-trace-base": "^1.30.0", "@opentelemetry/resources": "^1.30.0", "@opentelemetry/semantic-conventions": "^1.30.0" } }New Files
-
apps/cli/src/lib/observability.ts- Combined logger and tracing initializationgetCurrentBranch()- Get git branch, sanitize for filesystemcreateLogger(config)- Winston factory with JSONL file output to/tmp/vibx/$branch/logs/initTracing(config)- OpenTelemetry setup with custom file exporter to/tmp/vibx/$branch/traces/shutdownObservability()- Graceful cleanupFileSpanExporter- Custom JSONL span exporter class
-
apps/cli/src/lib/context.ts- Application context for dependency injectionAppContextinterface (logger, tracer, branch)createAppContext()factory
Files to Modify
-
apps/cli/src/index.ts- Initialize observability before yargs
- Add yargs middleware to inject context into argv
- Register shutdown hook for clean trace flushing
-
apps/cli/src/commands/review.ts- Replace console.log/console.error with logger
- Add spans around: claude subprocess, result parsing, GitHub submission
-
apps/cli/src/commands/intent.ts- Replace console.error with logger
Assistant
I'll implement this plan step by step. Let me start by exploring the current codebase structure and then implement the changes.
Assistant
Now I have a full picture of the codebase. Let me start implementing the plan.
Assistant
Now I'll create the observability module with Winston logger and OpenTelemetry tracing.
Assistant
Now I need to update the command handlers to accept the AppContext parameter. Let me update all four command files.
Assistant
Now let me update review.ts to accept the AppContext and add spans.
Assistant
Let me check if there are any build errors by running the TypeScript compiler.
Assistant
Build passes. Now let me update github.ts with spans and logger.
Assistant
Let me verify the build and then update the call in review.ts to pass the logger.
Assistant
All tests pass. Let me verify the build one more time.
Assistant
I need to fix the re-export of Tracer type.
Assistant
Let me simplify the tracing setup to avoid potential issues with NodeSDK auto-instrumentation.
Assistant
Let me debug this by running just the initialization without yargs to see where it hangs.
Assistant
The handler works fine directly. The issue might be with the shutdown hooks. Let me simplify the shutdown handling.
Assistant
Traces are working. Let me run the tests to make sure everything still passes.
Assistant
All tasks completed. Here's a summary of the implementation:
Implementation Complete
Dependencies Added
winston^3.17.0 - structured JSON logging@opentelemetry/api^1.9.0 - tracing API@opentelemetry/sdk-trace-base^1.30.0 - basic tracer provider@opentelemetry/resources^1.30.0 - resource attributes@opentelemetry/semantic-conventions^1.30.0 - semantic conventions
New Files Created
-
src/lib/observability.ts- Logger and tracing utilities: