otex
A VS Code plugin to auto instrument your code right in your IDE.
otex uses AI to automatically add OpenTelemetry instrumentation to your codebase. Analyze functions, select what to instrument, preview diffs, and apply changes — all from the sidebar.
Supported Languages
- TypeScript / JavaScript - Express, Fastify, NestJS, Koa, Next.js, React, Vue
- Python - Flask, FastAPI, Django
- Go - Gin, Echo, Fiber, Chi, net/http
- Java - Spring Boot, Micronaut, Quarkus
- Rust - Actix, Axum, Rocket, Warp
- C# - ASP.NET Core
- Ruby - Rails, Sinatra
- PHP - Laravel, Symfony
How It Works
- Analyze - The extension parses your code with AST analysis to discover functions, methods, and classes
- Select - A sidebar flow tree shows every element, classified by operation type (HTTP, database, auth, GenAI, etc.) with SRE-focused priority
- Instrument - AI generates OTel-instrumented versions of selected functions with proper span parent-child relationships
- Preview & Apply - Review diffs in VS Code's diff editor, then apply with one click (automatic backups included)
Features
Open the OTel Instrumentor panel in the activity bar. The sidebar guides you through scope selection, signal type, code analysis, function selection, and instrumentation.
Two Instrumentation Modes
- Current File - Analyze and instrument the active editor file
- Full Trace - Cross-file call graph analysis that traces request flows across your entire project
- Request Flow mode: finds entry points and traces the complete downstream call tree
- From Selection mode: traces upstream callers and downstream callees from selected functions
SRE-Focused Intelligence
Functions are automatically classified by operation type:
| Category |
Examples |
| HTTP Calls |
fetch, axios.get, http.request |
| Database |
query, findOne, save, insert |
| Authentication |
login, authenticate, authorize |
| GenAI / LLM |
chat, invoke_agent, execute_tool (OTel GenAI semantic conventions) |
| Event Handlers |
onClick, onSubmit, handleClick |
| Cache |
cache.get, cache.set |
| Messaging |
publish, subscribe, sendMessage |
| File I/O |
readFile, writeFile |
Entry points and critical-path operations are auto-selected; low-priority utilities are skipped by default.
Signal Types
Choose what telemetry to add:
- Traces - Distributed tracing with spans, context propagation, and proper parent-child relationships
- Logs - Structured logging with trace correlation
- Metrics - Counters, histograms, and gauges
- All - Complete instrumentation with all three signals
Diff Preview & Rollback
- Preview every change in VS Code's built-in diff editor before applying
- Automatic file backups before any modification
- One-click rollback to restore original files
- Backups persist across VS Code reloads
Scaling for Large Codebases
- Token-aware batching - Batch sizes are dynamically calculated based on source code token estimates to stay within the model's context window
- Rate limiting - Built-in request throttling (50 req/min) with exponential backoff and automatic retry on 429 responses
- Pause & Resume - Cancel a long instrumentation and resume later from where you left off. Progress is checkpointed after each file.
- State persistence - Analysis results, selections, and job progress survive VS Code reloads
- Call graph caching - Full-trace mode caches the project call graph and skips re-analysis when files haven't changed
- Selection cap - Full-trace auto-selects the top 50 functions by priority to prevent overwhelming the API; use Select All to override
- Large operation confirmation - Instrumenting more than 20 functions triggers a confirmation dialog with estimated API call count
Cross-File Call Chain Tracing
- Resolves imports and exports across files to build a project-wide call graph
- Visualizes upstream callers and downstream callees in the sidebar
- Supports TypeScript and JavaScript projects with ES module and CommonJS imports
Runtime Detection
Automatically detects your project's runtime environment:
- Node.js - Express, Fastify, NestJS backends
- Browser - React, Vue, Angular frontends
- Universal - Next.js, Nuxt SSR frameworks
Installation
From VSIX
- Download or build the
.vsix file:
npm install
npm run package
- In VS Code:
Cmd+Shift+P / Ctrl+Shift+P > Extensions: Install from VSIX > select the file
Development
- Clone the repository
npm install
- Press
F5 to launch the Extension Development Host
Configuration
API Key Setup
Cmd+Shift+P / Ctrl+Shift+P > OTel: Set API Key
- Enter your AI provider API key
Settings
| Setting |
Description |
Default |
otex.apiKey |
AI provider API key |
|
otex.serviceName |
Service name for OTel resource attributes |
my-service |
otex.model |
AI model for code generation |
claude-sonnet-4-20250514 |
otex.maxInputTokens |
Max input token budget per API call |
150000 |
otex.defaultSignalType |
Default signal type (traces, logs, metrics, all) |
traces |
otex.autoBackup |
Auto-backup files before applying changes |
true |
otex.otlp.endpoint |
OTLP collector endpoint |
http://localhost:4318 |
otex.otlp.protocol |
OTLP protocol (http/json, http/protobuf, grpc) |
http/json |
otex.otlp.headers |
Custom headers for OTLP requests |
{} |
otex.otlp.timeout |
OTLP request timeout (ms) |
10000 |
otex.otlp.compression |
OTLP compression (none, gzip) |
none |
Commands
| Command |
Description |
OTel: Set API Key |
Configure your AI provider API key |
OTel: Analyze Current File |
Parse the active file and show instrumentable functions |
OTel: Instrument Functions in Current File |
Instrument selected functions in the active file |
OTel: Rollback Instrumentation |
Restore files from backup |
OTel: Validate OTLP Endpoint |
Test connectivity to your OTLP collector |
OTel: Open Settings |
Open extension settings |
Requirements
- VS Code 1.85.0 or higher
- AI provider API key
License
MIT
| |