@adhd/apigen-plugin-tracing 0.1.0 → 0.2.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/CHANGELOG.md +15 -0
- package/README.md +10 -7
- package/index.js +1 -1
- package/index.mjs +89 -36
- package/lib/plugin.d.ts +42 -13
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# @adhd/apigen-plugin-tracing
|
|
2
2
|
|
|
3
|
+
## 0.2.0 (2026-10-01)
|
|
4
|
+
|
|
5
|
+
### ⚠️ Breaking Changes
|
|
6
|
+
|
|
7
|
+
- **apigen-plugin-tracing:** `makeTracingPlugin(opts)` / `makeTraceLayer(opts)` now REQUIRE
|
|
8
|
+
`opts.serviceName` (previously the options object defaulted to `{}` with an implicit `'apigen'`
|
|
9
|
+
namespace). Reserved span attribute and event keys changed from `apigen.op` / `apigen.transport` /
|
|
10
|
+
`apigen.op.error` to `<serviceName>.op` / `<serviceName>.transport` / `<serviceName>.op.error`.
|
|
11
|
+
Every consumer must now pass an explicit `serviceName` (adhd products pass `'adhd'`) and read the
|
|
12
|
+
namespaced keys. 0.x breaking ⇒ minor.
|
|
13
|
+
|
|
14
|
+
### ❤️ Thank You
|
|
15
|
+
|
|
16
|
+
- pseudosky
|
|
17
|
+
|
|
3
18
|
## 0.1.0
|
|
4
19
|
|
|
5
20
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -50,11 +50,13 @@ apigen run --source ./api.ts --type tracing
|
|
|
50
50
|
```ts
|
|
51
51
|
import { tracingPlugin, makeTracingPlugin, TraceHandle } from '@adhd/apigen-plugin-tracing';
|
|
52
52
|
|
|
53
|
-
//
|
|
53
|
+
// apigen's own singleton — span prefix `apigen` (for apigen's CLI and self-test only).
|
|
54
|
+
// adhd products must NOT use this: they pass their own namespace explicitly (see below).
|
|
54
55
|
run({ usePlugins: [tracingPlugin] });
|
|
55
56
|
|
|
56
|
-
// `makeTracingPlugin(...)` is the configured entry point —
|
|
57
|
-
//
|
|
57
|
+
// `makeTracingPlugin(...)` is the configured entry point — `serviceName` is REQUIRED (no
|
|
58
|
+
// implicit default) and is the namespace every emitted span/record/attribute is prefixed
|
|
59
|
+
// with. Pass your product's namespace (e.g. `adhd`), plus any envelope headers to copy.
|
|
58
60
|
|
|
59
61
|
// configured
|
|
60
62
|
run({
|
|
@@ -82,16 +84,17 @@ export async function placeOrder(call, ...args) {
|
|
|
82
84
|
```
|
|
83
85
|
|
|
84
86
|
`annotate` is a no-op when the operation is not currently inside a unary span (e.g. before the
|
|
85
|
-
downstream resolved, or
|
|
87
|
+
downstream resolved, or after the span has closed). A streaming call is still spanned — as a
|
|
88
|
+
unary span covering only the point the stream is obtained (see [Records](#records)).
|
|
86
89
|
|
|
87
90
|
## Records
|
|
88
91
|
|
|
89
92
|
| Event | Level | Carries |
|
|
90
93
|
|---|---|---|
|
|
91
|
-
| `<serviceName>.<op>.start` | info |
|
|
94
|
+
| `<serviceName>.<op>.start` | info | `<serviceName>.op`, `<serviceName>.transport`, `trace_id` |
|
|
92
95
|
| `<serviceName>.<op>.finish` | info | the above + `duration_ms` |
|
|
93
96
|
| `<serviceName>.<op>.error` | error | the above + `error` (the thrown message) |
|
|
94
|
-
|
|
|
97
|
+
| `<serviceName>.op.error` | error | `<serviceName>.op`, `<serviceName>.transport`, `trace_id`, `span`, `duration_ms`, `err` |
|
|
95
98
|
|
|
96
99
|
Streaming operations are **quarantined**: under the current `Next` contract
|
|
97
100
|
(`() => Promise<LayerResult>`), an `AsyncIterable` can only be a *resolved* value, never an
|
|
@@ -104,7 +107,7 @@ future reopen-span follow-up; `traceUnary` is the only layer path.
|
|
|
104
107
|
|
|
105
108
|
| Option | Type | Default | Description |
|
|
106
109
|
|---|---|---|---|
|
|
107
|
-
| `serviceName` | `string` |
|
|
110
|
+
| `serviceName` | `string` | _(required)_ | Span / record / attribute name prefix — the emitting product's namespace (e.g. `adhd`). |
|
|
108
111
|
| `envelopeAttrs` | `string[]` | `[]` | Extra `call.envelope` keys copied verbatim onto each span. |
|
|
109
112
|
|
|
110
113
|
## Part of the apigen toolchain
|
package/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});let e=require("@adhd/sox-telemetry");var t=class{constructor(e,t,n){this.traceId=e,this.spanName=t,this.startedAt=n}annotate(e){let t=
|
|
1
|
+
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});let e=require("node:crypto"),t=require("node:fs"),n=require("node:child_process"),r=require("node:path"),i=require("@adhd/sox-telemetry");function a(e){try{let t=(0,n.spawnSync)(`git`,[`rev-parse`,...e],{cwd:process.cwd(),encoding:`utf8`,timeout:2e3});if(t.status===0&&t.stdout){let e=t.stdout.trim();return e.length>0?e:null}}catch{}return null}function o(){let n=process.argv[1];if(n===void 0)return null;try{return`sha256:${(0,e.createHash)(`sha256`).update((0,t.readFileSync)(n)).digest(`hex`)}`}catch{return null}}function s(){let e=a([`--show-toplevel`]),t=a([`--path-format=absolute`,`--git-common-dir`]);return e===null||t===null?`none`:/[\\/]\.git$/.test(t)&&(0,r.resolve)((0,r.dirname)(t))!==(0,r.resolve)(e)?`linked`:`main`}var c=null;function l(){if(c===null){let t=process.env.ADHD_SESSION_ID,n=process.env.npm_package_version;c={sessionId:t!==void 0&&t.length>0?t:(0,e.randomUUID)(),worktree:s(),release:{version:n!==void 0&&n.length>0?n:null,gitSha:a([`HEAD`]),artifactSha256:o()}}}return c}var u=class{constructor(e,t,n){this.traceId=e,this.spanName=t,this.startedAt=n}annotate(e){let t=d.get(this);t!==void 0&&t.setAttributes(f(e))}},d=new WeakMap;function f(e){let t={};for(let[n,r]of Object.entries(e))(typeof r==`string`||typeof r==`number`||typeof r==`boolean`)&&(t[n]=r);return t}function p(e,t){let n={};for(let r of t){let t=e[r];t!==void 0&&(n[r]=t)}return n}function m(e){return e instanceof Error?e.message:typeof e==`string`?e:typeof e==`object`&&e&&`message`in e&&typeof e.message==`string`?e.message:String(e)}function h(e,t,n,r,a){return(0,i.withSpan)(t,f(n),async o=>{d.set(r,o);try{return await e}catch(e){throw i.log.error(`${a}.op.error`,{...n,span:t,duration_ms:Date.now()-r.startedAt,err:m(e)}),e}finally{d.delete(r)}})}function g(e){let t=e.serviceName;if(typeof t!=`string`||t.trim()===``)throw Error('@adhd/apigen-plugin-tracing: `serviceName` is required and must be a non-empty string — it namespaces every span name, attribute key, and error record. Construct the plugin explicitly, e.g. `makeTracingPlugin({ serviceName: "adhd" })`.');let n=e.envelopeAttrs??[];return(e,r)=>{let a=`${t}.${e.operation.id}`,o=(0,i.currentTraceId)()??(0,i.newTraceId)(),s=new u(o,a,Date.now());e.ctx.set(u,s);let c=l(),d={...p(e.envelope,n),[`${t}.op`]:e.operation.id,[`${t}.transport`]:e.transport,trace_id:o,session_id:c.sessionId,worktree:c.worktree,role:(0,i.currentRuntimeState)().role};return c.release.version!==null&&(d[`release.version`]=c.release.version),c.release.gitSha!==null&&(d[`release.git_sha`]=c.release.gitSha),c.release.artifactSha256!==null&&(d[`release.artifact_sha256`]=c.release.artifactSha256),(0,i.withTrace)(o,()=>h(Promise.resolve(r()),a,d,s,t))}}var _={id:`tracing`,description:`Layer plugin: emits one OTel span per dispatched operation (op id, transport, outcome, duration) to the sox-telemetry JSONL sink, correlated by trace_id.`,language:`ts`,optionsSchema:{type:`object`,properties:{serviceName:{type:`string`,description:`Span / record / attribute name prefix. REQUIRED — the emitting product namespace (e.g. adhd).`},envelopeAttrs:{type:`array`,items:{type:`string`},description:`Extra envelope keys copied verbatim onto each span. Default: [].`}},required:[`serviceName`],additionalProperties:!1},capabilities:{target:{name:`tracing`,generate(){return[]}},layer:{layer:g({serviceName:`apigen`})}}};function v(e){return{..._,capabilities:{..._.capabilities,layer:{layer:g(e)}}}}exports.TraceHandle=u,exports.default=_,exports.tracingPlugin=_,exports.makeTracingPlugin=v;
|
package/index.mjs
CHANGED
|
@@ -1,20 +1,67 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createHash as e, randomUUID as t } from "node:crypto";
|
|
2
|
+
import { readFileSync as n } from "node:fs";
|
|
3
|
+
import { spawnSync as r } from "node:child_process";
|
|
4
|
+
import { dirname as i, resolve as a } from "node:path";
|
|
5
|
+
import { currentRuntimeState as o, currentTraceId as s, log as c, newTraceId as l, withSpan as u, withTrace as d } from "@adhd/sox-telemetry";
|
|
2
6
|
//#region src/lib/plugin.ts
|
|
3
|
-
|
|
7
|
+
function f(e) {
|
|
8
|
+
try {
|
|
9
|
+
let t = r("git", ["rev-parse", ...e], {
|
|
10
|
+
cwd: process.cwd(),
|
|
11
|
+
encoding: "utf8",
|
|
12
|
+
timeout: 2e3
|
|
13
|
+
});
|
|
14
|
+
if (t.status === 0 && t.stdout) {
|
|
15
|
+
let e = t.stdout.trim();
|
|
16
|
+
return e.length > 0 ? e : null;
|
|
17
|
+
}
|
|
18
|
+
} catch {}
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
function p() {
|
|
22
|
+
let t = process.argv[1];
|
|
23
|
+
if (t === void 0) return null;
|
|
24
|
+
try {
|
|
25
|
+
return `sha256:${e("sha256").update(n(t)).digest("hex")}`;
|
|
26
|
+
} catch {
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
function m() {
|
|
31
|
+
let e = f(["--show-toplevel"]), t = f(["--path-format=absolute", "--git-common-dir"]);
|
|
32
|
+
return e === null || t === null ? "none" : /[\\/]\.git$/.test(t) && a(i(t)) !== a(e) ? "linked" : "main";
|
|
33
|
+
}
|
|
34
|
+
var h = null;
|
|
35
|
+
function g() {
|
|
36
|
+
if (h === null) {
|
|
37
|
+
let e = process.env.ADHD_SESSION_ID, n = process.env.npm_package_version;
|
|
38
|
+
h = {
|
|
39
|
+
sessionId: e !== void 0 && e.length > 0 ? e : t(),
|
|
40
|
+
worktree: m(),
|
|
41
|
+
release: {
|
|
42
|
+
version: n !== void 0 && n.length > 0 ? n : null,
|
|
43
|
+
gitSha: f(["HEAD"]),
|
|
44
|
+
artifactSha256: p()
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
return h;
|
|
49
|
+
}
|
|
50
|
+
var _ = class {
|
|
4
51
|
constructor(e, t, n) {
|
|
5
52
|
this.traceId = e, this.spanName = t, this.startedAt = n;
|
|
6
53
|
}
|
|
7
54
|
annotate(e) {
|
|
8
|
-
let t =
|
|
9
|
-
t !== void 0 && t.setAttributes(
|
|
55
|
+
let t = v.get(this);
|
|
56
|
+
t !== void 0 && t.setAttributes(y(e));
|
|
10
57
|
}
|
|
11
|
-
},
|
|
12
|
-
function
|
|
58
|
+
}, v = /* @__PURE__ */ new WeakMap();
|
|
59
|
+
function y(e) {
|
|
13
60
|
let t = {};
|
|
14
61
|
for (let [n, r] of Object.entries(e)) (typeof r == "string" || typeof r == "number" || typeof r == "boolean") && (t[n] = r);
|
|
15
62
|
return t;
|
|
16
63
|
}
|
|
17
|
-
function
|
|
64
|
+
function b(e, t) {
|
|
18
65
|
let n = {};
|
|
19
66
|
for (let r of t) {
|
|
20
67
|
let t = e[r];
|
|
@@ -22,41 +69,46 @@ function c(e, t) {
|
|
|
22
69
|
}
|
|
23
70
|
return n;
|
|
24
71
|
}
|
|
25
|
-
function
|
|
72
|
+
function x(e) {
|
|
26
73
|
return e instanceof Error ? e.message : typeof e == "string" ? e : typeof e == "object" && e && "message" in e && typeof e.message == "string" ? e.message : String(e);
|
|
27
74
|
}
|
|
28
|
-
function
|
|
29
|
-
return
|
|
30
|
-
|
|
75
|
+
function S(e, t, n, r, i) {
|
|
76
|
+
return u(t, y(n), async (a) => {
|
|
77
|
+
v.set(r, a);
|
|
31
78
|
try {
|
|
32
79
|
return await e;
|
|
33
80
|
} catch (e) {
|
|
34
|
-
throw
|
|
35
|
-
...
|
|
36
|
-
span:
|
|
37
|
-
duration_ms: Date.now() -
|
|
38
|
-
err:
|
|
81
|
+
throw c.error(`${i}.op.error`, {
|
|
82
|
+
...n,
|
|
83
|
+
span: t,
|
|
84
|
+
duration_ms: Date.now() - r.startedAt,
|
|
85
|
+
err: x(e)
|
|
39
86
|
}), e;
|
|
40
87
|
} finally {
|
|
41
|
-
|
|
88
|
+
v.delete(r);
|
|
42
89
|
}
|
|
43
90
|
});
|
|
44
91
|
}
|
|
45
|
-
function
|
|
46
|
-
let
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
let
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
92
|
+
function C(e) {
|
|
93
|
+
let t = e.serviceName;
|
|
94
|
+
if (typeof t != "string" || t.trim() === "") throw Error("@adhd/apigen-plugin-tracing: `serviceName` is required and must be a non-empty string — it namespaces every span name, attribute key, and error record. Construct the plugin explicitly, e.g. `makeTracingPlugin({ serviceName: \"adhd\" })`.");
|
|
95
|
+
let n = e.envelopeAttrs ?? [];
|
|
96
|
+
return (e, r) => {
|
|
97
|
+
let i = `${t}.${e.operation.id}`, a = s() ?? l(), c = new _(a, i, Date.now());
|
|
98
|
+
e.ctx.set(_, c);
|
|
99
|
+
let u = g(), f = {
|
|
100
|
+
...b(e.envelope, n),
|
|
101
|
+
[`${t}.op`]: e.operation.id,
|
|
102
|
+
[`${t}.transport`]: e.transport,
|
|
103
|
+
trace_id: a,
|
|
104
|
+
session_id: u.sessionId,
|
|
105
|
+
worktree: u.worktree,
|
|
106
|
+
role: o().role
|
|
55
107
|
};
|
|
56
|
-
return
|
|
108
|
+
return u.release.version !== null && (f["release.version"] = u.release.version), u.release.gitSha !== null && (f["release.git_sha"] = u.release.gitSha), u.release.artifactSha256 !== null && (f["release.artifact_sha256"] = u.release.artifactSha256), d(a, () => S(Promise.resolve(r()), i, f, c, t));
|
|
57
109
|
};
|
|
58
110
|
}
|
|
59
|
-
var
|
|
111
|
+
var w = {
|
|
60
112
|
id: "tracing",
|
|
61
113
|
description: "Layer plugin: emits one OTel span per dispatched operation (op id, transport, outcome, duration) to the sox-telemetry JSONL sink, correlated by trace_id.",
|
|
62
114
|
language: "ts",
|
|
@@ -65,7 +117,7 @@ var f = {
|
|
|
65
117
|
properties: {
|
|
66
118
|
serviceName: {
|
|
67
119
|
type: "string",
|
|
68
|
-
description: "Span / record name prefix.
|
|
120
|
+
description: "Span / record / attribute name prefix. REQUIRED — the emitting product namespace (e.g. adhd)."
|
|
69
121
|
},
|
|
70
122
|
envelopeAttrs: {
|
|
71
123
|
type: "array",
|
|
@@ -73,6 +125,7 @@ var f = {
|
|
|
73
125
|
description: "Extra envelope keys copied verbatim onto each span. Default: []."
|
|
74
126
|
}
|
|
75
127
|
},
|
|
128
|
+
required: ["serviceName"],
|
|
76
129
|
additionalProperties: !1
|
|
77
130
|
},
|
|
78
131
|
capabilities: {
|
|
@@ -82,17 +135,17 @@ var f = {
|
|
|
82
135
|
return [];
|
|
83
136
|
}
|
|
84
137
|
},
|
|
85
|
-
layer: { layer:
|
|
138
|
+
layer: { layer: C({ serviceName: "apigen" }) }
|
|
86
139
|
}
|
|
87
140
|
};
|
|
88
|
-
function
|
|
141
|
+
function T(e) {
|
|
89
142
|
return {
|
|
90
|
-
...
|
|
143
|
+
...w,
|
|
91
144
|
capabilities: {
|
|
92
|
-
...
|
|
93
|
-
layer: { layer:
|
|
145
|
+
...w.capabilities,
|
|
146
|
+
layer: { layer: C(e) }
|
|
94
147
|
}
|
|
95
148
|
};
|
|
96
149
|
}
|
|
97
150
|
//#endregion
|
|
98
|
-
export {
|
|
151
|
+
export { _ as TraceHandle, w as default, w as tracingPlugin, T as makeTracingPlugin };
|
package/lib/plugin.d.ts
CHANGED
|
@@ -1,20 +1,46 @@
|
|
|
1
1
|
import { Plugin, Call, Next, Result, Chunk } from '@adhd/apigen-core-client';
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* Where `process.cwd()` sits relative to git — three-valued so the main checkout and a
|
|
5
|
+
* cwd outside any repository (a boolean reported both as the same value) stay
|
|
6
|
+
* distinguishable when records are aggregated.
|
|
7
|
+
*/
|
|
8
|
+
export type WorktreeKind = 'main' | 'linked' | 'none';
|
|
9
|
+
/**
|
|
10
|
+
* Classify `process.cwd()` as a LINKED git worktree, a repository's main checkout, or
|
|
11
|
+
* nothing at all:
|
|
12
|
+
*
|
|
13
|
+
* - `'linked'` — inside a LINKED worktree: `--git-common-dir` names the main
|
|
14
|
+
* checkout's `.git` directory (a path ending in `.git`), and its
|
|
15
|
+
* parent is not this worktree's own `--show-toplevel`.
|
|
16
|
+
* - `'main'` — inside a repository but not a linked worktree (the main checkout).
|
|
17
|
+
* - `'none'` — not inside any repository (either `git rev-parse` probe fails).
|
|
18
|
+
*
|
|
19
|
+
* Exported only so all three values can be unit-tested directly — the same
|
|
20
|
+
* test-only, not-in-the-public-API precedent as `traceStream`; NOT re-exported
|
|
21
|
+
* from `src/index.ts`.
|
|
22
|
+
*/
|
|
23
|
+
export declare function classifyWorktree(): WorktreeKind;
|
|
3
24
|
/**
|
|
4
25
|
* Options for {@link makeTracingPlugin}.
|
|
5
26
|
*
|
|
6
27
|
* Layer plugins receive no opts at call time — `LayerCapability.layer` is invoked with only
|
|
7
28
|
* `(call, next)` — so configuration is a factory, exactly as `makeLoggerPlugin` does it.
|
|
8
29
|
*/
|
|
9
|
-
export
|
|
10
|
-
/**
|
|
11
|
-
|
|
30
|
+
export type TracingOptions = {
|
|
31
|
+
/**
|
|
32
|
+
* Span / record / attribute name prefix — the emitting product's namespace. REQUIRED: there
|
|
33
|
+
* is no implicit default, so a product cannot silently emit another product's telemetry.
|
|
34
|
+
* adhd products pass `'adhd'`; apigen's own CLI and self-test pass `'apigen'` explicitly.
|
|
35
|
+
*/
|
|
36
|
+
serviceName: string;
|
|
12
37
|
/**
|
|
13
38
|
* Extra attribute keys copied verbatim from `call.envelope` onto each span. Default: `[]`
|
|
14
|
-
* (only the built-in attrs
|
|
39
|
+
* (only the built-in attrs `${serviceName}.op`, `${serviceName}.transport`, `trace_id` are
|
|
40
|
+
* emitted).
|
|
15
41
|
*/
|
|
16
42
|
envelopeAttrs?: readonly string[];
|
|
17
|
-
}
|
|
43
|
+
};
|
|
18
44
|
/**
|
|
19
45
|
* Per-call trace handle, seeded into `call.ctx`. The class is the ctx token: domain code reads
|
|
20
46
|
* it back with `call.ctx.get(TraceHandle)`.
|
|
@@ -35,8 +61,9 @@ export declare class TraceHandle {
|
|
|
35
61
|
startedAt: number);
|
|
36
62
|
/**
|
|
37
63
|
* Add attributes to the live span from domain code — opt-in. A no-op when the operation is
|
|
38
|
-
* not currently inside a unary span (e.g. before the downstream resolved, or
|
|
39
|
-
*
|
|
64
|
+
* not currently inside a unary span (e.g. before the downstream resolved, or after the span
|
|
65
|
+
* has closed). Streaming is not special-cased: the layer spans a streaming op as a unary
|
|
66
|
+
* span covering only the point the stream is obtained.
|
|
40
67
|
*/
|
|
41
68
|
annotate(fields: Record<string, unknown>): void;
|
|
42
69
|
}
|
|
@@ -44,16 +71,18 @@ export declare class TraceHandle {
|
|
|
44
71
|
* QUARANTINED — unreachable under the current `Next` contract; see CONTRACT-FIX §4.
|
|
45
72
|
* Exported only so the streaming branch can be exercised by a direct unit test; no layer
|
|
46
73
|
* path reaches it (a `Next` resolves to a `LayerResult`, so this detector can never be
|
|
47
|
-
* true for the unresolved `next()` promise).
|
|
48
|
-
*
|
|
74
|
+
* true for the unresolved `next()` promise). Not re-exported from the package entry
|
|
75
|
+
* (`src/index.ts`), so it is not part of the public API either. Retained — never
|
|
76
|
+
* deleted — pending a `Next` that can yield an iterable before resolution.
|
|
49
77
|
*/
|
|
50
78
|
export declare function isAsyncIterable(value: unknown): value is AsyncIterable<Chunk>;
|
|
51
79
|
/**
|
|
52
80
|
* QUARANTINED — unreachable under the current `Next` contract; see CONTRACT-FIX §4.
|
|
53
81
|
* The layer no longer branches on `next()` (an `AsyncIterable` can only be a *resolved*
|
|
54
82
|
* value, never the unresolved promise), so this is retained with its body intact and
|
|
55
|
-
* exported solely for a direct unit test
|
|
56
|
-
* `
|
|
83
|
+
* exported solely for a direct unit test (and not re-exported from the package entry
|
|
84
|
+
* `src/index.ts`, so not part of the public API). Do NOT re-wire it into the layer by
|
|
85
|
+
* awaiting `next()` first — that would destroy the span-before-body invariant guarded by
|
|
57
86
|
* `plugin.spec.ts` (the hang-visibility test).
|
|
58
87
|
*
|
|
59
88
|
* Streaming branch — `withSpan` cannot await an iterable, so the `.start` record is emitted
|
|
@@ -65,7 +94,7 @@ export declare function traceStream(downstream: AsyncIterable<Chunk>, spanName:
|
|
|
65
94
|
* Build the tracing layer for a given configuration. The returned layer calls `next()` exactly
|
|
66
95
|
* once and returns its resolved value (or iterable) unchanged, wrapping it in a span.
|
|
67
96
|
*/
|
|
68
|
-
export declare function makeTraceLayer(opts
|
|
97
|
+
export declare function makeTraceLayer(opts: TracingOptions): (call: Call, next: Next) => Promise<Result> | AsyncIterable<Chunk>;
|
|
69
98
|
/**
|
|
70
99
|
* Tracing plugin.
|
|
71
100
|
*
|
|
@@ -76,5 +105,5 @@ export declare function makeTraceLayer(opts?: TracingOptions): (call: Call, next
|
|
|
76
105
|
*/
|
|
77
106
|
export declare const tracingPlugin: Plugin<TracingOptions>;
|
|
78
107
|
/** Configured factory — rebuilds the layer with `opts` (logger precedent). */
|
|
79
|
-
export declare function makeTracingPlugin(opts
|
|
108
|
+
export declare function makeTracingPlugin(opts: TracingOptions): Plugin<TracingOptions>;
|
|
80
109
|
export default tracingPlugin;
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adhd/apigen-plugin-tracing",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"dependencies": {
|
|
5
5
|
"@adhd/apigen-core-client": "^0.3.3",
|
|
6
|
-
"@adhd/sox-telemetry": "^0.
|
|
6
|
+
"@adhd/sox-telemetry": "^0.4.1"
|
|
7
7
|
},
|
|
8
8
|
"main": "./index.js",
|
|
9
9
|
"module": "./index.mjs",
|