-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathTaskfile.yml
More file actions
106 lines (90 loc) · 4.16 KB
/
Taskfile.yml
File metadata and controls
106 lines (90 loc) · 4.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
version: "3"
vars:
DATA_DIR: '{{.DATA_DIR | default "./data"}}'
HTTP_PORT: '{{.HTTP_PORT | default "4318"}}'
GRPC_PORT: '{{.GRPC_PORT | default "4317"}}'
COMPACT_OUT: '{{.COMPACT_OUT | default "./data/traces-by-trace.jsonl"}}'
tasks:
default:
desc: List available tasks.
cmds:
- task --list
install:
desc: Install dependencies with bun.
cmds:
- bun install
start:
desc: Run the OTLP interceptor (HTTP on {{.HTTP_PORT}}, gRPC on {{.GRPC_PORT}}).
env:
OTEL_INTERCEPTOR_HTTP_PORT: "{{.HTTP_PORT}}"
OTEL_INTERCEPTOR_GRPC_PORT: "{{.GRPC_PORT}}"
OTEL_INTERCEPTOR_DATA_DIR: "{{.DATA_DIR}}"
cmds:
- bun run src/server.ts
dev:
desc: Run with hot reload on source changes.
env:
OTEL_INTERCEPTOR_HTTP_PORT: "{{.HTTP_PORT}}"
OTEL_INTERCEPTOR_GRPC_PORT: "{{.GRPC_PORT}}"
OTEL_INTERCEPTOR_DATA_DIR: "{{.DATA_DIR}}"
cmds:
- bun --hot run src/server.ts
clean:
desc: Delete all captured NDJSON in the data dir.
cmds:
- rm -rf {{.DATA_DIR}}
- echo "cleaned {{.DATA_DIR}}"
stats:
desc: Show how many traces/metrics/logs payloads have been captured.
cmds:
- |
for f in traces metrics logs; do
path="{{.DATA_DIR}}/$f.ndjson"
if [ -f "$path" ]; then
count=$(wc -l < "$path" | tr -d ' ')
size=$(wc -c < "$path" | tr -d ' ')
printf "%-8s %s payloads (%s bytes)\n" "$f" "$count" "$size"
else
printf "%-8s (empty)\n" "$f"
fi
done
tail:traces:
desc: Follow captured traces NDJSON (pretty-printed).
cmds:
- tail -F {{.DATA_DIR}}/traces.ndjson | bun -e 'process.stdin.on("data", b => { for (const line of b.toString().split("\n")) { if (line.trim()) { try { console.log(JSON.stringify(JSON.parse(line), null, 2)); } catch { console.log(line); } } } })'
tail:metrics:
desc: Follow captured metrics NDJSON (pretty-printed).
cmds:
- tail -F {{.DATA_DIR}}/metrics.ndjson | bun -e 'process.stdin.on("data", b => { for (const line of b.toString().split("\n")) { if (line.trim()) { try { console.log(JSON.stringify(JSON.parse(line), null, 2)); } catch { console.log(line); } } } })'
tail:logs:
desc: Follow captured logs NDJSON (pretty-printed).
cmds:
- tail -F {{.DATA_DIR}}/logs.ndjson | bun -e 'process.stdin.on("data", b => { for (const line of b.toString().split("\n")) { if (line.trim()) { try { console.log(JSON.stringify(JSON.parse(line), null, 2)); } catch { console.log(line); } } } })'
tail:all:
desc: Follow all three NDJSON files, tagged by signal.
cmds:
- tail -F -n 0 {{.DATA_DIR}}/traces.ndjson {{.DATA_DIR}}/metrics.ndjson {{.DATA_DIR}}/logs.ndjson
compact:traces:
desc: Group spans by traceId -> {{.COMPACT_OUT}} (one-shot, traces only).
cmds:
- bun run src/compact-traces.ts --in {{.DATA_DIR}}/traces.ndjson --out {{.COMPACT_OUT}}
compact:all:
desc: Group spans by traceId and attach matching log records (one-shot).
cmds:
- bun run src/compact-traces.ts --in {{.DATA_DIR}}/traces.ndjson --logs {{.DATA_DIR}}/logs.ndjson --out {{.COMPACT_OUT}}
compact:watch:
desc: Watch traces.ndjson and rewrite {{.COMPACT_OUT}} whenever it grows.
cmds:
- bun run src/compact-traces.ts --in {{.DATA_DIR}}/traces.ndjson --out {{.COMPACT_OUT}} --watch
compact:watch:all:
desc: Watch traces.ndjson + logs.ndjson and rewrite {{.COMPACT_OUT}} on changes.
cmds:
- bun run src/compact-traces.ts --in {{.DATA_DIR}}/traces.ndjson --logs {{.DATA_DIR}}/logs.ndjson --out {{.COMPACT_OUT}} --watch
smoke:
desc: Send a test span via HTTP/JSON to verify the server is up.
cmds:
- |
curl -sS -X POST http://localhost:{{.HTTP_PORT}}/v1/traces \
-H 'content-type: application/json' \
-d '{"resourceSpans":[{"resource":{"attributes":[{"key":"service.name","value":{"stringValue":"taskfile-smoke"}}]},"scopeSpans":[{"spans":[{"traceId":"0102030405060708090a0b0c0d0e0f10","spanId":"1112131415161718","name":"smoke","startTimeUnixNano":"1700000000000000000","endTimeUnixNano":"1700000001000000000"}]}]}]}'
echo " -> wrote to {{.DATA_DIR}}/traces.ndjson"