autotel-cloudflare 2.19.0 → 3.1.0
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/README.md +41 -0
- package/dist/agents.d.ts +626 -123
- package/dist/agents.d.ts.map +1 -1
- package/dist/agents.js +253 -171
- package/dist/agents.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +40 -2
- package/dist/index.js.map +1 -1
- package/dist/native-tracing-D0EyAtsF.js +33 -0
- package/dist/native-tracing-D0EyAtsF.js.map +1 -0
- package/dist/native-tracing-DSo5mody.d.ts +21 -0
- package/dist/native-tracing-DSo5mody.d.ts.map +1 -0
- package/dist/native.d.ts +2 -0
- package/dist/native.js +3 -0
- package/package.json +7 -3
- package/src/agents/agent.ts +327 -0
- package/src/agents/base.ts +26 -0
- package/src/agents/index.ts +5 -1
- package/src/agents/mcp.ts +38 -0
- package/src/agents/observability.ts +145 -0
- package/src/agents/otel-observability.test.ts +165 -232
- package/src/agents/otel-observability.ts +350 -267
- package/src/agents/types.ts +26 -132
- package/src/agents.ts +17 -6
- package/src/index.ts +8 -0
- package/src/native/native-tracing.test.ts +54 -0
- package/src/native/native-tracing.ts +83 -0
- package/src/native.ts +12 -0
- package/src/wrappers/instrument.ts +83 -5
- package/src/wrappers/native-instrument.test.ts +153 -0
package/README.md
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
## Features
|
|
10
10
|
|
|
11
|
+
- ✅ **Cloudflare native tracing (automatic)** - `trace()`/`span()` nest inside Cloudflare's native trace waterfall when enabled; no duplicate spans, no exporter code
|
|
11
12
|
- ✅ **Native Cloudflare OTel integration** - Works with `wrangler.toml` destinations
|
|
12
13
|
- ✅ **Complete bindings coverage** - KV, R2, D1, DO, AI, Vectorize, Hyperdrive, and more
|
|
13
14
|
- ✅ **Multiple API styles** - `instrument()`, `wrapModule()`, `wrapDurableObject()`, functional
|
|
@@ -27,6 +28,46 @@ The package direction is to make Cloudflare observability feel the same across W
|
|
|
27
28
|
|
|
28
29
|
See [docs/CLOUDFLARE-DX.md](../../docs/CLOUDFLARE-DX.md) for the design target and review rules.
|
|
29
30
|
|
|
31
|
+
## Cloudflare native tracing (automatic)
|
|
32
|
+
|
|
33
|
+
Cloudflare Workers ship [native tracing](https://developers.cloudflare.com/workers/observability/traces/): enable it in Wrangler and Cloudflare instruments fetch/KV/R2/D1/handlers and exports OTLP to any backend — no exporter code. autotel integrates **automatically**: the same `trace()`/`span()`/`enterSpan()` code nests inside Cloudflare's native waterfall when native tracing is on, and falls back to autotel's own OTLP pipeline everywhere else (other edge runtimes, native off, local `wrangler dev`).
|
|
34
|
+
|
|
35
|
+
```toml
|
|
36
|
+
# wrangler.toml — that's the only setup
|
|
37
|
+
[observability.traces]
|
|
38
|
+
enabled = true
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
When native tracing is active, autotel **defers to the platform**: it does not proxy-instrument bindings (no duplicate spans) and does not run its own exporter. It routes your custom spans to `tracing.enterSpan()` and surfaces the `cf-ray` id as `ctx.correlationId` + a `correlation.id` span attribute. Controlled by `nativeTracing: 'auto' | 'on' | 'off'` (default `'auto'`).
|
|
42
|
+
|
|
43
|
+
### Same code, both modes — captured evidence
|
|
44
|
+
|
|
45
|
+
This is real output from [`apps/cloudflare-example`](../../apps/cloudflare-example) (`node scripts/capture-evidence.mjs`). Identical business logic, two runtimes:
|
|
46
|
+
|
|
47
|
+
```text
|
|
48
|
+
# autotel OTLP pipeline (local dev / non-Workers / nativeTracing:'off')
|
|
49
|
+
• GET /orders
|
|
50
|
+
• order.price order.id=ORD-1 order.total=120
|
|
51
|
+
• order.subtotal order.subtotal=100
|
|
52
|
+
• KV MY_KV: get db.system=cloudflare-kv db.operation=get ← autotel-instrumented
|
|
53
|
+
• order.total order.total=120
|
|
54
|
+
• user.create user.duplicate=true
|
|
55
|
+
• db.checkDuplicate
|
|
56
|
+
• payment.charge [ERROR] exception.message="card declined"
|
|
57
|
+
|
|
58
|
+
# Cloudflare native tracing (autotel → ctx.tracing.enterSpan)
|
|
59
|
+
• order.price [OK] correlation.id=8f1c2d3e…-LHR order.id=ORD-1 order.total=120
|
|
60
|
+
• order.subtotal correlation.id=8f1c2d3e…-LHR order.subtotal=100
|
|
61
|
+
• order.total correlation.id=8f1c2d3e…-LHR order.total=120
|
|
62
|
+
• user.create correlation.id=8f1c2d3e…-LHR user.duplicate=true
|
|
63
|
+
• db.checkDuplicate
|
|
64
|
+
• payment.charge [ERROR] error=true exception.message="card declined" correlation.id=8f1c2d3e…-LHR
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
Note the native tree has **no `KV MY_KV: get` span** — Cloudflare emits that natively (your custom spans nest above it on deploy), so there are no duplicates.
|
|
68
|
+
|
|
69
|
+
Full details, degradation map, and the forward-compatible trace-id story: [docs/CLOUDFLARE-NATIVE-TRACING.md](../../docs/CLOUDFLARE-NATIVE-TRACING.md).
|
|
70
|
+
|
|
30
71
|
## Installation
|
|
31
72
|
|
|
32
73
|
```bash
|