autotel-terminal 27.0.0 → 27.0.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "autotel-terminal",
3
- "version": "27.0.0",
3
+ "version": "27.0.1",
4
4
  "description": "Terminal dashboard for autotel traces using react-ink",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -24,7 +24,8 @@
24
24
  "files": [
25
25
  "dist",
26
26
  "src",
27
- "README.md"
27
+ "README.md",
28
+ "skills"
28
29
  ],
29
30
  "keywords": [
30
31
  "autotel",
@@ -0,0 +1,217 @@
1
+ ---
2
+ name: autotel-terminal
3
+ description: >
4
+ Use this skill when integrating the autotel-terminal dashboard into a Node.js app or running it as a standalone OTLP receiver — covers renderTerminal(), StreamingSpanProcessor, the CLI, and the AI assistant configuration.
5
+ ---
6
+
7
+ # autotel-terminal
8
+
9
+ React-Ink powered terminal dashboard for viewing autotel OpenTelemetry spans in real-time. Two modes: embedded in your Node.js process via `renderTerminal()`, or standalone OTLP receiver via the `autotel-terminal` CLI.
10
+
11
+ ## Setup
12
+
13
+ ### Embedded mode (in-process)
14
+
15
+ ```typescript
16
+ import { init, trace } from 'autotel';
17
+ import {
18
+ renderTerminal,
19
+ StreamingSpanProcessor,
20
+ createTerminalSpanStream,
21
+ } from 'autotel-terminal';
22
+
23
+ // Create streaming processor (null = no forwarding, or wrap a BatchSpanProcessor)
24
+ const streamingProcessor = new StreamingSpanProcessor(null);
25
+
26
+ // Initialize autotel with the streaming processor
27
+ init({
28
+ service: 'my-app',
29
+ endpoint: 'http://localhost:4318',
30
+ spanProcessors: [streamingProcessor],
31
+ });
32
+
33
+ // Create stream and launch dashboard
34
+ const stream = createTerminalSpanStream(streamingProcessor);
35
+ renderTerminal({ title: 'My App Traces' }, stream);
36
+ ```
37
+
38
+ ### Standalone CLI (separate terminal)
39
+
40
+ ```bash
41
+ # Start the OTLP receiver dashboard on port 4319
42
+ npx autotel-terminal
43
+
44
+ # Run your app pointing at the dashboard
45
+ OTEL_EXPORTER_OTLP_PROTOCOL=http/json \
46
+ OTEL_EXPORTER_OTLP_ENDPOINT=http://127.0.0.1:4319 \
47
+ node app.js
48
+ ```
49
+
50
+ ## Configuration / Core Patterns
51
+
52
+ ### TerminalOptions
53
+
54
+ ```typescript
55
+ renderTerminal(
56
+ {
57
+ title: 'My App Traces', // Dashboard title
58
+ showStats: true, // Show span count, error rate, avg duration
59
+ maxSpans: 200, // Max spans to display (default: 100)
60
+ colors: true, // Auto-detected from TTY if omitted
61
+ ai: { // Optional AI assistant config
62
+ provider: 'ollama', // 'ollama' | 'openai' | 'openai-compatible'
63
+ model: 'granite4', // Model name
64
+ apiKey: 'sk-...', // For cloud providers
65
+ baseUrl: 'http://...', // Custom endpoint
66
+ },
67
+ },
68
+ stream,
69
+ );
70
+ ```
71
+
72
+ ### StreamingSpanProcessor — wrapping an existing processor
73
+
74
+ Wrap a `BatchSpanProcessor` so spans go to both the terminal dashboard and your OTLP backend:
75
+
76
+ ```typescript
77
+ import { BatchSpanProcessor } from '@opentelemetry/sdk-trace-base';
78
+ import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-http';
79
+ import { StreamingSpanProcessor, createTerminalSpanStream } from 'autotel-terminal';
80
+
81
+ const exporter = new OTLPTraceExporter({ url: 'http://localhost:4318/v1/traces' });
82
+ const batchProcessor = new BatchSpanProcessor(exporter);
83
+ const streamingProcessor = new StreamingSpanProcessor(batchProcessor);
84
+
85
+ // Subscribe manually (without renderTerminal)
86
+ const unsubscribe = streamingProcessor.subscribe((span) => {
87
+ console.log('Span ended:', span.name);
88
+ });
89
+ // Later: unsubscribe()
90
+ ```
91
+
92
+ ### Auto-wire shortcut (no stream needed)
93
+
94
+ If you call `init()` before `renderTerminal()`, autotel-terminal auto-detects the tracer provider:
95
+
96
+ ```typescript
97
+ import { init } from 'autotel';
98
+ import { renderTerminal } from 'autotel-terminal';
99
+
100
+ init({ service: 'my-app' });
101
+ renderTerminal(); // No stream arg — auto-wires from current tracer provider
102
+ ```
103
+
104
+ ### CLI options and environment variables
105
+
106
+ ```bash
107
+ autotel-terminal \
108
+ --port 4319 \ # env: AUTOTEL_TERMINAL_PORT
109
+ --host 127.0.0.1 \ # env: AUTOTEL_TERMINAL_HOST
110
+ --title "My Dashboard" \ # env: AUTOTEL_TERMINAL_TITLE
111
+ --ai-provider ollama \ # env: AI_PROVIDER
112
+ --ai-model granite4 \ # env: AI_MODEL
113
+ --ai-api-key sk-... \ # env: AI_API_KEY
114
+ --ai-base-url http://... # env: AI_BASE_URL
115
+ ```
116
+
117
+ CLI OTLP endpoints (all accept OTLP JSON format):
118
+
119
+ | Endpoint | Signal |
120
+ |---|---|
121
+ | `POST /v1/traces` | Spans streamed into the TUI |
122
+ | `POST /v1/logs` | Logs shown in logs view (`l`) |
123
+ | `POST /v1/metrics` | Acknowledged and counted |
124
+ | `GET /healthz` | Health check |
125
+
126
+ ### AI assistant
127
+
128
+ Auto-detects Ollama (if running locally) or OpenAI (if `OPENAI_API_KEY` is set). Press `a` in the dashboard to toggle the AI panel. The assistant can answer questions about the spans currently visible in the dashboard.
129
+
130
+ ### Dashboard keyboard controls
131
+
132
+ | Key | Action |
133
+ |---|---|
134
+ | `↑/↓` | Navigate |
135
+ | `Enter` | Open selected trace (span tree) |
136
+ | `Esc` | Back / exit search |
137
+ | `t` | Toggle trace view / span list |
138
+ | `l` | Toggle logs view |
139
+ | `v` | Toggle service summary |
140
+ | `E` | Toggle errors view |
141
+ | `/` | Search by span name |
142
+ | `e` | Toggle error-only filter |
143
+ | `p` | Pause / resume live updates |
144
+ | `r` | Record snapshot |
145
+ | `c` | Clear all spans |
146
+ | `J` | Export selected trace as JSON (stdout) |
147
+ | `?` | Show help overlay |
148
+ | `Ctrl+C` | Exit |
149
+
150
+ ## Common Mistakes
151
+
152
+ ### HIGH — Calling renderTerminal() before init()
153
+
154
+ Wrong:
155
+ ```typescript
156
+ renderTerminal({}, stream); // stream is empty, no provider wired
157
+ init({ service: 'my-app', spanProcessors: [streamingProcessor] });
158
+ ```
159
+
160
+ Correct:
161
+ ```typescript
162
+ init({ service: 'my-app', spanProcessors: [streamingProcessor] });
163
+ const stream = createTerminalSpanStream(streamingProcessor);
164
+ renderTerminal({ title: 'My App' }, stream);
165
+ ```
166
+
167
+ Explanation: `init()` must run first so the `StreamingSpanProcessor` is registered with the tracer provider before any spans are created.
168
+
169
+ ### HIGH — Not adding StreamingSpanProcessor to init()
170
+
171
+ Wrong:
172
+ ```typescript
173
+ const streamingProcessor = new StreamingSpanProcessor(null);
174
+ init({ service: 'my-app' }); // streamingProcessor not included
175
+ const stream = createTerminalSpanStream(streamingProcessor);
176
+ renderTerminal({}, stream); // Dashboard shows nothing
177
+ ```
178
+
179
+ Correct:
180
+ ```typescript
181
+ const streamingProcessor = new StreamingSpanProcessor(null);
182
+ init({ service: 'my-app', spanProcessors: [streamingProcessor] });
183
+ ```
184
+
185
+ Explanation: `StreamingSpanProcessor` must be in the `spanProcessors` list passed to `init()` — it is not registered automatically.
186
+
187
+ ### MEDIUM — Using standard OTLP port 4318 for the CLI
188
+
189
+ Wrong:
190
+ ```bash
191
+ npx autotel-terminal --port 4318
192
+ # Now conflicts with any real OTLP collector also on 4318
193
+ ```
194
+
195
+ Correct:
196
+ ```bash
197
+ npx autotel-terminal # Default is 4319, avoids the standard port
198
+ ```
199
+
200
+ Explanation: The CLI defaults to port 4319 deliberately so it does not clash with an existing OTLP collector on 4318.
201
+
202
+ ### MEDIUM — Passing full protocol path to OTEL_EXPORTER_OTLP_ENDPOINT
203
+
204
+ Wrong:
205
+ ```bash
206
+ OTEL_EXPORTER_OTLP_ENDPOINT=http://127.0.0.1:4319/v1/traces
207
+ ```
208
+
209
+ Correct:
210
+ ```bash
211
+ OTEL_EXPORTER_OTLP_ENDPOINT=http://127.0.0.1:4319
212
+ # The SDK appends /v1/traces automatically
213
+ ```
214
+
215
+ ## Version
216
+
217
+ Targets autotel-terminal v17.0.8. Requires `autotel` (peer), `@opentelemetry/api ^1.9.0`, `@opentelemetry/sdk-trace-base ^2.6.0`. Node.js 22+. Uses Ink v6 / React 19 internally.