@fractaal/pi-telemetry 0.86.8 → 1.4.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 +167 -21
- package/dist/index.d.ts +90 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/memory.d.ts +40 -2
- package/dist/memory.d.ts.map +1 -1
- package/dist/memory.js +228 -80
- package/dist/memory.js.map +1 -1
- package/dist/metrics.d.ts +78 -0
- package/dist/metrics.d.ts.map +1 -0
- package/dist/metrics.js +14 -0
- package/dist/metrics.js.map +1 -0
- package/dist/noop.d.ts +7 -2
- package/dist/noop.d.ts.map +1 -1
- package/dist/noop.js +19 -7
- package/dist/noop.js.map +1 -1
- package/dist/render.d.ts +4 -0
- package/dist/render.d.ts.map +1 -0
- package/dist/render.js +48 -0
- package/dist/render.js.map +1 -0
- package/dist/testing/conformance.d.ts.map +1 -1
- package/dist/testing/conformance.js +171 -77
- package/dist/testing/conformance.js.map +1 -1
- package/dist/testing/types.d.ts +5 -2
- package/dist/testing/types.d.ts.map +1 -1
- package/dist/testing/types.js.map +1 -1
- package/package.json +7 -2
package/README.md
CHANGED
|
@@ -6,6 +6,8 @@ This package provides:
|
|
|
6
6
|
|
|
7
7
|
- an explicit, callback-based `TelemetryContext` / `TelemetrySpan` contract;
|
|
8
8
|
- a shared `NOOP_TELEMETRY_CONTEXT`;
|
|
9
|
+
- opaque cross-process propagation and span links;
|
|
10
|
+
- counters, up-down counters, histograms, and typed metric schemas;
|
|
9
11
|
- a reference `InMemoryTelemetryContext` implementation;
|
|
10
12
|
- serializable schema definitions with inferred TypeScript types;
|
|
11
13
|
- no exporter, global current-span state, or dependency on a telemetry backend.
|
|
@@ -18,8 +20,11 @@ Applications can use the in-memory reference or provide an adapter for OpenTelem
|
|
|
18
20
|
- [Telemetry Concepts](#telemetry-concepts)
|
|
19
21
|
- [Core Context API](#core-context-api)
|
|
20
22
|
- [Adapter Contract](#adapter-contract)
|
|
23
|
+
- [Propagation and Span Links](#propagation-and-span-links)
|
|
24
|
+
- [Metrics](#metrics)
|
|
21
25
|
- [No-op Context](#no-op-context)
|
|
22
26
|
- [In-Memory Reference Adapter](#in-memory-reference-adapter)
|
|
27
|
+
- [Stored Telemetry](#stored-telemetry)
|
|
23
28
|
- [Adapter Conformance](#adapter-conformance)
|
|
24
29
|
- [Typed Schemas](#typed-schemas)
|
|
25
30
|
- [Start and Completion Attributes](#start-and-completion-attributes)
|
|
@@ -59,11 +64,11 @@ example.account.load span
|
|
|
59
64
|
└─ status: ok final outcome
|
|
60
65
|
```
|
|
61
66
|
|
|
62
|
-
A span is diagnostic data, not business state.
|
|
67
|
+
A span is diagnostic data, not business state. An adapter translates these generic concepts into the corresponding concepts used by OpenTelemetry, Sentry, logs, or another backend.
|
|
63
68
|
|
|
64
69
|
## Core Context API
|
|
65
70
|
|
|
66
|
-
A `TelemetryContext` starts a span around a callback. The callback receives a `TelemetrySpan`, which is also the explicit parent context for child spans.
|
|
71
|
+
A `TelemetryContext` starts a span around a callback. The callback receives a `TelemetrySpan`, which is also the explicit parent context for child spans. Contexts optionally expose their adapter's `metrics?: TelemetryMetrics` and `propagation?: TelemetryPropagation` capabilities; child spans and extracted parents carry the same capabilities. A `TelemetryContext` adapter starts root spans; hosts retain this adapter. Invocation contexts and pi-ai request options carry a `TelemetrySpan`, never the adapter. A tracing adapter that only implements `startSpan()` is still valid.
|
|
67
72
|
|
|
68
73
|
```typescript
|
|
69
74
|
import {
|
|
@@ -117,20 +122,121 @@ return telemetryContext.startSpan({ name: 'example.save' }, async (span) => {
|
|
|
117
122
|
|
|
118
123
|
## Adapter Contract
|
|
119
124
|
|
|
120
|
-
An adapter implements `TelemetryContext` and bridges the generic API to its backend.
|
|
125
|
+
An adapter implements `TelemetryContext` and bridges the generic API to its backend. Typed inputs are trusted; malformed inputs have unspecified behavior. Adapters are not required to validate inputs or suppress adapter/backend failures.
|
|
126
|
+
|
|
127
|
+
The callback and recording contract is:
|
|
121
128
|
|
|
122
129
|
- create a child span and invoke the callback synchronously, exactly once;
|
|
130
|
+
- expose optional metric and propagation capabilities on its contexts, child spans, and extracted parents, including inert fallback spans;
|
|
123
131
|
- preserve the callback's returned value and rejection value, returning a promise rejected with the same value after a synchronous throw;
|
|
124
132
|
- keep the native span open until a returned promise settles;
|
|
125
133
|
- treat normal completion as `ok` and throws/rejections as errors unless an explicit status was set;
|
|
126
134
|
- make repeated `setStatus()` calls last-write-wins;
|
|
127
135
|
- merge `setAttributes()` calls, with later defined values replacing earlier values and `undefined` ignored;
|
|
128
|
-
- make recording methods synchronous
|
|
129
|
-
- ignore calls made after settlement
|
|
130
|
-
- ignore a failed recording call atomically, suppress backend failures, and still execute the business callback exactly once.
|
|
136
|
+
- make recording methods synchronous;
|
|
137
|
+
- ignore calls made after settlement.
|
|
131
138
|
|
|
132
139
|
Adapters may activate backend-native ambient context internally for automatic instrumentation, but pi code always propagates the parent through `TelemetryContext` arguments. Exporter buffering, flushing, sampling, backend IDs, and backend-specific context objects belong to the adapter. Use the [adapter conformance suite](#adapter-conformance) to check these observable semantics.
|
|
133
140
|
|
|
141
|
+
## Propagation and Span Links
|
|
142
|
+
|
|
143
|
+
An adapter may also implement `TelemetryPropagation`. Expose it through `context.propagation` so code can inject or extract using the context it already has. The root, spans, and extracted parents share the adapter's capability object:
|
|
144
|
+
|
|
145
|
+
```typescript
|
|
146
|
+
interface TelemetryPropagation {
|
|
147
|
+
inject(context: TelemetryContext): TelemetryCarrier | undefined;
|
|
148
|
+
extract(carrier: TelemetryCarrier | undefined): TelemetryContext;
|
|
149
|
+
}
|
|
150
|
+
type TelemetryCarrier = Record<string, string>;
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
A carrier is an opaque JSON-safe string map. Adapters own its format; W3C `traceparent` and `tracestate` fit without requiring them. Transport code sends only the carrier, never a context or span:
|
|
154
|
+
|
|
155
|
+
```typescript
|
|
156
|
+
const caller = new InMemoryTelemetryContext();
|
|
157
|
+
const provider = new InMemoryTelemetryContext();
|
|
158
|
+
await caller.startSpan({ name: 'rpc.client' }, async (span) => {
|
|
159
|
+
const wire = JSON.stringify(caller.inject(span));
|
|
160
|
+
await provider.extract(JSON.parse(wire)).startSpan(
|
|
161
|
+
{ name: 'rpc.server' },
|
|
162
|
+
(serverSpan) => handleRequest(serverSpan),
|
|
163
|
+
);
|
|
164
|
+
});
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
Injection returns a detached carrier or `undefined` for roots, no-op contexts, and unsupported contexts. Extraction returns a receiver-owned parent. Absent or unknown carriers fall back to the adapter's root. Extraction checks only that required carrier keys contain strings; identifiers are opaque and need no format validation. Both methods are synchronous. Trace metadata is diagnostics, never authorization. Transport boundaries own carrier size limits.
|
|
168
|
+
|
|
169
|
+
A link relates work without changing its parent. Use `SpanOptions.links` when the target is known at creation, or `span.addLink()` after the span has started:
|
|
170
|
+
|
|
171
|
+
```typescript
|
|
172
|
+
await telemetry.startSpan(
|
|
173
|
+
{ name: 'activation', links: [{ context: firstGetter, attributes: { reason: 'trigger' } }] },
|
|
174
|
+
async (activation) => {
|
|
175
|
+
laterGetter.addLink({ context: activation });
|
|
176
|
+
await activate();
|
|
177
|
+
},
|
|
178
|
+
);
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
Link targets are `TelemetryContext` handles, including spans and extracted remote parents. For a remote link, first call `adapter.extract(carrier)`. A settled target remains linkable and injectable; a settled source ignores `addLink()`. Links append in order, copy attributes, and ignore root, no-op, or unsupported contexts. The typed span starter's callback also supports `addLink()`; initial links use the low-level `startSpan()` API.
|
|
182
|
+
|
|
183
|
+
`NOOP_TELEMETRY_PROPAGATION` ignores its arguments: injection returns `undefined`, extraction returns `NOOP_TELEMETRY_CONTEXT`.
|
|
184
|
+
|
|
185
|
+
## Metrics
|
|
186
|
+
|
|
187
|
+
An adapter may implement `TelemetryMetrics` alongside `TelemetryContext` and `TelemetryPropagation`. Applications configure one adapter, not separate backends for each capability. Expose the shared capability through `context.metrics`; child spans retain it, so nested model calls can record metrics without a separate configuration option. The in-memory adapter also implements the factory methods directly:
|
|
188
|
+
|
|
189
|
+
```typescript
|
|
190
|
+
const bytes = telemetry.counter('network.bytes', {
|
|
191
|
+
description: 'Encoded WebSocket bytes', unit: 'By',
|
|
192
|
+
});
|
|
193
|
+
bytes.add(encodedSize, { direction: 'out' });
|
|
194
|
+
|
|
195
|
+
const active = telemetry.upDownCounter('calls.active');
|
|
196
|
+
active.add(1);
|
|
197
|
+
active.add(-1);
|
|
198
|
+
|
|
199
|
+
const duration = telemetry.histogram('call.duration', {
|
|
200
|
+
unit: 'ms', boundaries: [1, 10, 100, 1000],
|
|
201
|
+
});
|
|
202
|
+
duration.record(elapsedMs, { method: 'read' }, currentSpan);
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
Factories take an instrument name and optional `InstrumentOptions` (`description`, `unit`). Histograms additionally accept `HistogramOptions.boundaries`: callers supply finite, strictly increasing bucket hints. Backends own aggregation and may translate these hints. Callers are responsible for finite measurements and non-negative counter increments; up-down counters and histograms may use signed values. Histogram `record(value, attributes?, context?)` optionally correlates a measurement with a span, called an exemplar. Counter `add(value, attributes?)` has no context argument.
|
|
206
|
+
|
|
207
|
+
Factories and recording methods are synchronous and trust typed inputs. Adapters need not validate measurement values, metadata, attributes, or boundaries; malformed inputs have unspecified behavior. `NOOP_TELEMETRY_METRICS` returns shared frozen instruments that discard measurements. Record only values already available to business code; do not serialize or measure extra data for telemetry.
|
|
208
|
+
|
|
209
|
+
Use only low-cardinality attributes: bounded values such as direction or method, not request IDs, user IDs, prompts, or arbitrary paths. The low-level attribute bag remains open; instrumentation owns this policy, not backend-specific heuristics.
|
|
210
|
+
|
|
211
|
+
### Typed metric schemas
|
|
212
|
+
|
|
213
|
+
`TelemetrySchemaDefinition.metrics` optionally declares instrument names, kinds, metadata, and required/optional attributes. `createTypedMetrics()` combines one or more schemas and rejects duplicate metric names, incorrect instrument kinds, unknown attributes, and missing required attributes at compile time:
|
|
214
|
+
|
|
215
|
+
```typescript
|
|
216
|
+
const schema = defineTelemetrySchema({
|
|
217
|
+
version: 1,
|
|
218
|
+
spans: {},
|
|
219
|
+
metrics: {
|
|
220
|
+
'network.bytes': {
|
|
221
|
+
kind: 'counter', description: 'Encoded bytes', unit: 'By',
|
|
222
|
+
attributes: {
|
|
223
|
+
direction: {
|
|
224
|
+
type: 'string', required: true, values: ['in', 'out'],
|
|
225
|
+
description: 'Direction', cardinality: 'low',
|
|
226
|
+
},
|
|
227
|
+
},
|
|
228
|
+
},
|
|
229
|
+
},
|
|
230
|
+
} as const);
|
|
231
|
+
|
|
232
|
+
const metrics = createTypedMetrics(telemetry, [schema]);
|
|
233
|
+
metrics.counter('network.bytes').add(encodedSize, { direction: 'out' });
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
Metric definitions use `kind: 'counter' | 'upDownCounter' | 'histogram'`; only histograms may declare `boundaries`. Metric attributes use the same scalar/array definitions as spans, but reject `cardinality: 'high'`. Omitting the cardinality annotation does not waive the low-cardinality policy. Unlike the typed span starter, the metric helper reads and retains schema instrument metadata at runtime. It performs no runtime attribute validation.
|
|
237
|
+
|
|
238
|
+
`InMemoryTelemetryContext.getMetrics()` returns ordered, detached `RecordedTelemetryMeasurement` snapshots: `kind`, `name`, optional `description`/`unit`/`boundaries`, `value`, copied `attributes`, and a carrier-shaped exemplar `context` or `null`. This is a measurement log, not aggregated counters or buckets; storage is unbounded. Measurement times are retained privately for store queries, not exposed in these snapshots.
|
|
239
|
+
|
|
134
240
|
## No-op Context
|
|
135
241
|
|
|
136
242
|
Use `NOOP_TELEMETRY_CONTEXT` when telemetry is optional:
|
|
@@ -149,6 +255,7 @@ The no-op context:
|
|
|
149
255
|
- invokes callbacks synchronously;
|
|
150
256
|
- preserves returned values and asynchronous rejections, and converts a synchronous throw to a promise rejected with the same value;
|
|
151
257
|
- uses one shared frozen inert span, including for nested spans;
|
|
258
|
+
- exposes `NOOP_TELEMETRY_METRICS` and `NOOP_TELEMETRY_PROPAGATION` on its root and spans;
|
|
152
259
|
- does not inspect or retain names, attributes, events, or statuses.
|
|
153
260
|
|
|
154
261
|
## In-Memory Reference Adapter
|
|
@@ -171,10 +278,35 @@ await telemetry.startSpan(
|
|
|
171
278
|
console.log(telemetry.getSpans());
|
|
172
279
|
```
|
|
173
280
|
|
|
174
|
-
`getSpans()` returns detached snapshots in span-start order. Each `RecordedTelemetrySpan` contains a deterministic numeric ID, parent ID, merged attributes, ordered events, final status, settlement state, and deterministic end sequence.
|
|
281
|
+
`getSpans()` returns detached snapshots in span-start order. Each `RecordedTelemetrySpan` contains a deterministic numeric ID, local parent ID, carrier-shaped `context` and `parentContext` snapshots, ordered `links`, merged attributes, ordered events, final status, settlement state, and deterministic end sequence. These normalized snapshots expose no timestamps. A remote parent has `parentId: null` but a non-null `parentContext`; a root has both null. A `RecordedTelemetryLink` contains a target carrier and copied attributes.
|
|
282
|
+
|
|
283
|
+
The adapter implements `TelemetryPropagation` with its own small carrier codec: a unique recorder scope, a deterministic numeric span ID, and an inherited trace ID. The carrier survives JSON round trips and works across independent processes without a shared registry. Its keys are an implementation detail, not a public wire format for other adapters.
|
|
175
284
|
|
|
176
285
|
The adapter is safe to use as an ordinary `TelemetryContext`, but storage is unbounded and process-local. Create a fresh instance to isolate tests or recording scopes, and do not capture sensitive attributes unless the caller's data policy allows them.
|
|
177
286
|
|
|
287
|
+
## Stored Telemetry
|
|
288
|
+
|
|
289
|
+
`TelemetryStore` separates querying from recording. Both `InMemoryTelemetryContext` and `@earendil-works/chord/telemetry-sqlite` implement it:
|
|
290
|
+
|
|
291
|
+
- `findTraces(query?)` returns complete locally stored traces, newest trace start first. Filters include the earliest stored span's `name`, inclusive `startMin`/`startMax`, `errors: true`, and scalar `attributes`. All requested attributes must match one span, anywhere in the trace. Pages default to 20 traces; pass the returned opaque `cursor` with the same filters to continue. Equal start times are ordered by trace ID.
|
|
292
|
+
- `getTrace(traceId)` returns a trace or `undefined`.
|
|
293
|
+
- `findMetrics({ name, startMin?, startMax?, attributes? })` returns metric rows with count, sum, minimum, and maximum. Time bounds are inclusive interval-start times. The in-memory adapter maps each raw measurement to a count-one row in its ten-second interval; SQLite aggregates measurements per series and interval.
|
|
294
|
+
|
|
295
|
+
Only settled spans are returned. A trace ID is the root's globally unique span ID (`<recorder UUID>:<counter>`) and propagates with the parent identity. Stores return the spans available locally: remote or expired parents can be absent, and a child can appear before its parent settles. Pagination is not a snapshot across requests; late settlements and retention can change a trace's earliest stored span. SQLite reads committed rows without implicitly flushing.
|
|
296
|
+
|
|
297
|
+
`StoredSpan` includes epoch-millisecond `startedMs`/`endedMs`, event offsets in `timeMs`, and links carrying both target `traceId` and `spanId`. Duration uses a monotonic clock; wall clocks across processes may disagree. Merge spans from several stores by trace ID; parent relationships, not timestamp containment, define the tree.
|
|
298
|
+
|
|
299
|
+
Rendering is a separate subpath, kept out of the root entry graph:
|
|
300
|
+
|
|
301
|
+
```typescript
|
|
302
|
+
import { renderTrace } from '@earendil-works/pi-telemetry/render';
|
|
303
|
+
|
|
304
|
+
const page = await telemetry.findTraces({ errors: true, limit: 10 });
|
|
305
|
+
for (const trace of page.traces) console.log(renderTrace(trace.spans));
|
|
306
|
+
```
|
|
307
|
+
|
|
308
|
+
`renderTrace()` accepts stored spans, deduplicates IDs, treats absent parents as roots, and prints attributes, durations, statuses, event offsets, and cross-trace links. It never follows links or queries a store.
|
|
309
|
+
|
|
178
310
|
## Adapter Conformance
|
|
179
311
|
|
|
180
312
|
`@earendil-works/pi-telemetry/testing` exports a runner-independent conformance suite modeled as grouped cases. A fixture supplies a fresh context and converts its backend's finished spans into normalized `RecordedTelemetrySpan` snapshots:
|
|
@@ -206,7 +338,7 @@ for (const group of new Set(conformance.map((testCase) => testCase.group))) {
|
|
|
206
338
|
}
|
|
207
339
|
```
|
|
208
340
|
|
|
209
|
-
The suite checks synchronous single admission, result and rejection identity, automatic and explicit status, attribute merging, event ordering, inert post-settlement calls, nested and concurrent parentage, and suppression of
|
|
341
|
+
The suite checks capability identity on roots, child spans, extracted parents and inert spans, synchronous single admission, result and rejection identity, automatic and explicit status, attribute merging, event ordering, inert post-settlement calls, nested and concurrent parentage, and links. Fixtures may supply `propagation` to additionally check JSON round trips, multiple adapter hops, and root fallback for absent or unknown carriers. Fixtures may also supply `metrics` and `getMetrics()` to check ordered measurements, histogram exemplars, and input copying. It does not test malformed inputs or require suppression of adapter/backend failures. `getSpans()` may flush an asynchronous exporter before returning. The testing subpath uses Node's assertion APIs; the root telemetry package remains runtime-neutral.
|
|
210
342
|
|
|
211
343
|
## Typed Schemas
|
|
212
344
|
|
|
@@ -367,24 +499,20 @@ Adapters do not need to understand schema objects. Instrumentation helpers and t
|
|
|
367
499
|
Package ownership is intentionally split:
|
|
368
500
|
|
|
369
501
|
- `@earendil-works/pi-telemetry` owns the vendor-neutral contract, no-op and in-memory reference contexts, schema utilities, and adapter conformance suite;
|
|
370
|
-
- `@earendil-works/pi-ai` accepts
|
|
371
|
-
- `@earendil-works/pi-
|
|
502
|
+
- `@earendil-works/pi-ai` accepts a parent `TelemetrySpan` through `telemetry` in provider request options and exports `AI_TELEMETRY_SCHEMA` from its root and `./models` entry points;
|
|
503
|
+
- `@earendil-works/pi-durable` exports `DURABLE_TELEMETRY_SCHEMA` for short task-handler and submission spans, events, and metrics;
|
|
504
|
+
- `@earendil-works/pi-agent-core` retains its existing agent-loop and session instrumentation and schemas.
|
|
372
505
|
|
|
373
506
|
```typescript
|
|
374
|
-
import {
|
|
375
|
-
|
|
376
|
-
AI_TELEMETRY_SCHEMA,
|
|
377
|
-
HARNESS_TELEMETRY_SCHEMA,
|
|
378
|
-
startAiSpan,
|
|
379
|
-
startHarnessSpan,
|
|
380
|
-
} from '@earendil-works/pi-agent-core';
|
|
507
|
+
import { AI_TELEMETRY_SCHEMA } from '@earendil-works/pi-ai/models';
|
|
508
|
+
import { DURABLE_TELEMETRY_SCHEMA } from '@earendil-works/pi-durable';
|
|
381
509
|
```
|
|
382
510
|
|
|
383
|
-
The
|
|
511
|
+
The AI and Durable schemas use pi-owned `pi.ai.*` and `pi.durable.*` names. Adapters may translate them to backend conventions without changing the emitted pi vocabulary.
|
|
384
512
|
|
|
385
513
|
## Security and Portability
|
|
386
514
|
|
|
387
|
-
Telemetry is
|
|
515
|
+
Telemetry is diagnostics, not durable application state. Do not persist a `TelemetryContext`, `TelemetrySpan`, or backend-native trace object in records, messages, snapshots, or deferred handles. An injected `TelemetryCarrier` may cross a transport or be stored as optional diagnostic correlation data. Changing adapters may lose correlation; carriers are not application state.
|
|
388
516
|
|
|
389
517
|
Attribute values are intentionally limited to primitive scalars and arrays. Domain instrumentation should avoid prompts, completions, tool arguments or output, file contents, provider payloads, headers, credentials, and free-form error details unless its schema and data policy explicitly allow them.
|
|
390
518
|
|
|
@@ -396,15 +524,30 @@ The package does not use `AsyncLocalStorage` or another runtime-specific ambient
|
|
|
396
524
|
|
|
397
525
|
| Export | Purpose |
|
|
398
526
|
|---|---|
|
|
399
|
-
| `TelemetryContext` | Starts callback-managed child spans |
|
|
527
|
+
| `TelemetryContext` | Starts callback-managed child spans and optionally exposes adapter metrics/propagation |
|
|
400
528
|
| `TelemetrySpan` | Records attributes, events, and status; also acts as a child context |
|
|
401
|
-
| `SpanOptions` | Span name
|
|
529
|
+
| `SpanOptions` | Span name, optional start attributes and links |
|
|
530
|
+
| `SpanLink` | Context target and optional link attributes |
|
|
531
|
+
| `TelemetryCarrier` | Opaque JSON-safe string map |
|
|
532
|
+
| `TelemetryPropagation` | Optional adapter injection and extraction capability |
|
|
533
|
+
| `NOOP_TELEMETRY_PROPAGATION` | Shared passive propagation for disabled telemetry |
|
|
534
|
+
| `TelemetryMetrics` | Optional adapter instrument factories |
|
|
535
|
+
| `TelemetryCounter` / `TelemetryUpDownCounter` | Instruments with `add()` |
|
|
536
|
+
| `TelemetryHistogram` | Instrument with `record()` and optional exemplar context |
|
|
537
|
+
| `InstrumentOptions` / `HistogramOptions` | Description, unit, and histogram boundary hints |
|
|
538
|
+
| `NOOP_TELEMETRY_METRICS` | Shared passive metric instruments |
|
|
539
|
+
| `RecordedTelemetryMeasurement` | Captured measurement and optional exemplar |
|
|
402
540
|
| `SpanAttributes` / `AttributeValue` | Open adapter-level attribute bag and supported values |
|
|
403
541
|
| `SpanStatus` | Explicit `ok` or `error` status |
|
|
404
542
|
| `NOOP_TELEMETRY_CONTEXT` | Shared passive context for disabled telemetry |
|
|
405
543
|
| `InMemoryTelemetryContext` | Reference adapter with deterministic process-local recording |
|
|
406
544
|
| `RecordedTelemetrySpan` | Normalized captured span snapshot |
|
|
407
545
|
| `RecordedTelemetryEvent` | Normalized captured event snapshot |
|
|
546
|
+
| `RecordedTelemetryLink` | Captured target carrier and link attributes |
|
|
547
|
+
| `TelemetryStore` | Settled trace discovery, trace retrieval, and metric queries |
|
|
548
|
+
| `StoredSpan` / `StoredTrace` | Backend-independent timed span and trace snapshots |
|
|
549
|
+
| `TraceQuery` / `MetricQuery` | Trace filters, pagination, and metric filters |
|
|
550
|
+
| `StoredMetric` | Metric interval row with count, sum, minimum, and maximum |
|
|
408
551
|
|
|
409
552
|
### Schema definitions and inference
|
|
410
553
|
|
|
@@ -412,6 +555,9 @@ The package does not use `AsyncLocalStorage` or another runtime-specific ambient
|
|
|
412
555
|
|---|---|
|
|
413
556
|
| `defineTelemetrySchema()` | Typed identity helper for serializable schema data |
|
|
414
557
|
| `createTypedSpanStarter()` | Binds a parent context to one or more schema vocabularies |
|
|
558
|
+
| `createTypedMetrics()` / `TypedTelemetryMetrics` | Binds metric names, kinds, metadata, and attributes to schemas |
|
|
559
|
+
| `TelemetryMetricDefinition` / `TelemetryMetricAttributeDefinition` | Serializable instrument metadata and low-cardinality attribute definitions |
|
|
560
|
+
| `SchemaTelemetryCounter` / `SchemaTelemetryHistogram` | Schema-constrained recording methods |
|
|
415
561
|
| `TypedSpanStarter` | Exact starter type with recursively child-bound callbacks |
|
|
416
562
|
| `TelemetrySchemaDefinition` | Top-level schema shape |
|
|
417
563
|
| `TelemetrySpanDefinition` | Span metadata, parents, attributes, events, and status rule |
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,24 @@
|
|
|
1
|
+
import type { TelemetryMetricDefinition, TelemetryMetrics } from "./metrics.ts";
|
|
1
2
|
export type AttributeValue = string | number | boolean | readonly string[] | readonly number[] | readonly boolean[];
|
|
2
3
|
export interface SpanAttributes {
|
|
3
4
|
[name: string]: AttributeValue | undefined;
|
|
4
5
|
}
|
|
6
|
+
/** Opaque, JSON-serializable adapter-owned propagation data. */
|
|
7
|
+
export type TelemetryCarrier = Record<string, string>;
|
|
8
|
+
/** Optional transport capability implemented by the application's telemetry adapter. */
|
|
9
|
+
export interface TelemetryPropagation {
|
|
10
|
+
inject(context: TelemetryContext): TelemetryCarrier | undefined;
|
|
11
|
+
/** Absent or unknown carriers use the root; recognized identifiers are opaque strings. */
|
|
12
|
+
extract(carrier: TelemetryCarrier | undefined): TelemetryContext;
|
|
13
|
+
}
|
|
14
|
+
export interface SpanLink {
|
|
15
|
+
context: TelemetryContext;
|
|
16
|
+
attributes?: SpanAttributes;
|
|
17
|
+
}
|
|
5
18
|
export interface SpanOptions {
|
|
6
19
|
name: string;
|
|
7
20
|
attributes?: SpanAttributes;
|
|
21
|
+
links?: readonly SpanLink[];
|
|
8
22
|
}
|
|
9
23
|
export type SpanStatus = {
|
|
10
24
|
status: "ok";
|
|
@@ -15,15 +29,88 @@ export type SpanStatus = {
|
|
|
15
29
|
message: string;
|
|
16
30
|
};
|
|
17
31
|
};
|
|
32
|
+
/** A settled span snapshot, independent of the recording adapter. Event times are relative to span start. */
|
|
33
|
+
export interface StoredSpan {
|
|
34
|
+
readonly id: string;
|
|
35
|
+
readonly traceId: string;
|
|
36
|
+
readonly parentId?: string;
|
|
37
|
+
readonly name: string;
|
|
38
|
+
readonly startedMs: number;
|
|
39
|
+
readonly endedMs: number;
|
|
40
|
+
readonly attributes: SpanAttributes;
|
|
41
|
+
readonly events: readonly {
|
|
42
|
+
readonly name: string;
|
|
43
|
+
readonly timeMs: number;
|
|
44
|
+
readonly attributes: SpanAttributes;
|
|
45
|
+
}[];
|
|
46
|
+
readonly links: readonly {
|
|
47
|
+
readonly traceId: string;
|
|
48
|
+
readonly spanId: string;
|
|
49
|
+
readonly attributes?: SpanAttributes;
|
|
50
|
+
}[];
|
|
51
|
+
readonly status: SpanStatus;
|
|
52
|
+
}
|
|
53
|
+
export interface StoredTrace {
|
|
54
|
+
readonly traceId: string;
|
|
55
|
+
readonly spans: readonly StoredSpan[];
|
|
56
|
+
}
|
|
57
|
+
export interface TraceQuery {
|
|
58
|
+
/** Name of the earliest stored span, with span ID breaking timestamp ties. */
|
|
59
|
+
readonly name?: string;
|
|
60
|
+
/** All equalities must match one span; that span may be anywhere in the trace. */
|
|
61
|
+
readonly attributes?: Readonly<Record<string, string | number | boolean>>;
|
|
62
|
+
readonly errors?: true;
|
|
63
|
+
/** Inclusive bounds on the earliest stored span's start time. */
|
|
64
|
+
readonly startMin?: number;
|
|
65
|
+
readonly startMax?: number;
|
|
66
|
+
/** Positive page size; defaults to 20. */
|
|
67
|
+
readonly limit?: number;
|
|
68
|
+
/** Opaque continuation from the previous page; retain the same filters. */
|
|
69
|
+
readonly cursor?: string;
|
|
70
|
+
}
|
|
71
|
+
export interface MetricQuery {
|
|
72
|
+
readonly name: string;
|
|
73
|
+
/** Inclusive bounds on interval start time. */
|
|
74
|
+
readonly startMin?: number;
|
|
75
|
+
readonly startMax?: number;
|
|
76
|
+
readonly attributes?: Readonly<Record<string, string | number | boolean>>;
|
|
77
|
+
}
|
|
78
|
+
export interface StoredMetric {
|
|
79
|
+
readonly intervalMs: number;
|
|
80
|
+
readonly name: string;
|
|
81
|
+
readonly kind: "counter" | "upDownCounter" | "histogram";
|
|
82
|
+
readonly unit?: string;
|
|
83
|
+
readonly attributes: SpanAttributes;
|
|
84
|
+
readonly count: number;
|
|
85
|
+
readonly sum: number;
|
|
86
|
+
readonly min: number;
|
|
87
|
+
readonly max: number;
|
|
88
|
+
}
|
|
89
|
+
/** Read settled traces without depending on a storage backend. */
|
|
90
|
+
export interface TelemetryStore {
|
|
91
|
+
findTraces(query?: TraceQuery): Promise<{
|
|
92
|
+
traces: readonly StoredTrace[];
|
|
93
|
+
cursor?: string;
|
|
94
|
+
}>;
|
|
95
|
+
getTrace(traceId: string): Promise<StoredTrace | undefined>;
|
|
96
|
+
findMetrics(query: MetricQuery): Promise<readonly StoredMetric[]>;
|
|
97
|
+
}
|
|
98
|
+
/** Adapter contract for trusted typed inputs; malformed input behavior is unspecified. */
|
|
18
99
|
export interface TelemetryContext {
|
|
100
|
+
/** Adapter capabilities remain available on child spans and extracted parents. */
|
|
101
|
+
readonly metrics?: TelemetryMetrics;
|
|
102
|
+
readonly propagation?: TelemetryPropagation;
|
|
19
103
|
startSpan<T>(options: SpanOptions, callback: (span: TelemetrySpan) => T | Promise<T>): Promise<T>;
|
|
20
104
|
}
|
|
21
105
|
export interface TelemetrySpan extends TelemetryContext {
|
|
106
|
+
addLink(link: SpanLink): void;
|
|
22
107
|
addEvent(name: string, attributes?: SpanAttributes): void;
|
|
23
108
|
setAttributes(attributes: SpanAttributes): void;
|
|
24
109
|
setStatus(status: SpanStatus): void;
|
|
25
110
|
}
|
|
26
|
-
export {
|
|
111
|
+
export type { HistogramOptions, InstrumentOptions, SchemaTelemetryCounter, SchemaTelemetryHistogram, TelemetryCounter, TelemetryHistogram, TelemetryMetricAttributeDefinition, TelemetryMetricDefinition, TelemetryMetrics, TelemetryUpDownCounter, TypedTelemetryMetrics, } from "./metrics.ts";
|
|
112
|
+
export { createTypedMetrics } from "./metrics.ts";
|
|
113
|
+
export { NOOP_TELEMETRY_CONTEXT, NOOP_TELEMETRY_METRICS, NOOP_TELEMETRY_PROPAGATION } from "./noop.ts";
|
|
27
114
|
export type TelemetryAttributeType = "string" | "number" | "boolean" | "string[]" | "number[]" | "boolean[]";
|
|
28
115
|
export interface TelemetryAttributeMetadata {
|
|
29
116
|
description: string;
|
|
@@ -87,6 +174,7 @@ export interface TelemetrySpanDefinition {
|
|
|
87
174
|
export interface TelemetrySchemaDefinition {
|
|
88
175
|
version: number;
|
|
89
176
|
spans: Record<string, TelemetrySpanDefinition>;
|
|
177
|
+
metrics?: Record<string, TelemetryMetricDefinition>;
|
|
90
178
|
}
|
|
91
179
|
/** Typed identity helper for serializable telemetry schema data. */
|
|
92
180
|
export declare function defineTelemetrySchema<const T extends TelemetrySchemaDefinition>(schema: T): T;
|
|
@@ -189,6 +277,6 @@ export type TypedSpanStarter<Schemas extends TelemetrySchemaTuple> = UnionToInte
|
|
|
189
277
|
* Schema values are used only for type inference; no runtime schema validation is performed.
|
|
190
278
|
*/
|
|
191
279
|
export declare function createTypedSpanStarter<const Schemas extends TelemetrySchemaTuple>(telemetryContext: TelemetryContext, _schemas: Schemas & UniqueTelemetrySchemas<Schemas>): TypedSpanStarter<Schemas>;
|
|
192
|
-
export type { RecordedTelemetryEvent, RecordedTelemetrySpan } from "./memory.ts";
|
|
280
|
+
export type { RecordedTelemetryEvent, RecordedTelemetryLink, RecordedTelemetryMeasurement, RecordedTelemetrySpan, } from "./memory.ts";
|
|
193
281
|
export { InMemoryTelemetryContext } from "./memory.ts";
|
|
194
282
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,MAAM,EAAE,GAAG,SAAS,MAAM,EAAE,GAAG,SAAS,OAAO,EAAE,CAAC;AAEpH,MAAM,WAAW,cAAc;IAC9B,CAAC,IAAI,EAAE,MAAM,GAAG,cAAc,GAAG,SAAS,CAAC;CAC3C;AAED,MAAM,WAAW,WAAW;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,CAAC,EAAE,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AI,CAAC;CAC5E,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAC,CAC7B,CAAC;AAuBF;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,CAAC,OAAO,SAAS,oBAAoB,EAChF,gBAAgB,EAAE,gBAAgB,EAClC,QAAQ,EAAE,OAAO,GAAG,sBAAsB,CAAC,OAAO,CAAC,GACjD,gBAAgB,CAAC,OAAO,CAAC,CAE3B;AAED,YAAY,EACX,sBAAsB,EACtB,qBAAqB,EACrB,4BAA4B,EAC5B,qBAAqB,GACrB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { createTypedMetrics } from "./metrics.js";
|
|
2
|
+
export { NOOP_TELEMETRY_CONTEXT, NOOP_TELEMETRY_METRICS, NOOP_TELEMETRY_PROPAGATION } from "./noop.js";
|
|
2
3
|
/** Typed identity helper for serializable telemetry schema data. */
|
|
3
4
|
export function defineTelemetrySchema(schema) {
|
|
4
5
|
return schema;
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAuBA,OAAO,EAAE,sBAAsB,EAAE,MAAM,WAAW,CAAC;AA+CnD,oEAAoE;AACpE,MAAM,UAAU,qBAAqB,CAA4C,MAAS;IACzF,OAAO,MAAM,CAAC;AACf,CAAC;AA0PD,SAAS,oBAAoB,CAC5B,gBAAkC;IAElC,MAAM,SAAS,GAAG,CACjB,IAAgC,EAChC,UAA0B,EAC1B,QAGY,EACO,EAAE,CACrB,gBAAgB,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,EAAE,CAAC,IAAI,EAAE,EAAE,CACzD,QAAQ,CACP,IAAiE,EACjE,oBAAoB,CAAU,IAAI,CAAC,CACnC,CACD,CAAC;IAEH,OAAO,SAAsC,CAAC;AAC/C,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,sBAAsB,CACrC,gBAAkC,EAClC,QAAmD;IAEnD,OAAO,oBAAoB,CAAU,gBAAgB,CAAC,CAAC;AACxD,CAAC;AAGD,OAAO,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC","sourcesContent":["export type AttributeValue = string | number | boolean | readonly string[] | readonly number[] | readonly boolean[];\n\nexport interface SpanAttributes {\n\t[name: string]: AttributeValue | undefined;\n}\n\nexport interface SpanOptions {\n\tname: string;\n\tattributes?: SpanAttributes;\n}\n\nexport type SpanStatus = { status: \"ok\" } | { status: \"error\"; error?: { name: string; message: string } };\n\nexport interface TelemetryContext {\n\tstartSpan<T>(options: SpanOptions, callback: (span: TelemetrySpan) => T | Promise<T>): Promise<T>;\n}\n\nexport interface TelemetrySpan extends TelemetryContext {\n\taddEvent(name: string, attributes?: SpanAttributes): void;\n\tsetAttributes(attributes: SpanAttributes): void;\n\tsetStatus(status: SpanStatus): void;\n}\n\nexport { NOOP_TELEMETRY_CONTEXT } from \"./noop.ts\";\n\nexport type TelemetryAttributeType = \"string\" | \"number\" | \"boolean\" | \"string[]\" | \"number[]\" | \"boolean[]\";\n\nexport interface TelemetryAttributeMetadata {\n\tdescription: string;\n\tsensitive?: boolean;\n\tcardinality?: \"low\" | \"high\";\n}\n\nexport type TelemetryAttributeDefinition = TelemetryAttributeMetadata &\n\t(\n\t\t| { type: \"string\"; values?: readonly string[]; examples?: readonly string[] }\n\t\t| { type: \"number\"; values?: readonly number[]; examples?: readonly number[] }\n\t\t| { type: \"boolean\"; values?: readonly boolean[]; examples?: readonly boolean[] }\n\t\t| { type: \"string[]\"; elementValues?: readonly string[]; examples?: readonly (readonly string[])[] }\n\t\t| { type: \"number[]\"; elementValues?: readonly number[]; examples?: readonly (readonly number[])[] }\n\t\t| { type: \"boolean[]\"; elementValues?: readonly boolean[]; examples?: readonly (readonly boolean[])[] }\n\t);\n\nexport type TelemetryStartAttributeDefinition = TelemetryAttributeDefinition & { required: boolean };\nexport type TelemetryEventAttributeDefinition = TelemetryAttributeDefinition & { required: boolean };\n\nexport interface TelemetryEventDefinition {\n\tdescription: string;\n\tattributes: Record<string, TelemetryEventAttributeDefinition>;\n}\n\nexport type TelemetryParentDefinition =\n\t| { kind: \"any\" }\n\t| { kind: \"root_or_external\" }\n\t| { kind: \"spans\"; spans: readonly string[] };\n\nexport interface TelemetrySpanDefinition {\n\tdescription: string;\n\tparents: TelemetryParentDefinition;\n\tstartAttributes: Record<string, TelemetryStartAttributeDefinition>;\n\tendAttributes: Record<string, TelemetryAttributeDefinition>;\n\tevents?: Record<string, TelemetryEventDefinition>;\n\tstatus: { default: \"ok\"; errorWhen: string };\n}\n\nexport interface TelemetrySchemaDefinition {\n\tversion: number;\n\tspans: Record<string, TelemetrySpanDefinition>;\n}\n\n/** Typed identity helper for serializable telemetry schema data. */\nexport function defineTelemetrySchema<const T extends TelemetrySchemaDefinition>(schema: T): T {\n\treturn schema;\n}\n\ntype AttributeDefinitionValue<Definition extends TelemetryAttributeDefinition> = Definition extends {\n\ttype: \"string\";\n\tvalues: readonly (infer Value extends string)[];\n}\n\t? Value\n\t: Definition extends { type: \"string\" }\n\t\t? string\n\t\t: Definition extends { type: \"number\"; values: readonly (infer Value extends number)[] }\n\t\t\t? Value\n\t\t\t: Definition extends { type: \"number\" }\n\t\t\t\t? number\n\t\t\t\t: Definition extends { type: \"boolean\"; values: readonly (infer Value extends boolean)[] }\n\t\t\t\t\t? Value\n\t\t\t\t\t: Definition extends { type: \"boolean\" }\n\t\t\t\t\t\t? boolean\n\t\t\t\t\t\t: Definition extends {\n\t\t\t\t\t\t\t\t\ttype: \"string[]\";\n\t\t\t\t\t\t\t\t\telementValues: readonly (infer Value extends string)[];\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t? readonly Value[]\n\t\t\t\t\t\t\t: Definition extends { type: \"string[]\" }\n\t\t\t\t\t\t\t\t? readonly string[]\n\t\t\t\t\t\t\t\t: Definition extends {\n\t\t\t\t\t\t\t\t\t\t\ttype: \"number[]\";\n\t\t\t\t\t\t\t\t\t\t\telementValues: readonly (infer Value extends number)[];\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t? readonly Value[]\n\t\t\t\t\t\t\t\t\t: Definition extends { type: \"number[]\" }\n\t\t\t\t\t\t\t\t\t\t? readonly number[]\n\t\t\t\t\t\t\t\t\t\t: Definition extends {\n\t\t\t\t\t\t\t\t\t\t\t\t\ttype: \"boolean[]\";\n\t\t\t\t\t\t\t\t\t\t\t\t\telementValues: readonly (infer Value extends boolean)[];\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t? readonly Value[]\n\t\t\t\t\t\t\t\t\t\t\t: readonly boolean[];\n\ntype RequiredAttributeNames<\n\tDefinitions extends Record<string, TelemetryStartAttributeDefinition | TelemetryEventAttributeDefinition>,\n> = {\n\t[Name in keyof Definitions]-?: Definitions[Name][\"required\"] extends true ? Name : never;\n}[keyof Definitions];\n\ntype OptionalAttributeNames<\n\tDefinitions extends Record<string, TelemetryStartAttributeDefinition | TelemetryEventAttributeDefinition>,\n> = Exclude<keyof Definitions, RequiredAttributeNames<Definitions>>;\n\nexport type InferRequiredAndOptionalAttributes<\n\tDefinitions extends Record<string, TelemetryStartAttributeDefinition | TelemetryEventAttributeDefinition>,\n> = keyof Definitions extends never\n\t? Record<string, never>\n\t: {\n\t\t\t[Name in RequiredAttributeNames<Definitions>]: AttributeDefinitionValue<Definitions[Name]>;\n\t\t} & {\n\t\t\t[Name in OptionalAttributeNames<Definitions>]?: AttributeDefinitionValue<Definitions[Name]>;\n\t\t};\n\nexport type InferStartAttributes<Definitions extends Record<string, TelemetryStartAttributeDefinition>> =\n\tInferRequiredAndOptionalAttributes<Definitions>;\n\nexport type InferOptionalAttributes<Definitions extends Record<string, TelemetryAttributeDefinition>> =\n\tkeyof Definitions extends never\n\t\t? Record<string, never>\n\t\t: { [Name in keyof Definitions]?: AttributeDefinitionValue<Definitions[Name]> };\n\nexport type ExactTelemetryAttributes<Expected, Actual extends Expected> = Actual &\n\tRecord<Exclude<keyof Actual, keyof Expected>, never>;\n\nexport type InferEventAttributes<Definitions extends Record<string, TelemetryEventAttributeDefinition>> =\n\tInferRequiredAndOptionalAttributes<Definitions>;\n\nexport type TelemetrySchemaSpanName<Schema extends TelemetrySchemaDefinition> = keyof Schema[\"spans\"] & string;\n\ntype SchemaSpan<\n\tSchema extends TelemetrySchemaDefinition,\n\tName extends TelemetrySchemaSpanName<Schema>,\n> = Schema[\"spans\"][Name];\n\nexport type TelemetrySchemaSpanStartAttributes<\n\tSchema extends TelemetrySchemaDefinition,\n\tName extends TelemetrySchemaSpanName<Schema>,\n> = SchemaSpan<Schema, Name>[\"startAttributes\"] extends infer Definitions extends Record<\n\tstring,\n\tTelemetryStartAttributeDefinition\n>\n\t? InferStartAttributes<Definitions>\n\t: never;\n\nexport type TelemetrySchemaSpanEndAttributes<\n\tSchema extends TelemetrySchemaDefinition,\n\tName extends TelemetrySchemaSpanName<Schema>,\n> = SchemaSpan<Schema, Name>[\"endAttributes\"] extends infer Definitions extends Record<\n\tstring,\n\tTelemetryAttributeDefinition\n>\n\t? InferOptionalAttributes<Definitions>\n\t: never;\n\ntype SchemaSpanEvents<\n\tSchema extends TelemetrySchemaDefinition,\n\tName extends TelemetrySchemaSpanName<Schema>,\n> = SchemaSpan<Schema, Name> extends { events: infer Events extends Record<string, TelemetryEventDefinition> }\n\t? Events\n\t: Record<never, never>;\n\nexport type TelemetrySchemaSpanEventName<\n\tSchema extends TelemetrySchemaDefinition,\n\tName extends TelemetrySchemaSpanName<Schema>,\n> = keyof SchemaSpanEvents<Schema, Name> & string;\n\ntype SchemaSpanEvent<\n\tSchema extends TelemetrySchemaDefinition,\n\tName extends TelemetrySchemaSpanName<Schema>,\n\tEventName extends TelemetrySchemaSpanEventName<Schema, Name>,\n> = SchemaSpanEvents<Schema, Name> extends infer Events\n\t? EventName extends keyof Events\n\t\t? Events[EventName]\n\t\t: never\n\t: never;\n\nexport type TelemetrySchemaSpanEventAttributes<\n\tSchema extends TelemetrySchemaDefinition,\n\tName extends TelemetrySchemaSpanName<Schema>,\n\tEventName extends TelemetrySchemaSpanEventName<Schema, Name>,\n> = SchemaSpanEvent<Schema, Name, EventName> extends {\n\tattributes: infer Definitions extends Record<string, TelemetryEventAttributeDefinition>;\n}\n\t? InferEventAttributes<Definitions>\n\t: never;\n\ntype SchemaSpanEventAttributeDefinitions<\n\tSchema extends TelemetrySchemaDefinition,\n\tName extends TelemetrySchemaSpanName<Schema>,\n\tEventName extends TelemetrySchemaSpanEventName<Schema, Name>,\n> = SchemaSpanEvent<Schema, Name, EventName> extends {\n\tattributes: infer Definitions extends Record<string, TelemetryEventAttributeDefinition>;\n}\n\t? Definitions\n\t: Record<never, never>;\n\ntype EventArguments<\n\tDefinitions extends Record<string, TelemetryEventAttributeDefinition>,\n\tAttributes extends InferEventAttributes<Definitions>,\n> = [RequiredAttributeNames<Definitions>] extends [never]\n\t? [attributes?: ExactTelemetryAttributes<InferEventAttributes<Definitions>, Attributes>]\n\t: [attributes: ExactTelemetryAttributes<InferEventAttributes<Definitions>, Attributes>];\n\nexport type SchemaTelemetrySpan<\n\tSchema extends TelemetrySchemaDefinition,\n\tName extends TelemetrySchemaSpanName<Schema>,\n> = Omit<TelemetrySpan, \"addEvent\" | \"setAttributes\"> & {\n\taddEvent<\n\t\tEventName extends TelemetrySchemaSpanEventName<Schema, Name>,\n\t\tconst Attributes extends InferEventAttributes<\n\t\t\tSchemaSpanEventAttributeDefinitions<Schema, Name, EventName>\n\t\t> = InferEventAttributes<SchemaSpanEventAttributeDefinitions<Schema, Name, EventName>>,\n\t>(\n\t\tname: EventName,\n\t\t...args: EventArguments<SchemaSpanEventAttributeDefinitions<Schema, Name, EventName>, Attributes>\n\t): void;\n\tsetAttributes<const Attributes extends TelemetrySchemaSpanEndAttributes<Schema, Name>>(\n\t\tattributes: ExactTelemetryAttributes<TelemetrySchemaSpanEndAttributes<Schema, Name>, Attributes>,\n\t): void;\n};\n\nexport type TelemetrySchemaSpanUnion<Schema extends TelemetrySchemaDefinition> = {\n\t[Name in TelemetrySchemaSpanName<Schema>]: {\n\t\tname: Name;\n\t\tstartAttributes: TelemetrySchemaSpanStartAttributes<Schema, Name>;\n\t\tendAttributes: TelemetrySchemaSpanEndAttributes<Schema, Name>;\n\t\tevents: {\n\t\t\t[EventName in TelemetrySchemaSpanEventName<Schema, Name>]: TelemetrySchemaSpanEventAttributes<\n\t\t\t\tSchema,\n\t\t\t\tName,\n\t\t\t\tEventName\n\t\t\t>;\n\t\t};\n\t};\n}[TelemetrySchemaSpanName<Schema>];\n\ntype TelemetrySchemaTuple = readonly [TelemetrySchemaDefinition, ...TelemetrySchemaDefinition[]];\n\ntype SpanNameInSchema<Schema extends TelemetrySchemaDefinition> = Schema extends TelemetrySchemaDefinition\n\t? TelemetrySchemaSpanName<Schema>\n\t: never;\n\ntype SpanNameInSchemas<Schemas extends TelemetrySchemaTuple> = SpanNameInSchema<Schemas[number]>;\n\ntype SpanStartAttributesInSchema<\n\tSchema extends TelemetrySchemaDefinition,\n\tName extends string,\n> = Schema extends TelemetrySchemaDefinition\n\t? Name extends TelemetrySchemaSpanName<Schema>\n\t\t? TelemetrySchemaSpanStartAttributes<Schema, Name>\n\t\t: never\n\t: never;\n\ntype SpanInSchema<\n\tSchema extends TelemetrySchemaDefinition,\n\tName extends string,\n> = Schema extends TelemetrySchemaDefinition\n\t? Name extends TelemetrySchemaSpanName<Schema>\n\t\t? SchemaTelemetrySpan<Schema, Name>\n\t\t: never\n\t: never;\n\ntype DuplicateTelemetrySpanNames<\n\tSchemas extends readonly TelemetrySchemaDefinition[],\n\tSeen extends string = never,\n> = Schemas extends readonly [\n\tinfer Schema extends TelemetrySchemaDefinition,\n\t...infer Rest extends readonly TelemetrySchemaDefinition[],\n]\n\t?\n\t\t\t| Extract<TelemetrySchemaSpanName<Schema>, Seen>\n\t\t\t| DuplicateTelemetrySpanNames<Rest, Seen | TelemetrySchemaSpanName<Schema>>\n\t: never;\n\ntype UniqueTelemetrySchemas<Schemas extends TelemetrySchemaTuple> = [DuplicateTelemetrySpanNames<Schemas>] extends [\n\tnever,\n]\n\t? unknown\n\t: { readonly \"duplicate telemetry span names\": DuplicateTelemetrySpanNames<Schemas> };\n\ntype UnionToIntersection<Union> = (Union extends unknown ? (value: Union) => void : never) extends (\n\tvalue: infer Intersection,\n) => void\n\t? Intersection\n\t: never;\n\ntype TypedSpanStarterForName<Schemas extends TelemetrySchemaTuple, Name extends SpanNameInSchemas<Schemas>> = <\n\tconst Attributes extends SpanStartAttributesInSchema<Schemas[number], Name>,\n\tResult,\n>(\n\tname: Name,\n\tattributes: ExactTelemetryAttributes<SpanStartAttributesInSchema<Schemas[number], Name>, Attributes>,\n\tcallback: (\n\t\tspan: SpanInSchema<Schemas[number], Name>,\n\t\tstartChildSpan: TypedSpanStarter<Schemas>,\n\t) => Result | Promise<Result>,\n) => Promise<Result>;\n\n/** A per-span overload set bound to one explicit parent context and one or more schemas. */\nexport type TypedSpanStarter<Schemas extends TelemetrySchemaTuple> = UnionToIntersection<\n\t{\n\t\t[Name in SpanNameInSchemas<Schemas>]: TypedSpanStarterForName<Schemas, Name>;\n\t}[SpanNameInSchemas<Schemas>]\n>;\n\nfunction bindTypedSpanStarter<Schemas extends TelemetrySchemaTuple>(\n\ttelemetryContext: TelemetryContext,\n): TypedSpanStarter<Schemas> {\n\tconst startSpan = (\n\t\tname: SpanNameInSchemas<Schemas>,\n\t\tattributes: SpanAttributes,\n\t\tcallback: (\n\t\t\tspan: SpanInSchema<Schemas[number], SpanNameInSchemas<Schemas>>,\n\t\t\tstartChildSpan: TypedSpanStarter<Schemas>,\n\t\t) => unknown,\n\t): Promise<unknown> =>\n\t\ttelemetryContext.startSpan({ name, attributes }, (span) =>\n\t\t\tcallback(\n\t\t\t\tspan as SpanInSchema<Schemas[number], SpanNameInSchemas<Schemas>>,\n\t\t\t\tbindTypedSpanStarter<Schemas>(span),\n\t\t\t),\n\t\t);\n\n\treturn startSpan as TypedSpanStarter<Schemas>;\n}\n\n/**\n * Bind an explicit parent context to the combined span vocabulary of one or more schemas.\n * Schema values are used only for type inference; no runtime schema validation is performed.\n */\nexport function createTypedSpanStarter<const Schemas extends TelemetrySchemaTuple>(\n\ttelemetryContext: TelemetryContext,\n\t_schemas: Schemas & UniqueTelemetrySchemas<Schemas>,\n): TypedSpanStarter<Schemas> {\n\treturn bindTypedSpanStarter<Schemas>(telemetryContext);\n}\n\nexport type { RecordedTelemetryEvent, RecordedTelemetrySpan } from \"./memory.ts\";\nexport { InMemoryTelemetryContext } from \"./memory.ts\";\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AA4HA,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,EAAE,sBAAsB,EAAE,sBAAsB,EAAE,0BAA0B,EAAE,MAAM,WAAW,CAAC;AAgDvG,oEAAoE;AACpE,MAAM,UAAU,qBAAqB,CAA4C,MAAS;IACzF,OAAO,MAAM,CAAC;AACf,CAAC;AA0PD,SAAS,oBAAoB,CAC5B,gBAAkC;IAElC,MAAM,SAAS,GAAG,CACjB,IAAgC,EAChC,UAA0B,EAC1B,QAGY,EACO,EAAE,CACrB,gBAAgB,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,EAAE,CAAC,IAAI,EAAE,EAAE,CACzD,QAAQ,CACP,IAAiE,EACjE,oBAAoB,CAAU,IAAI,CAAC,CACnC,CACD,CAAC;IAEH,OAAO,SAAsC,CAAC;AAC/C,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,sBAAsB,CACrC,gBAAkC,EAClC,QAAmD;IAEnD,OAAO,oBAAoB,CAAU,gBAAgB,CAAC,CAAC;AACxD,CAAC;AAQD,OAAO,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC","sourcesContent":["import type { TelemetryMetricDefinition, TelemetryMetrics } from \"./metrics.ts\";\n\nexport type AttributeValue = string | number | boolean | readonly string[] | readonly number[] | readonly boolean[];\n\nexport interface SpanAttributes {\n\t[name: string]: AttributeValue | undefined;\n}\n\n/** Opaque, JSON-serializable adapter-owned propagation data. */\nexport type TelemetryCarrier = Record<string, string>;\n\n/** Optional transport capability implemented by the application's telemetry adapter. */\nexport interface TelemetryPropagation {\n\tinject(context: TelemetryContext): TelemetryCarrier | undefined;\n\t/** Absent or unknown carriers use the root; recognized identifiers are opaque strings. */\n\textract(carrier: TelemetryCarrier | undefined): TelemetryContext;\n}\n\nexport interface SpanLink {\n\tcontext: TelemetryContext;\n\tattributes?: SpanAttributes;\n}\n\nexport interface SpanOptions {\n\tname: string;\n\tattributes?: SpanAttributes;\n\tlinks?: readonly SpanLink[];\n}\n\nexport type SpanStatus = { status: \"ok\" } | { status: \"error\"; error?: { name: string; message: string } };\n\n/** A settled span snapshot, independent of the recording adapter. Event times are relative to span start. */\nexport interface StoredSpan {\n\treadonly id: string;\n\treadonly traceId: string;\n\treadonly parentId?: string;\n\treadonly name: string;\n\treadonly startedMs: number;\n\treadonly endedMs: number;\n\treadonly attributes: SpanAttributes;\n\treadonly events: readonly { readonly name: string; readonly timeMs: number; readonly attributes: SpanAttributes }[];\n\treadonly links: readonly {\n\t\treadonly traceId: string;\n\t\treadonly spanId: string;\n\t\treadonly attributes?: SpanAttributes;\n\t}[];\n\treadonly status: SpanStatus;\n}\n\nexport interface StoredTrace {\n\treadonly traceId: string;\n\treadonly spans: readonly StoredSpan[];\n}\n\nexport interface TraceQuery {\n\t/** Name of the earliest stored span, with span ID breaking timestamp ties. */\n\treadonly name?: string;\n\t/** All equalities must match one span; that span may be anywhere in the trace. */\n\treadonly attributes?: Readonly<Record<string, string | number | boolean>>;\n\treadonly errors?: true;\n\t/** Inclusive bounds on the earliest stored span's start time. */\n\treadonly startMin?: number;\n\treadonly startMax?: number;\n\t/** Positive page size; defaults to 20. */\n\treadonly limit?: number;\n\t/** Opaque continuation from the previous page; retain the same filters. */\n\treadonly cursor?: string;\n}\n\nexport interface MetricQuery {\n\treadonly name: string;\n\t/** Inclusive bounds on interval start time. */\n\treadonly startMin?: number;\n\treadonly startMax?: number;\n\treadonly attributes?: Readonly<Record<string, string | number | boolean>>;\n}\n\nexport interface StoredMetric {\n\treadonly intervalMs: number;\n\treadonly name: string;\n\treadonly kind: \"counter\" | \"upDownCounter\" | \"histogram\";\n\treadonly unit?: string;\n\treadonly attributes: SpanAttributes;\n\treadonly count: number;\n\treadonly sum: number;\n\treadonly min: number;\n\treadonly max: number;\n}\n\n/** Read settled traces without depending on a storage backend. */\nexport interface TelemetryStore {\n\tfindTraces(query?: TraceQuery): Promise<{ traces: readonly StoredTrace[]; cursor?: string }>;\n\tgetTrace(traceId: string): Promise<StoredTrace | undefined>;\n\tfindMetrics(query: MetricQuery): Promise<readonly StoredMetric[]>;\n}\n\n/** Adapter contract for trusted typed inputs; malformed input behavior is unspecified. */\nexport interface TelemetryContext {\n\t/** Adapter capabilities remain available on child spans and extracted parents. */\n\treadonly metrics?: TelemetryMetrics;\n\treadonly propagation?: TelemetryPropagation;\n\tstartSpan<T>(options: SpanOptions, callback: (span: TelemetrySpan) => T | Promise<T>): Promise<T>;\n}\n\nexport interface TelemetrySpan extends TelemetryContext {\n\taddLink(link: SpanLink): void;\n\taddEvent(name: string, attributes?: SpanAttributes): void;\n\tsetAttributes(attributes: SpanAttributes): void;\n\tsetStatus(status: SpanStatus): void;\n}\n\nexport type {\n\tHistogramOptions,\n\tInstrumentOptions,\n\tSchemaTelemetryCounter,\n\tSchemaTelemetryHistogram,\n\tTelemetryCounter,\n\tTelemetryHistogram,\n\tTelemetryMetricAttributeDefinition,\n\tTelemetryMetricDefinition,\n\tTelemetryMetrics,\n\tTelemetryUpDownCounter,\n\tTypedTelemetryMetrics,\n} from \"./metrics.ts\";\nexport { createTypedMetrics } from \"./metrics.ts\";\nexport { NOOP_TELEMETRY_CONTEXT, NOOP_TELEMETRY_METRICS, NOOP_TELEMETRY_PROPAGATION } from \"./noop.ts\";\n\nexport type TelemetryAttributeType = \"string\" | \"number\" | \"boolean\" | \"string[]\" | \"number[]\" | \"boolean[]\";\n\nexport interface TelemetryAttributeMetadata {\n\tdescription: string;\n\tsensitive?: boolean;\n\tcardinality?: \"low\" | \"high\";\n}\n\nexport type TelemetryAttributeDefinition = TelemetryAttributeMetadata &\n\t(\n\t\t| { type: \"string\"; values?: readonly string[]; examples?: readonly string[] }\n\t\t| { type: \"number\"; values?: readonly number[]; examples?: readonly number[] }\n\t\t| { type: \"boolean\"; values?: readonly boolean[]; examples?: readonly boolean[] }\n\t\t| { type: \"string[]\"; elementValues?: readonly string[]; examples?: readonly (readonly string[])[] }\n\t\t| { type: \"number[]\"; elementValues?: readonly number[]; examples?: readonly (readonly number[])[] }\n\t\t| { type: \"boolean[]\"; elementValues?: readonly boolean[]; examples?: readonly (readonly boolean[])[] }\n\t);\n\nexport type TelemetryStartAttributeDefinition = TelemetryAttributeDefinition & { required: boolean };\nexport type TelemetryEventAttributeDefinition = TelemetryAttributeDefinition & { required: boolean };\n\nexport interface TelemetryEventDefinition {\n\tdescription: string;\n\tattributes: Record<string, TelemetryEventAttributeDefinition>;\n}\n\nexport type TelemetryParentDefinition =\n\t| { kind: \"any\" }\n\t| { kind: \"root_or_external\" }\n\t| { kind: \"spans\"; spans: readonly string[] };\n\nexport interface TelemetrySpanDefinition {\n\tdescription: string;\n\tparents: TelemetryParentDefinition;\n\tstartAttributes: Record<string, TelemetryStartAttributeDefinition>;\n\tendAttributes: Record<string, TelemetryAttributeDefinition>;\n\tevents?: Record<string, TelemetryEventDefinition>;\n\tstatus: { default: \"ok\"; errorWhen: string };\n}\n\nexport interface TelemetrySchemaDefinition {\n\tversion: number;\n\tspans: Record<string, TelemetrySpanDefinition>;\n\tmetrics?: Record<string, TelemetryMetricDefinition>;\n}\n\n/** Typed identity helper for serializable telemetry schema data. */\nexport function defineTelemetrySchema<const T extends TelemetrySchemaDefinition>(schema: T): T {\n\treturn schema;\n}\n\ntype AttributeDefinitionValue<Definition extends TelemetryAttributeDefinition> = Definition extends {\n\ttype: \"string\";\n\tvalues: readonly (infer Value extends string)[];\n}\n\t? Value\n\t: Definition extends { type: \"string\" }\n\t\t? string\n\t\t: Definition extends { type: \"number\"; values: readonly (infer Value extends number)[] }\n\t\t\t? Value\n\t\t\t: Definition extends { type: \"number\" }\n\t\t\t\t? number\n\t\t\t\t: Definition extends { type: \"boolean\"; values: readonly (infer Value extends boolean)[] }\n\t\t\t\t\t? Value\n\t\t\t\t\t: Definition extends { type: \"boolean\" }\n\t\t\t\t\t\t? boolean\n\t\t\t\t\t\t: Definition extends {\n\t\t\t\t\t\t\t\t\ttype: \"string[]\";\n\t\t\t\t\t\t\t\t\telementValues: readonly (infer Value extends string)[];\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t? readonly Value[]\n\t\t\t\t\t\t\t: Definition extends { type: \"string[]\" }\n\t\t\t\t\t\t\t\t? readonly string[]\n\t\t\t\t\t\t\t\t: Definition extends {\n\t\t\t\t\t\t\t\t\t\t\ttype: \"number[]\";\n\t\t\t\t\t\t\t\t\t\t\telementValues: readonly (infer Value extends number)[];\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t? readonly Value[]\n\t\t\t\t\t\t\t\t\t: Definition extends { type: \"number[]\" }\n\t\t\t\t\t\t\t\t\t\t? readonly number[]\n\t\t\t\t\t\t\t\t\t\t: Definition extends {\n\t\t\t\t\t\t\t\t\t\t\t\t\ttype: \"boolean[]\";\n\t\t\t\t\t\t\t\t\t\t\t\t\telementValues: readonly (infer Value extends boolean)[];\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t? readonly Value[]\n\t\t\t\t\t\t\t\t\t\t\t: readonly boolean[];\n\ntype RequiredAttributeNames<\n\tDefinitions extends Record<string, TelemetryStartAttributeDefinition | TelemetryEventAttributeDefinition>,\n> = {\n\t[Name in keyof Definitions]-?: Definitions[Name][\"required\"] extends true ? Name : never;\n}[keyof Definitions];\n\ntype OptionalAttributeNames<\n\tDefinitions extends Record<string, TelemetryStartAttributeDefinition | TelemetryEventAttributeDefinition>,\n> = Exclude<keyof Definitions, RequiredAttributeNames<Definitions>>;\n\nexport type InferRequiredAndOptionalAttributes<\n\tDefinitions extends Record<string, TelemetryStartAttributeDefinition | TelemetryEventAttributeDefinition>,\n> = keyof Definitions extends never\n\t? Record<string, never>\n\t: {\n\t\t\t[Name in RequiredAttributeNames<Definitions>]: AttributeDefinitionValue<Definitions[Name]>;\n\t\t} & {\n\t\t\t[Name in OptionalAttributeNames<Definitions>]?: AttributeDefinitionValue<Definitions[Name]>;\n\t\t};\n\nexport type InferStartAttributes<Definitions extends Record<string, TelemetryStartAttributeDefinition>> =\n\tInferRequiredAndOptionalAttributes<Definitions>;\n\nexport type InferOptionalAttributes<Definitions extends Record<string, TelemetryAttributeDefinition>> =\n\tkeyof Definitions extends never\n\t\t? Record<string, never>\n\t\t: { [Name in keyof Definitions]?: AttributeDefinitionValue<Definitions[Name]> };\n\nexport type ExactTelemetryAttributes<Expected, Actual extends Expected> = Actual &\n\tRecord<Exclude<keyof Actual, keyof Expected>, never>;\n\nexport type InferEventAttributes<Definitions extends Record<string, TelemetryEventAttributeDefinition>> =\n\tInferRequiredAndOptionalAttributes<Definitions>;\n\nexport type TelemetrySchemaSpanName<Schema extends TelemetrySchemaDefinition> = keyof Schema[\"spans\"] & string;\n\ntype SchemaSpan<\n\tSchema extends TelemetrySchemaDefinition,\n\tName extends TelemetrySchemaSpanName<Schema>,\n> = Schema[\"spans\"][Name];\n\nexport type TelemetrySchemaSpanStartAttributes<\n\tSchema extends TelemetrySchemaDefinition,\n\tName extends TelemetrySchemaSpanName<Schema>,\n> = SchemaSpan<Schema, Name>[\"startAttributes\"] extends infer Definitions extends Record<\n\tstring,\n\tTelemetryStartAttributeDefinition\n>\n\t? InferStartAttributes<Definitions>\n\t: never;\n\nexport type TelemetrySchemaSpanEndAttributes<\n\tSchema extends TelemetrySchemaDefinition,\n\tName extends TelemetrySchemaSpanName<Schema>,\n> = SchemaSpan<Schema, Name>[\"endAttributes\"] extends infer Definitions extends Record<\n\tstring,\n\tTelemetryAttributeDefinition\n>\n\t? InferOptionalAttributes<Definitions>\n\t: never;\n\ntype SchemaSpanEvents<\n\tSchema extends TelemetrySchemaDefinition,\n\tName extends TelemetrySchemaSpanName<Schema>,\n> = SchemaSpan<Schema, Name> extends { events: infer Events extends Record<string, TelemetryEventDefinition> }\n\t? Events\n\t: Record<never, never>;\n\nexport type TelemetrySchemaSpanEventName<\n\tSchema extends TelemetrySchemaDefinition,\n\tName extends TelemetrySchemaSpanName<Schema>,\n> = keyof SchemaSpanEvents<Schema, Name> & string;\n\ntype SchemaSpanEvent<\n\tSchema extends TelemetrySchemaDefinition,\n\tName extends TelemetrySchemaSpanName<Schema>,\n\tEventName extends TelemetrySchemaSpanEventName<Schema, Name>,\n> = SchemaSpanEvents<Schema, Name> extends infer Events\n\t? EventName extends keyof Events\n\t\t? Events[EventName]\n\t\t: never\n\t: never;\n\nexport type TelemetrySchemaSpanEventAttributes<\n\tSchema extends TelemetrySchemaDefinition,\n\tName extends TelemetrySchemaSpanName<Schema>,\n\tEventName extends TelemetrySchemaSpanEventName<Schema, Name>,\n> = SchemaSpanEvent<Schema, Name, EventName> extends {\n\tattributes: infer Definitions extends Record<string, TelemetryEventAttributeDefinition>;\n}\n\t? InferEventAttributes<Definitions>\n\t: never;\n\ntype SchemaSpanEventAttributeDefinitions<\n\tSchema extends TelemetrySchemaDefinition,\n\tName extends TelemetrySchemaSpanName<Schema>,\n\tEventName extends TelemetrySchemaSpanEventName<Schema, Name>,\n> = SchemaSpanEvent<Schema, Name, EventName> extends {\n\tattributes: infer Definitions extends Record<string, TelemetryEventAttributeDefinition>;\n}\n\t? Definitions\n\t: Record<never, never>;\n\ntype EventArguments<\n\tDefinitions extends Record<string, TelemetryEventAttributeDefinition>,\n\tAttributes extends InferEventAttributes<Definitions>,\n> = [RequiredAttributeNames<Definitions>] extends [never]\n\t? [attributes?: ExactTelemetryAttributes<InferEventAttributes<Definitions>, Attributes>]\n\t: [attributes: ExactTelemetryAttributes<InferEventAttributes<Definitions>, Attributes>];\n\nexport type SchemaTelemetrySpan<\n\tSchema extends TelemetrySchemaDefinition,\n\tName extends TelemetrySchemaSpanName<Schema>,\n> = Omit<TelemetrySpan, \"addEvent\" | \"setAttributes\"> & {\n\taddEvent<\n\t\tEventName extends TelemetrySchemaSpanEventName<Schema, Name>,\n\t\tconst Attributes extends InferEventAttributes<\n\t\t\tSchemaSpanEventAttributeDefinitions<Schema, Name, EventName>\n\t\t> = InferEventAttributes<SchemaSpanEventAttributeDefinitions<Schema, Name, EventName>>,\n\t>(\n\t\tname: EventName,\n\t\t...args: EventArguments<SchemaSpanEventAttributeDefinitions<Schema, Name, EventName>, Attributes>\n\t): void;\n\tsetAttributes<const Attributes extends TelemetrySchemaSpanEndAttributes<Schema, Name>>(\n\t\tattributes: ExactTelemetryAttributes<TelemetrySchemaSpanEndAttributes<Schema, Name>, Attributes>,\n\t): void;\n};\n\nexport type TelemetrySchemaSpanUnion<Schema extends TelemetrySchemaDefinition> = {\n\t[Name in TelemetrySchemaSpanName<Schema>]: {\n\t\tname: Name;\n\t\tstartAttributes: TelemetrySchemaSpanStartAttributes<Schema, Name>;\n\t\tendAttributes: TelemetrySchemaSpanEndAttributes<Schema, Name>;\n\t\tevents: {\n\t\t\t[EventName in TelemetrySchemaSpanEventName<Schema, Name>]: TelemetrySchemaSpanEventAttributes<\n\t\t\t\tSchema,\n\t\t\t\tName,\n\t\t\t\tEventName\n\t\t\t>;\n\t\t};\n\t};\n}[TelemetrySchemaSpanName<Schema>];\n\ntype TelemetrySchemaTuple = readonly [TelemetrySchemaDefinition, ...TelemetrySchemaDefinition[]];\n\ntype SpanNameInSchema<Schema extends TelemetrySchemaDefinition> = Schema extends TelemetrySchemaDefinition\n\t? TelemetrySchemaSpanName<Schema>\n\t: never;\n\ntype SpanNameInSchemas<Schemas extends TelemetrySchemaTuple> = SpanNameInSchema<Schemas[number]>;\n\ntype SpanStartAttributesInSchema<\n\tSchema extends TelemetrySchemaDefinition,\n\tName extends string,\n> = Schema extends TelemetrySchemaDefinition\n\t? Name extends TelemetrySchemaSpanName<Schema>\n\t\t? TelemetrySchemaSpanStartAttributes<Schema, Name>\n\t\t: never\n\t: never;\n\ntype SpanInSchema<\n\tSchema extends TelemetrySchemaDefinition,\n\tName extends string,\n> = Schema extends TelemetrySchemaDefinition\n\t? Name extends TelemetrySchemaSpanName<Schema>\n\t\t? SchemaTelemetrySpan<Schema, Name>\n\t\t: never\n\t: never;\n\ntype DuplicateTelemetrySpanNames<\n\tSchemas extends readonly TelemetrySchemaDefinition[],\n\tSeen extends string = never,\n> = Schemas extends readonly [\n\tinfer Schema extends TelemetrySchemaDefinition,\n\t...infer Rest extends readonly TelemetrySchemaDefinition[],\n]\n\t?\n\t\t\t| Extract<TelemetrySchemaSpanName<Schema>, Seen>\n\t\t\t| DuplicateTelemetrySpanNames<Rest, Seen | TelemetrySchemaSpanName<Schema>>\n\t: never;\n\ntype UniqueTelemetrySchemas<Schemas extends TelemetrySchemaTuple> = [DuplicateTelemetrySpanNames<Schemas>] extends [\n\tnever,\n]\n\t? unknown\n\t: { readonly \"duplicate telemetry span names\": DuplicateTelemetrySpanNames<Schemas> };\n\ntype UnionToIntersection<Union> = (Union extends unknown ? (value: Union) => void : never) extends (\n\tvalue: infer Intersection,\n) => void\n\t? Intersection\n\t: never;\n\ntype TypedSpanStarterForName<Schemas extends TelemetrySchemaTuple, Name extends SpanNameInSchemas<Schemas>> = <\n\tconst Attributes extends SpanStartAttributesInSchema<Schemas[number], Name>,\n\tResult,\n>(\n\tname: Name,\n\tattributes: ExactTelemetryAttributes<SpanStartAttributesInSchema<Schemas[number], Name>, Attributes>,\n\tcallback: (\n\t\tspan: SpanInSchema<Schemas[number], Name>,\n\t\tstartChildSpan: TypedSpanStarter<Schemas>,\n\t) => Result | Promise<Result>,\n) => Promise<Result>;\n\n/** A per-span overload set bound to one explicit parent context and one or more schemas. */\nexport type TypedSpanStarter<Schemas extends TelemetrySchemaTuple> = UnionToIntersection<\n\t{\n\t\t[Name in SpanNameInSchemas<Schemas>]: TypedSpanStarterForName<Schemas, Name>;\n\t}[SpanNameInSchemas<Schemas>]\n>;\n\nfunction bindTypedSpanStarter<Schemas extends TelemetrySchemaTuple>(\n\ttelemetryContext: TelemetryContext,\n): TypedSpanStarter<Schemas> {\n\tconst startSpan = (\n\t\tname: SpanNameInSchemas<Schemas>,\n\t\tattributes: SpanAttributes,\n\t\tcallback: (\n\t\t\tspan: SpanInSchema<Schemas[number], SpanNameInSchemas<Schemas>>,\n\t\t\tstartChildSpan: TypedSpanStarter<Schemas>,\n\t\t) => unknown,\n\t): Promise<unknown> =>\n\t\ttelemetryContext.startSpan({ name, attributes }, (span) =>\n\t\t\tcallback(\n\t\t\t\tspan as SpanInSchema<Schemas[number], SpanNameInSchemas<Schemas>>,\n\t\t\t\tbindTypedSpanStarter<Schemas>(span),\n\t\t\t),\n\t\t);\n\n\treturn startSpan as TypedSpanStarter<Schemas>;\n}\n\n/**\n * Bind an explicit parent context to the combined span vocabulary of one or more schemas.\n * Schema values are used only for type inference; no runtime schema validation is performed.\n */\nexport function createTypedSpanStarter<const Schemas extends TelemetrySchemaTuple>(\n\ttelemetryContext: TelemetryContext,\n\t_schemas: Schemas & UniqueTelemetrySchemas<Schemas>,\n): TypedSpanStarter<Schemas> {\n\treturn bindTypedSpanStarter<Schemas>(telemetryContext);\n}\n\nexport type {\n\tRecordedTelemetryEvent,\n\tRecordedTelemetryLink,\n\tRecordedTelemetryMeasurement,\n\tRecordedTelemetrySpan,\n} from \"./memory.ts\";\nexport { InMemoryTelemetryContext } from \"./memory.ts\";\n"]}
|