autotel 2.22.0 → 2.23.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/README.md +112 -6
- package/bin/intent.js +6 -0
- package/dist/auto.cjs +3 -3
- package/dist/auto.js +2 -2
- package/dist/{chunk-EWH2542B.js → chunk-3AMR5XLZ.js} +3 -3
- package/dist/{chunk-EWH2542B.js.map → chunk-3AMR5XLZ.js.map} +1 -1
- package/dist/chunk-3QXBFGKP.js +344 -0
- package/dist/chunk-3QXBFGKP.js.map +1 -0
- package/dist/{chunk-VQFF2WMP.cjs → chunk-3ZFDJJWZ.cjs} +37 -29
- package/dist/chunk-3ZFDJJWZ.cjs.map +1 -0
- package/dist/{chunk-CQC6RVLR.cjs → chunk-4RZ4JUBY.cjs} +5 -5
- package/dist/{chunk-CQC6RVLR.cjs.map → chunk-4RZ4JUBY.cjs.map} +1 -1
- package/dist/{chunk-PAVYKPCQ.js → chunk-5XUEHX7J.js} +3 -3
- package/dist/{chunk-PAVYKPCQ.js.map → chunk-5XUEHX7J.js.map} +1 -1
- package/dist/chunk-6S5RUKU3.cjs +347 -0
- package/dist/chunk-6S5RUKU3.cjs.map +1 -0
- package/dist/{chunk-BS757SL2.js → chunk-724XLWR3.js} +9 -4
- package/dist/chunk-724XLWR3.js.map +1 -0
- package/dist/chunk-7EQ4G4SI.cjs +146 -0
- package/dist/chunk-7EQ4G4SI.cjs.map +1 -0
- package/dist/{chunk-CQP5SQT4.cjs → chunk-AXFWWJF3.cjs} +7 -7
- package/dist/{chunk-CQP5SQT4.cjs.map → chunk-AXFWWJF3.cjs.map} +1 -1
- package/dist/{chunk-7NH625MS.cjs → chunk-BSZP4URK.cjs} +5 -5
- package/dist/{chunk-7NH625MS.cjs.map → chunk-BSZP4URK.cjs.map} +1 -1
- package/dist/{chunk-GZFH6P5U.js → chunk-GY4CRZSV.js} +14 -6
- package/dist/chunk-GY4CRZSV.js.map +1 -0
- package/dist/{chunk-QKUGUDXJ.cjs → chunk-HSEIUH7F.cjs} +10 -5
- package/dist/chunk-HSEIUH7F.cjs.map +1 -0
- package/dist/{chunk-DTW3WB7Z.js → chunk-IPKXURBW.js} +3 -3
- package/dist/{chunk-DTW3WB7Z.js.map → chunk-IPKXURBW.js.map} +1 -1
- package/dist/chunk-J7VGRIAJ.js +64 -0
- package/dist/chunk-J7VGRIAJ.js.map +1 -0
- package/dist/chunk-KFOHQK7X.js +144 -0
- package/dist/chunk-KFOHQK7X.js.map +1 -0
- package/dist/{chunk-4UYR46UP.cjs → chunk-MSUHW2I4.cjs} +13 -13
- package/dist/{chunk-4UYR46UP.cjs.map → chunk-MSUHW2I4.cjs.map} +1 -1
- package/dist/chunk-T4B5LB6E.cjs +66 -0
- package/dist/chunk-T4B5LB6E.cjs.map +1 -0
- package/dist/{chunk-QHT4MUED.js → chunk-WCIIFRGL.js} +3 -3
- package/dist/{chunk-QHT4MUED.js.map → chunk-WCIIFRGL.js.map} +1 -1
- package/dist/decorators.cjs +3 -3
- package/dist/decorators.js +3 -3
- package/dist/drain-pipeline.cjs +13 -0
- package/dist/drain-pipeline.cjs.map +1 -0
- package/dist/drain-pipeline.d.cts +37 -0
- package/dist/drain-pipeline.d.ts +37 -0
- package/dist/drain-pipeline.js +4 -0
- package/dist/drain-pipeline.js.map +1 -0
- package/dist/enrichers.cjs +90 -0
- package/dist/enrichers.cjs.map +1 -0
- package/dist/enrichers.d.cts +23 -0
- package/dist/enrichers.d.ts +23 -0
- package/dist/enrichers.js +86 -0
- package/dist/enrichers.js.map +1 -0
- package/dist/event.cjs +6 -6
- package/dist/event.js +3 -3
- package/dist/functional.cjs +10 -10
- package/dist/functional.js +3 -3
- package/dist/index.cjs +274 -41
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +73 -3
- package/dist/index.d.ts +73 -3
- package/dist/index.js +227 -11
- package/dist/index.js.map +1 -1
- package/dist/{init-BMiXSJNM.d.cts → init-BC5aN8bh.d.cts} +18 -0
- package/dist/{init-ByRbNTRo.d.ts → init-_FG4IbhF.d.ts} +18 -0
- package/dist/instrumentation.cjs +9 -9
- package/dist/instrumentation.js +2 -2
- package/dist/messaging.cjs +7 -7
- package/dist/messaging.js +4 -4
- package/dist/parse-error.cjs +13 -0
- package/dist/parse-error.cjs.map +1 -0
- package/dist/parse-error.d.cts +13 -0
- package/dist/parse-error.d.ts +13 -0
- package/dist/parse-error.js +4 -0
- package/dist/parse-error.js.map +1 -0
- package/dist/processors.cjs +2 -2
- package/dist/processors.d.cts +40 -4
- package/dist/processors.d.ts +40 -4
- package/dist/processors.js +1 -1
- package/dist/semantic-helpers.cjs +8 -8
- package/dist/semantic-helpers.js +4 -4
- package/dist/webhook.cjs +4 -4
- package/dist/webhook.js +3 -3
- package/dist/workflow-distributed.cjs +5 -5
- package/dist/workflow-distributed.js +3 -3
- package/dist/workflow.cjs +8 -8
- package/dist/workflow.js +4 -4
- package/dist/yaml-config.d.cts +2 -1
- package/dist/yaml-config.d.ts +2 -1
- package/package.json +55 -33
- package/skills/autotel-core/SKILL.md +162 -0
- package/skills/autotel-events/SKILL.md +88 -0
- package/skills/autotel-frameworks/SKILL.md +97 -0
- package/skills/autotel-instrumentation/SKILL.md +125 -0
- package/skills/autotel-request-logging/SKILL.md +100 -0
- package/skills/autotel-structured-errors/SKILL.md +130 -0
- package/src/drain-pipeline.test.ts +68 -0
- package/src/drain-pipeline.ts +199 -0
- package/src/enrichers.test.ts +150 -0
- package/src/enrichers.ts +145 -0
- package/src/flatten-attributes.test.ts +76 -0
- package/src/flatten-attributes.ts +80 -0
- package/src/functional.test.ts +63 -0
- package/src/functional.ts +11 -3
- package/src/index.ts +34 -0
- package/src/init.ts +22 -0
- package/src/package-manifest.test.ts +24 -0
- package/src/parse-error.test.ts +73 -0
- package/src/parse-error.ts +112 -0
- package/src/pretty-log-formatter.test.ts +123 -0
- package/src/pretty-log-formatter.ts +210 -0
- package/src/processors/canonical-log-line-processor.test.ts +81 -25
- package/src/processors/canonical-log-line-processor.ts +130 -42
- package/src/request-logger.test.ts +137 -0
- package/src/request-logger.ts +150 -0
- package/src/structured-error.test.ts +106 -0
- package/src/structured-error.ts +97 -0
- package/dist/chunk-2RQDNGV3.js +0 -126
- package/dist/chunk-2RQDNGV3.js.map +0 -1
- package/dist/chunk-BS757SL2.js.map +0 -1
- package/dist/chunk-GZFH6P5U.js.map +0 -1
- package/dist/chunk-ONK2Y22L.cjs +0 -128
- package/dist/chunk-ONK2Y22L.cjs.map +0 -1
- package/dist/chunk-QKUGUDXJ.cjs.map +0 -1
- package/dist/chunk-VQFF2WMP.cjs.map +0 -1
package/README.md
CHANGED
|
@@ -76,6 +76,9 @@ Replace `NODE_OPTIONS` and 30+ lines of SDK boilerplate with `init()`, wrap func
|
|
|
76
76
|
- [What You Get](#what-you-get)
|
|
77
77
|
- [Query Examples](#query-examples)
|
|
78
78
|
- [Configuration Options](#configuration-options)
|
|
79
|
+
- [Request Logger DX](#request-logger-dx)
|
|
80
|
+
- [Drain Pipeline (Batch + Retry + Flush)](#drain-pipeline-batch--retry--flush)
|
|
81
|
+
- [parseError (Frontend/API Consumers)](#parseerror-frontendapi-consumers)
|
|
79
82
|
- [Auto Instrumentation \& Advanced Configuration](#auto-instrumentation--advanced-configuration)
|
|
80
83
|
- [⚠️ autoInstrumentations vs. Manual Instrumentations](#️-autoinstrumentations-vs-manual-instrumentations)
|
|
81
84
|
- [Option A: Auto-instrumentations only (all defaults)](#option-a-auto-instrumentations-only-all-defaults)
|
|
@@ -1504,7 +1507,7 @@ export const processCheckout = trace((ctx) => async (order: Order) => {
|
|
|
1504
1507
|
|
|
1505
1508
|
When a span ends, a canonical log line is automatically emitted with:
|
|
1506
1509
|
|
|
1507
|
-
- **Core fields**: `operation`, `traceId`, `spanId`, `correlationId`, `duration_ms`, `status_code`
|
|
1510
|
+
- **Core fields**: `operation`, `traceId`, `spanId`, `correlationId`, `duration_ms`, `duration`, `status_code`
|
|
1508
1511
|
- **ALL span attributes**: Every attribute you set with `ctx.setAttribute()`
|
|
1509
1512
|
- **Resource attributes**: `service.name`, `service.version`, `deployment.environment`
|
|
1510
1513
|
- **Timestamp**: ISO 8601 format
|
|
@@ -1520,6 +1523,7 @@ When a span ends, a canonical log line is automatically emitted with:
|
|
|
1520
1523
|
"spanId": "00f067aa0ba902b7",
|
|
1521
1524
|
"correlationId": "4bf92f3577b34da",
|
|
1522
1525
|
"duration_ms": 124.7,
|
|
1526
|
+
"duration": "125ms",
|
|
1523
1527
|
"status_code": 1,
|
|
1524
1528
|
"user.id": "user-123",
|
|
1525
1529
|
"user.subscription": "premium",
|
|
@@ -1561,17 +1565,119 @@ init({
|
|
|
1561
1565
|
service: 'my-app',
|
|
1562
1566
|
canonicalLogLines: {
|
|
1563
1567
|
enabled: true,
|
|
1564
|
-
rootSpansOnly: true,
|
|
1565
|
-
minLevel: 'info',
|
|
1566
|
-
logger: pino(),
|
|
1568
|
+
rootSpansOnly: true,
|
|
1569
|
+
minLevel: 'info',
|
|
1570
|
+
logger: pino(),
|
|
1571
|
+
pretty: true, // tree-formatted console output (defaults to NODE_ENV=development)
|
|
1572
|
+
keep: [{ status: 500 }, { durationMs: 1000 }], // declarative tail sampling
|
|
1573
|
+
shouldEmit: ({ event }) => {
|
|
1574
|
+
// or use a custom predicate (overrides keep)
|
|
1575
|
+
const isError = Number(event.status_code) === 2;
|
|
1576
|
+
const isSlow = Number(event.duration_ms ?? 0) >= 1000;
|
|
1577
|
+
return isError || isSlow || Math.random() < 0.1;
|
|
1578
|
+
},
|
|
1579
|
+
drain: async ({ event }) => {
|
|
1580
|
+
await fetch('https://logs.example.com/ingest', {
|
|
1581
|
+
method: 'POST',
|
|
1582
|
+
body: JSON.stringify(event),
|
|
1583
|
+
});
|
|
1584
|
+
},
|
|
1567
1585
|
messageFormat: (span) => {
|
|
1568
|
-
// Custom message format
|
|
1569
1586
|
const status = span.status.code === 2 ? 'ERROR' : 'SUCCESS';
|
|
1570
1587
|
return `${span.name} [${status}]`;
|
|
1571
1588
|
},
|
|
1572
|
-
includeResourceAttributes: true,
|
|
1589
|
+
includeResourceAttributes: true,
|
|
1590
|
+
},
|
|
1591
|
+
});
|
|
1592
|
+
```
|
|
1593
|
+
|
|
1594
|
+
### Request Logger DX
|
|
1595
|
+
|
|
1596
|
+
For teams that prefer `log.set({...})` ergonomics, you can use `getRequestLogger()`.
|
|
1597
|
+
It writes directly to span attributes/events, so canonical log lines still emit one
|
|
1598
|
+
wide event per request.
|
|
1599
|
+
|
|
1600
|
+
```typescript
|
|
1601
|
+
import { trace, getRequestLogger, createStructuredError } from 'autotel';
|
|
1602
|
+
|
|
1603
|
+
export const checkout = trace((ctx) => async (order: Order) => {
|
|
1604
|
+
const log = getRequestLogger(ctx);
|
|
1605
|
+
|
|
1606
|
+
log.set({ user: { id: order.userId, plan: order.plan } });
|
|
1607
|
+
log.set({
|
|
1608
|
+
cart: { total_cents: order.totalCents, item_count: order.items.length },
|
|
1609
|
+
});
|
|
1610
|
+
|
|
1611
|
+
try {
|
|
1612
|
+
await processPayment(order);
|
|
1613
|
+
} catch (cause) {
|
|
1614
|
+
log.error(
|
|
1615
|
+
createStructuredError({
|
|
1616
|
+
message: 'Payment failed',
|
|
1617
|
+
why: 'Card declined by issuer',
|
|
1618
|
+
fix: 'Try another payment method',
|
|
1619
|
+
link: 'https://docs.example.com/errors/payment-declined',
|
|
1620
|
+
cause,
|
|
1621
|
+
}),
|
|
1622
|
+
{ step: 'payment' },
|
|
1623
|
+
);
|
|
1624
|
+
throw cause;
|
|
1625
|
+
}
|
|
1626
|
+
});
|
|
1627
|
+
```
|
|
1628
|
+
|
|
1629
|
+
You also get:
|
|
1630
|
+
|
|
1631
|
+
- `log.getContext()` to inspect the accumulated request context.
|
|
1632
|
+
- `log.emitNow(overrides?)` to capture an immediate snapshot (adds a span event
|
|
1633
|
+
and returns `{ timestamp, traceId, spanId, correlationId, context }`).
|
|
1634
|
+
|
|
1635
|
+
### Drain Pipeline (Batch + Retry + Flush)
|
|
1636
|
+
|
|
1637
|
+
If you want batching/retry behavior for canonical drains, wrap `drain`
|
|
1638
|
+
with `createDrainPipeline()` style logging:
|
|
1639
|
+
|
|
1640
|
+
```typescript
|
|
1641
|
+
import { createDrainPipeline, init } from 'autotel';
|
|
1642
|
+
|
|
1643
|
+
const pipeline = createDrainPipeline({
|
|
1644
|
+
batch: { size: 50, intervalMs: 2000 },
|
|
1645
|
+
retry: { maxAttempts: 3, backoff: 'exponential' },
|
|
1646
|
+
maxBufferSize: 1000,
|
|
1647
|
+
});
|
|
1648
|
+
|
|
1649
|
+
const drain = pipeline(async (batch) => {
|
|
1650
|
+
await fetch('https://logs.example.com/ingest', {
|
|
1651
|
+
method: 'POST',
|
|
1652
|
+
body: JSON.stringify(batch.map((ctx) => ctx.event)),
|
|
1653
|
+
});
|
|
1654
|
+
});
|
|
1655
|
+
|
|
1656
|
+
init({
|
|
1657
|
+
service: 'my-app',
|
|
1658
|
+
canonicalLogLines: {
|
|
1659
|
+
enabled: true,
|
|
1660
|
+
rootSpansOnly: true,
|
|
1661
|
+
drain,
|
|
1573
1662
|
},
|
|
1574
1663
|
});
|
|
1664
|
+
|
|
1665
|
+
await drain.flush();
|
|
1666
|
+
```
|
|
1667
|
+
|
|
1668
|
+
### parseError (Frontend/API Consumers)
|
|
1669
|
+
|
|
1670
|
+
Use `parseError()` to normalize unknown caught errors into a stable shape:
|
|
1671
|
+
|
|
1672
|
+
```typescript
|
|
1673
|
+
import { parseError } from 'autotel';
|
|
1674
|
+
|
|
1675
|
+
try {
|
|
1676
|
+
await api.checkout(order);
|
|
1677
|
+
} catch (error) {
|
|
1678
|
+
const parsed = parseError(error);
|
|
1679
|
+
showError(parsed.message, parsed.why, parsed.fix);
|
|
1680
|
+
}
|
|
1575
1681
|
```
|
|
1576
1682
|
|
|
1577
1683
|
## Auto Instrumentation & Advanced Configuration
|
package/bin/intent.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Auto-generated by @tanstack/intent setup
|
|
3
|
+
// Exposes the intent end-user CLI for consumers of this library.
|
|
4
|
+
// Commit this file, then add to your package.json:
|
|
5
|
+
// "bin": { "intent": "./bin/intent.js" }
|
|
6
|
+
await import('@tanstack/intent/intent-library');
|
package/dist/auto.cjs
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkHSEIUH7F_cjs = require('./chunk-HSEIUH7F.cjs');
|
|
4
4
|
var chunk6YIDHH2S_cjs = require('./chunk-6YIDHH2S.cjs');
|
|
5
5
|
require('./chunk-GVLK7YUU.cjs');
|
|
6
6
|
require('./chunk-ZNMBW67B.cjs');
|
|
7
7
|
require('./chunk-IOYFAFHJ.cjs');
|
|
8
8
|
require('./chunk-ELW34S4C.cjs');
|
|
9
9
|
require('./chunk-CU6IDACR.cjs');
|
|
10
|
-
require('./chunk-
|
|
10
|
+
require('./chunk-6S5RUKU3.cjs');
|
|
11
11
|
require('./chunk-YS6C2YJE.cjs');
|
|
12
12
|
require('./chunk-BGVKKL2N.cjs');
|
|
13
13
|
require('./chunk-AZ24DJAG.cjs');
|
|
@@ -23,7 +23,7 @@ module$1.register("import-in-the-middle/hook.mjs", (typeof document === 'undefin
|
|
|
23
23
|
var yamlConfig = chunk6YIDHH2S_cjs.loadYamlConfig();
|
|
24
24
|
var autoInstrumentationsEnv = process.env.AUTOTEL_INTEGRATIONS;
|
|
25
25
|
var autoInstrumentations = autoInstrumentationsEnv === "true" ? true : autoInstrumentationsEnv ? autoInstrumentationsEnv.split(",").map((s) => s.trim()) : yamlConfig?.autoInstrumentations ?? ["http", "express"];
|
|
26
|
-
|
|
26
|
+
chunkHSEIUH7F_cjs.init({
|
|
27
27
|
service: yamlConfig?.service ?? process.env.OTEL_SERVICE_NAME ?? "unknown-service",
|
|
28
28
|
debug: yamlConfig?.debug ?? process.env.AUTOTEL_DEBUG === "true",
|
|
29
29
|
autoInstrumentations
|
package/dist/auto.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { init } from './chunk-
|
|
1
|
+
import { init } from './chunk-724XLWR3.js';
|
|
2
2
|
import { loadYamlConfig } from './chunk-YTGF4L2C.js';
|
|
3
3
|
import './chunk-X4RMFFMR.js';
|
|
4
4
|
import './chunk-WGWSHJ2N.js';
|
|
5
5
|
import './chunk-GYR5K654.js';
|
|
6
6
|
import './chunk-SNINLBEE.js';
|
|
7
7
|
import './chunk-6UQRVUN3.js';
|
|
8
|
-
import './chunk-
|
|
8
|
+
import './chunk-3QXBFGKP.js';
|
|
9
9
|
import './chunk-33WTKH7X.js';
|
|
10
10
|
import './chunk-XND7WBVX.js';
|
|
11
11
|
import './chunk-B33XPEKY.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { trace } from './chunk-
|
|
1
|
+
import { trace } from './chunk-GY4CRZSV.js';
|
|
2
2
|
import { extractLinksFromBatch, createLinkFromHeaders } from './chunk-XND7WBVX.js';
|
|
3
3
|
import { SpanKind, propagation, context } from '@opentelemetry/api';
|
|
4
4
|
|
|
@@ -790,5 +790,5 @@ function clearOrderingState() {
|
|
|
790
790
|
}
|
|
791
791
|
|
|
792
792
|
export { clearOrderingState, traceConsumer, traceProducer };
|
|
793
|
-
//# sourceMappingURL=chunk-
|
|
794
|
-
//# sourceMappingURL=chunk-
|
|
793
|
+
//# sourceMappingURL=chunk-3AMR5XLZ.js.map
|
|
794
|
+
//# sourceMappingURL=chunk-3AMR5XLZ.js.map
|