autotel-cli 0.9.0 → 0.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +1 -1
- package/dist/index.js +5890 -5793
- package/dist/index.js.map +1 -1
- package/package.json +6 -5
- package/skills/autotel-cli/SKILL.md +263 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "autotel-cli",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.1",
|
|
4
4
|
"description": "CLI for autotel - setup wizard, diagnostics, and incremental features",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -13,7 +13,8 @@
|
|
|
13
13
|
}
|
|
14
14
|
},
|
|
15
15
|
"files": [
|
|
16
|
-
"dist"
|
|
16
|
+
"dist",
|
|
17
|
+
"skills"
|
|
17
18
|
],
|
|
18
19
|
"dependencies": {
|
|
19
20
|
"@inquirer/prompts": "^8.5.2",
|
|
@@ -34,7 +35,7 @@
|
|
|
34
35
|
"eslint": "^10.4.1",
|
|
35
36
|
"eslint-config-prettier": "^10.1.8",
|
|
36
37
|
"eslint-plugin-unicorn": "^64.0.0",
|
|
37
|
-
"
|
|
38
|
+
"tsdown": "^0.22.2",
|
|
38
39
|
"tsx": "^4.22.4",
|
|
39
40
|
"typescript": "^6.0.3",
|
|
40
41
|
"typescript-eslint": "^8.60.1",
|
|
@@ -61,8 +62,8 @@
|
|
|
61
62
|
},
|
|
62
63
|
"homepage": "https://github.com/jagreehal/autotel#readme",
|
|
63
64
|
"scripts": {
|
|
64
|
-
"build": "
|
|
65
|
-
"dev": "
|
|
65
|
+
"build": "tsdown",
|
|
66
|
+
"dev": "tsdown --watch",
|
|
66
67
|
"test": "vitest run --config vitest.unit.config.ts",
|
|
67
68
|
"test:watch": "vitest",
|
|
68
69
|
"lint": "eslint src",
|
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: autotel-cli
|
|
3
|
+
description: >
|
|
4
|
+
Use this skill when running autotel CLI commands to set up, configure, or extend OpenTelemetry instrumentation in a Node.js project — including init, doctor, add, and codemod trace.
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# autotel-cli
|
|
8
|
+
|
|
9
|
+
CLI for autotel: interactive setup wizard, diagnostics, incremental feature addition, and a codemod to adopt tracing on existing code. Targets Node.js 18+.
|
|
10
|
+
|
|
11
|
+
## Setup
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
# One-off use (no global install needed)
|
|
15
|
+
npx autotel <command>
|
|
16
|
+
|
|
17
|
+
# Or install globally
|
|
18
|
+
npm install -g autotel-cli
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Commands
|
|
22
|
+
|
|
23
|
+
### `autotel init`
|
|
24
|
+
|
|
25
|
+
Interactive wizard that writes an instrumentation file and installs dependencies.
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
# Interactive (prompts for backend, plugins, etc.)
|
|
29
|
+
npx autotel init
|
|
30
|
+
|
|
31
|
+
# Non-interactive: accept all defaults (local backend, all auto-instrumentations)
|
|
32
|
+
npx autotel init --yes
|
|
33
|
+
|
|
34
|
+
# Use a named quick preset
|
|
35
|
+
npx autotel init --preset node-datadog-pino
|
|
36
|
+
|
|
37
|
+
# Preview what would happen without writing files
|
|
38
|
+
npx autotel init --dry-run
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
**Quick presets:** `node-datadog-pino`, `node-datadog-agent`, `node-honeycomb`, `node-otlp`
|
|
42
|
+
|
|
43
|
+
**Key options:**
|
|
44
|
+
|
|
45
|
+
| Option | Effect |
|
|
46
|
+
|---|---|
|
|
47
|
+
| `--yes / -y` | Non-interactive, accept defaults |
|
|
48
|
+
| `--preset <name>` | Use a quick preset |
|
|
49
|
+
| `--dry-run` | Print what would be done, no writes or installs |
|
|
50
|
+
| `--no-install` | Generate files only, skip package installation |
|
|
51
|
+
| `--print-install-cmd` | Output the install command instead of running it |
|
|
52
|
+
| `--force` | Overwrite existing config (backs up the old file first) |
|
|
53
|
+
| `--workspace-root` | Install at monorepo workspace root instead of package root |
|
|
54
|
+
|
|
55
|
+
Generated files:
|
|
56
|
+
- `src/instrumentation.mts` (or `.mjs`) — the instrumentation entry point with section markers
|
|
57
|
+
- `.env.example` — env var template based on selected presets (written only if file does not exist)
|
|
58
|
+
|
|
59
|
+
After init, start your app with `--import`:
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
# Node.js ESM
|
|
63
|
+
node --import ./src/instrumentation.mts dist/index.js
|
|
64
|
+
|
|
65
|
+
# With tsx (development)
|
|
66
|
+
tsx --import ./src/instrumentation.mts src/index.ts
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
---
|
|
70
|
+
|
|
71
|
+
### `autotel doctor`
|
|
72
|
+
|
|
73
|
+
Diagnose the current autotel setup.
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
npx autotel doctor # Run all checks, human-readable output
|
|
77
|
+
npx autotel doctor --json # Machine-readable JSON
|
|
78
|
+
npx autotel doctor --fix # Auto-fix resolvable issues
|
|
79
|
+
npx autotel doctor --list-checks # Show all available check names
|
|
80
|
+
npx autotel doctor --env-file .env.production # Check a specific env file
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
Exit codes: `0` = all passed, `1` = warnings, `2` = errors.
|
|
84
|
+
|
|
85
|
+
---
|
|
86
|
+
|
|
87
|
+
### `autotel add <type> <name>`
|
|
88
|
+
|
|
89
|
+
Incrementally add a backend, subscriber, plugin, or platform to an existing instrumentation file.
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
# List all available presets
|
|
93
|
+
npx autotel add --list
|
|
94
|
+
|
|
95
|
+
# List backends only
|
|
96
|
+
npx autotel add backend --list
|
|
97
|
+
|
|
98
|
+
# Add Datadog backend
|
|
99
|
+
npx autotel add backend datadog
|
|
100
|
+
|
|
101
|
+
# Add a PostHog event subscriber
|
|
102
|
+
npx autotel add subscriber posthog
|
|
103
|
+
|
|
104
|
+
# Add Mongoose plugin
|
|
105
|
+
npx autotel add plugin mongoose
|
|
106
|
+
|
|
107
|
+
# Show help for a specific preset (packages, env vars, next steps)
|
|
108
|
+
npx autotel add backend datadog --help
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
**Preset types:**
|
|
112
|
+
|
|
113
|
+
| Type | Examples |
|
|
114
|
+
|---|---|
|
|
115
|
+
| `backend` | `datadog`, `honeycomb`, `otlp`, `local` |
|
|
116
|
+
| `subscriber` | `posthog`, `mixpanel`, `segment`, `slack` |
|
|
117
|
+
| `plugin` | `mongoose`, `drizzle` |
|
|
118
|
+
| `platform` | AWS Lambda, Cloudflare Workers |
|
|
119
|
+
|
|
120
|
+
**Key options:** `--dry-run`, `--no-install`, `--force`, `--json` (for `--list`).
|
|
121
|
+
|
|
122
|
+
`add` is idempotent: if the package is already installed and the instrumentation file already contains the feature, it exits cleanly with `[OK]`.
|
|
123
|
+
|
|
124
|
+
`add` requires an existing CLI-owned instrumentation file (created by `autotel init`). Use `--force` to modify a user-created file.
|
|
125
|
+
|
|
126
|
+
---
|
|
127
|
+
|
|
128
|
+
### `autotel codemod trace <path>`
|
|
129
|
+
|
|
130
|
+
Wrap existing functions in `trace()` calls, deriving span names from the function or variable name. Use this to adopt tracing on existing code without manual edits.
|
|
131
|
+
|
|
132
|
+
```bash
|
|
133
|
+
# Single file
|
|
134
|
+
npx autotel codemod trace src/index.ts
|
|
135
|
+
|
|
136
|
+
# Glob (quote to prevent shell expansion)
|
|
137
|
+
npx autotel codemod trace "src/**/*.ts"
|
|
138
|
+
|
|
139
|
+
# All supported types
|
|
140
|
+
npx autotel codemod trace "src/**/*.{ts,tsx,js,jsx}"
|
|
141
|
+
|
|
142
|
+
# Dry run — preview changes without writing
|
|
143
|
+
npx autotel codemod trace "src/**/*.ts" --dry-run
|
|
144
|
+
|
|
145
|
+
# Custom span name: {name}, {file} (basename), {path} (relative from --cwd)
|
|
146
|
+
npx autotel codemod trace "src/**/*.ts" --name-pattern "{file}.{name}"
|
|
147
|
+
|
|
148
|
+
# Skip functions matching a regex (repeatable, combined as OR)
|
|
149
|
+
npx autotel codemod trace "src/**/*.ts" --skip "^_" --skip "test|mock"
|
|
150
|
+
|
|
151
|
+
# Print per-file summary
|
|
152
|
+
npx autotel codemod trace "src/**/*.ts" --print-files
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
**What gets wrapped:** function declarations, arrow/function expressions in `const`/`let`/`var`, class and static methods, object method shorthand, named default export functions.
|
|
156
|
+
|
|
157
|
+
**Never wrapped:** generator functions, getters/setters, constructors, `super` usage in body, anonymous default exports, `.d.ts` files, `node_modules/`, files that already use `require('autotel')`.
|
|
158
|
+
|
|
159
|
+
## Configuration Patterns
|
|
160
|
+
|
|
161
|
+
### Global options (all commands)
|
|
162
|
+
|
|
163
|
+
```bash
|
|
164
|
+
--cwd <path> # Target directory (default: cwd)
|
|
165
|
+
--verbose # Show detailed output
|
|
166
|
+
--quiet # Only show warnings and errors
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
### Package manager detection
|
|
170
|
+
|
|
171
|
+
Detected automatically from the nearest lockfile in this order:
|
|
172
|
+
1. `pnpm-lock.yaml` → pnpm
|
|
173
|
+
2. `bun.lockb` → bun
|
|
174
|
+
3. `yarn.lock` → yarn
|
|
175
|
+
4. `package-lock.json` → npm
|
|
176
|
+
|
|
177
|
+
Fallback: npm.
|
|
178
|
+
|
|
179
|
+
### Monorepo usage
|
|
180
|
+
|
|
181
|
+
```bash
|
|
182
|
+
# Install into a specific workspace package
|
|
183
|
+
npx autotel init --cwd ./packages/my-app
|
|
184
|
+
|
|
185
|
+
# Install at workspace root (shared instrumentation)
|
|
186
|
+
npx autotel init --cwd ./packages/my-app --workspace-root
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
### Generated instrumentation file structure
|
|
190
|
+
|
|
191
|
+
The CLI uses section markers to allow `autotel add` to safely modify the file:
|
|
192
|
+
|
|
193
|
+
```typescript
|
|
194
|
+
/**
|
|
195
|
+
* autotel instrumentation - managed by autotel-cli
|
|
196
|
+
* Run `autotel add <feature>` to update this file
|
|
197
|
+
*/
|
|
198
|
+
import 'autotel/register';
|
|
199
|
+
import { init } from 'autotel';
|
|
200
|
+
|
|
201
|
+
// --- AUTOTEL:BACKEND ---
|
|
202
|
+
import { createDatadogConfig } from 'autotel-backends/datadog';
|
|
203
|
+
|
|
204
|
+
init({
|
|
205
|
+
// --- AUTOTEL:BACKEND_CONFIG ---
|
|
206
|
+
...createDatadogConfig({ apiKey: process.env.DATADOG_API_KEY }),
|
|
207
|
+
// --- AUTOTEL:SUBSCRIBERS_CONFIG ---
|
|
208
|
+
subscribers: [],
|
|
209
|
+
});
|
|
210
|
+
|
|
211
|
+
// --- AUTOTEL:PLUGIN_INIT ---
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
Do not remove these markers if you want `autotel add` to continue working on the file.
|
|
215
|
+
|
|
216
|
+
## Common Mistakes
|
|
217
|
+
|
|
218
|
+
### HIGH — Forgetting `--import` when starting the app
|
|
219
|
+
|
|
220
|
+
```bash
|
|
221
|
+
# Wrong: instrumentation never runs
|
|
222
|
+
node dist/index.js
|
|
223
|
+
|
|
224
|
+
# Correct: register instrumentation before app code loads
|
|
225
|
+
node --import ./src/instrumentation.mts dist/index.js
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
The instrumentation file must be loaded before any other module. The `--import` flag (Node.js 18.19+) is the correct mechanism. `require` or a top-level import inside app code is too late.
|
|
229
|
+
|
|
230
|
+
### HIGH — Running `autotel add` before `autotel init`
|
|
231
|
+
|
|
232
|
+
```bash
|
|
233
|
+
# Wrong: no instrumentation file exists yet
|
|
234
|
+
npx autotel add plugin mongoose
|
|
235
|
+
|
|
236
|
+
# Correct: create the file first
|
|
237
|
+
npx autotel init
|
|
238
|
+
npx autotel add plugin mongoose
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
`add` reads and modifies the existing instrumentation file. It will fail if the file does not exist or is not CLI-owned (use `--force` for user-created files).
|
|
242
|
+
|
|
243
|
+
### MEDIUM — Globbing without quotes
|
|
244
|
+
|
|
245
|
+
```bash
|
|
246
|
+
# Wrong: shell expands the glob before the CLI sees it
|
|
247
|
+
npx autotel codemod trace src/**/*.ts
|
|
248
|
+
|
|
249
|
+
# Correct: quote the glob so the CLI handles expansion
|
|
250
|
+
npx autotel codemod trace "src/**/*.ts"
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
### MEDIUM — Using `--force` on init without understanding the backup
|
|
254
|
+
|
|
255
|
+
`--force` on `init` overwrites an existing instrumentation file but creates a `.bak` backup first. The backup path is logged at `--verbose` level. If you ran `--force` accidentally, check for `instrumentation.mts.bak` in the same directory.
|
|
256
|
+
|
|
257
|
+
### MEDIUM — Using `--dry-run` and expecting installs to have run
|
|
258
|
+
|
|
259
|
+
`--dry-run` implies `--no-install` and `--print-install-cmd`. No files are written and no packages are installed. It is purely a preview mode.
|
|
260
|
+
|
|
261
|
+
## Version
|
|
262
|
+
|
|
263
|
+
Targets autotel-cli v0.8.2. Node.js >= 18.0.0 required (18.19+ for `--import` flag support).
|