@semiont/observability 0.5.2 → 0.5.4
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/dist/index.d.ts +20 -23
- package/dist/index.d.ts.map +1 -0
- package/dist/node.d.ts +4 -5
- package/dist/node.d.ts.map +1 -0
- package/dist/process-logger.d.ts +3 -6
- package/dist/process-logger.d.ts.map +1 -0
- package/dist/web.d.ts +3 -4
- package/dist/web.d.ts.map +1 -0
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import { Span, Attributes, SpanKind } from '@opentelemetry/api';
|
|
2
|
-
export { Attributes, Span, SpanKind, SpanStatusCode } from '@opentelemetry/api';
|
|
3
|
-
|
|
4
1
|
/**
|
|
5
2
|
* @semiont/observability — public API.
|
|
6
3
|
*
|
|
@@ -24,13 +21,13 @@ export { Attributes, Span, SpanKind, SpanStatusCode } from '@opentelemetry/api';
|
|
|
24
21
|
* tracer is a no-op, so `withSpan` is essentially free until
|
|
25
22
|
* `initObservability*()` runs.
|
|
26
23
|
*/
|
|
27
|
-
|
|
24
|
+
import { SpanKind, type Attributes, type Span } from '@opentelemetry/api';
|
|
28
25
|
/**
|
|
29
26
|
* Wrap an async block in a span. The span is started before `fn` runs and
|
|
30
27
|
* ended after it resolves or rejects; exceptions are recorded and the span
|
|
31
28
|
* status is set to ERROR. `kind` defaults to INTERNAL.
|
|
32
29
|
*/
|
|
33
|
-
declare function withSpan<T>(name: string, fn: (span: Span) => Promise<T> | T, options?: {
|
|
30
|
+
export declare function withSpan<T>(name: string, fn: (span: Span) => Promise<T> | T, options?: {
|
|
34
31
|
kind?: SpanKind;
|
|
35
32
|
attrs?: Attributes;
|
|
36
33
|
}): Promise<T>;
|
|
@@ -40,7 +37,7 @@ declare function withSpan<T>(name: string, fn: (span: Span) => Promise<T> | T, o
|
|
|
40
37
|
* the payload to subscribers. Additive — payloads without `_trace` parse
|
|
41
38
|
* unchanged.
|
|
42
39
|
*/
|
|
43
|
-
interface TraceCarrier {
|
|
40
|
+
export interface TraceCarrier {
|
|
44
41
|
/** W3C `traceparent` header value (`00-<traceId>-<spanId>-<flags>`). */
|
|
45
42
|
traceparent: string;
|
|
46
43
|
/** W3C `tracestate` header value (vendor-specific extensions). */
|
|
@@ -50,24 +47,24 @@ interface TraceCarrier {
|
|
|
50
47
|
* Read the active span's W3C traceparent (and tracestate). Returns
|
|
51
48
|
* `undefined` if no span is active.
|
|
52
49
|
*/
|
|
53
|
-
declare function getActiveTraceparent(): TraceCarrier | undefined;
|
|
50
|
+
export declare function getActiveTraceparent(): TraceCarrier | undefined;
|
|
54
51
|
/**
|
|
55
52
|
* Attach the active span's trace-context to a payload object as
|
|
56
53
|
* `_trace`. No-op when no span is active. Returns the same object
|
|
57
54
|
* reference for chaining.
|
|
58
55
|
*/
|
|
59
|
-
declare function injectTraceparent<T extends Record<string, unknown>>(payload: T): T;
|
|
56
|
+
export declare function injectTraceparent<T extends Record<string, unknown>>(payload: T): T;
|
|
60
57
|
/**
|
|
61
58
|
* Strip and return the `_trace` field from a payload. Mutates `payload`.
|
|
62
59
|
* The field is internal plumbing and should not be visible to subscribers.
|
|
63
60
|
*/
|
|
64
|
-
declare function extractTraceparent<T extends Record<string, unknown>>(payload: T): TraceCarrier | undefined;
|
|
61
|
+
export declare function extractTraceparent<T extends Record<string, unknown>>(payload: T): TraceCarrier | undefined;
|
|
65
62
|
/**
|
|
66
63
|
* Run `fn` with the given W3C traceparent set as the parent context.
|
|
67
64
|
* Any spans started inside `fn` will be children of the incoming trace.
|
|
68
65
|
* No-op if `carrier` is undefined.
|
|
69
66
|
*/
|
|
70
|
-
declare function withTraceparent<T>(carrier: TraceCarrier | undefined, fn: () => T): T;
|
|
67
|
+
export declare function withTraceparent<T>(carrier: TraceCarrier | undefined, fn: () => T): T;
|
|
71
68
|
/**
|
|
72
69
|
* Wrap a bus-event handler in an `actor.<name>:<channel>` consumer span.
|
|
73
70
|
* Used at every `eventBus.get(channel).subscribe(handler)` site inside
|
|
@@ -80,7 +77,7 @@ declare function withTraceparent<T>(carrier: TraceCarrier | undefined, fn: () =>
|
|
|
80
77
|
* (Subject.next runs synchronously inside the dispatch span), or the
|
|
81
78
|
* `bus.emit:<channel>` span when an actor emits to itself.
|
|
82
79
|
*/
|
|
83
|
-
declare function withActorSpan<T>(actor: string, channel: string, fn: (span: Span) => Promise<T> | T, extraAttrs?: Attributes): Promise<T>;
|
|
80
|
+
export declare function withActorSpan<T>(actor: string, channel: string, fn: (span: Span) => Promise<T> | T, extraAttrs?: Attributes): Promise<T>;
|
|
84
81
|
/**
|
|
85
82
|
* Read the active span's `trace_id` / `span_id` for log-line correlation.
|
|
86
83
|
* Tier 3 of `.plans/OBSERVABILITY.md`. Each structured log line gets
|
|
@@ -90,12 +87,12 @@ declare function withActorSpan<T>(actor: string, channel: string, fn: (span: Spa
|
|
|
90
87
|
* Returns `undefined` if no span is active, or if the active span's
|
|
91
88
|
* context is invalid (uninitialized SDK, no-op tracer).
|
|
92
89
|
*/
|
|
93
|
-
declare function getLogTraceContext(): {
|
|
90
|
+
export declare function getLogTraceContext(): {
|
|
94
91
|
trace_id: string;
|
|
95
92
|
span_id: string;
|
|
96
93
|
} | undefined;
|
|
97
94
|
/** Snapshot of job-queue contents by status. Match `JobQueue.getStats()`. */
|
|
98
|
-
interface JobQueueSnapshot {
|
|
95
|
+
export interface JobQueueSnapshot {
|
|
99
96
|
pending: number;
|
|
100
97
|
running: number;
|
|
101
98
|
complete: number;
|
|
@@ -103,15 +100,15 @@ interface JobQueueSnapshot {
|
|
|
103
100
|
cancelled: number;
|
|
104
101
|
}
|
|
105
102
|
/** Increment the bus-emit counter. Called at every transport `emit` site. */
|
|
106
|
-
declare function recordBusEmit(channel: string, scope?: string): void;
|
|
103
|
+
export declare function recordBusEmit(channel: string, scope?: string): void;
|
|
107
104
|
/** Record an in-process actor handler's duration. */
|
|
108
|
-
declare function recordHandlerDuration(actor: string, channel: string, durationMs: number): void;
|
|
105
|
+
export declare function recordHandlerDuration(actor: string, channel: string, durationMs: number): void;
|
|
109
106
|
/** Record a worker job's outcome and duration. */
|
|
110
|
-
declare function recordJobOutcome(jobType: string, outcome: 'completed' | 'failed', durationMs: number): void;
|
|
107
|
+
export declare function recordJobOutcome(jobType: string, outcome: 'completed' | 'failed', durationMs: number): void;
|
|
111
108
|
/** Increment the SSE subscriber gauge — call on `/bus/subscribe` open. */
|
|
112
|
-
declare function recordSubscriberConnect(): void;
|
|
109
|
+
export declare function recordSubscriberConnect(): void;
|
|
113
110
|
/** Decrement on disconnect. Pair with `recordSubscriberConnect`. */
|
|
114
|
-
declare function recordSubscriberDisconnect(): void;
|
|
111
|
+
export declare function recordSubscriberDisconnect(): void;
|
|
115
112
|
/**
|
|
116
113
|
* Register a callback that returns the current job-queue snapshot.
|
|
117
114
|
* Polled at the SDK's metric-collection interval. The single gauge
|
|
@@ -119,19 +116,19 @@ declare function recordSubscriberDisconnect(): void;
|
|
|
119
116
|
* with the `job.status` attribute. Idempotent — last registered
|
|
120
117
|
* provider wins.
|
|
121
118
|
*/
|
|
122
|
-
declare function registerJobQueueProvider(provider: () => Promise<JobQueueSnapshot> | JobQueueSnapshot): void;
|
|
119
|
+
export declare function registerJobQueueProvider(provider: () => Promise<JobQueueSnapshot> | JobQueueSnapshot): void;
|
|
123
120
|
/**
|
|
124
121
|
* Register a callback that returns the current vector-index size
|
|
125
122
|
* (point count). Async to allow remote queries (Qdrant). Polled at
|
|
126
123
|
* the metric-collection interval.
|
|
127
124
|
*/
|
|
128
|
-
declare function registerVectorIndexSizeProvider(provider: () => Promise<number> | number): void;
|
|
125
|
+
export declare function registerVectorIndexSizeProvider(provider: () => Promise<number> | number): void;
|
|
129
126
|
/**
|
|
130
127
|
* Record an inference call. Token counts are optional — providers that
|
|
131
128
|
* don't expose them (or fail before generating) record only call count
|
|
132
129
|
* and duration.
|
|
133
130
|
*/
|
|
134
|
-
declare function recordInferenceUsage(opts: {
|
|
131
|
+
export declare function recordInferenceUsage(opts: {
|
|
135
132
|
provider: string;
|
|
136
133
|
model: string;
|
|
137
134
|
durationMs: number;
|
|
@@ -139,5 +136,5 @@ declare function recordInferenceUsage(opts: {
|
|
|
139
136
|
inputTokens?: number;
|
|
140
137
|
outputTokens?: number;
|
|
141
138
|
}): void;
|
|
142
|
-
|
|
143
|
-
|
|
139
|
+
export { SpanKind, SpanStatusCode, type Attributes, type Span } from '@opentelemetry/api';
|
|
140
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,EAKL,QAAQ,EAGR,KAAK,UAAU,EAIf,KAAK,IAAI,EAEV,MAAM,oBAAoB,CAAC;AAqB5B;;;;GAIG;AACH,wBAAsB,QAAQ,CAAC,CAAC,EAC9B,IAAI,EAAE,MAAM,EACZ,EAAE,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,EAClC,OAAO,CAAC,EAAE;IAAE,IAAI,CAAC,EAAE,QAAQ,CAAC;IAAC,KAAK,CAAC,EAAE,UAAU,CAAA;CAAE,GAChD,OAAO,CAAC,CAAC,CAAC,CAiBZ;AAMD;;;;;GAKG;AACH,MAAM,WAAW,YAAY;IAC3B,wEAAwE;IACxE,WAAW,EAAE,MAAM,CAAC;IACpB,kEAAkE;IAClE,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,IAAI,YAAY,GAAG,SAAS,CAQ/D;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,EAAE,CAAC,GAAG,CAAC,CAMlF;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,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uBAAuB,IAAI,IAAI,CAE9C;AAED,oEAAoE;AACpE,wBAAgB,0BAA0B,IAAI,IAAI,CAEjD;AAED;;;;;;GAMG;AACH,wBAAgB,wBAAwB,CACtC,QAAQ,EAAE,MAAM,OAAO,CAAC,gBAAgB,CAAC,GAAG,gBAAgB,GAC3D,IAAI,CAgBN;AAED;;;;GAIG;AACH,wBAAgB,+BAA+B,CAC7C,QAAQ,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,GAAG,MAAM,GACvC,IAAI,CAaN;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE;IACzC,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,SAAS,GAAG,OAAO,CAAC;IAC7B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,GAAG,IAAI,CAsBP;AAID,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,KAAK,UAAU,EAAE,KAAK,IAAI,EAAE,MAAM,oBAAoB,CAAC"}
|
package/dist/node.d.ts
CHANGED
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
* SDKs, forcing npm to nest duplicate copies of the stable packages and
|
|
25
25
|
* blowing up bundles for every consumer.
|
|
26
26
|
*/
|
|
27
|
-
interface NodeObservabilityConfig {
|
|
27
|
+
export interface NodeObservabilityConfig {
|
|
28
28
|
/** Service identity (e.g. `semiont-backend`). Overridden by `OTEL_SERVICE_NAME`. */
|
|
29
29
|
serviceName: string;
|
|
30
30
|
/** Service version. Defaults to `0.0.0` if omitted. */
|
|
@@ -39,8 +39,7 @@ interface NodeObservabilityConfig {
|
|
|
39
39
|
* Metrics export at `OTEL_METRIC_EXPORT_INTERVAL` ms (default 30s) to
|
|
40
40
|
* the same `OTEL_EXPORTER_OTLP_ENDPOINT` as traces.
|
|
41
41
|
*/
|
|
42
|
-
declare function initObservabilityNode(config: NodeObservabilityConfig): boolean;
|
|
42
|
+
export declare function initObservabilityNode(config: NodeObservabilityConfig): boolean;
|
|
43
43
|
/** Force-flush + shutdown both SDKs. Test cleanup, not production. */
|
|
44
|
-
declare function shutdownObservabilityNode(): Promise<void>;
|
|
45
|
-
|
|
46
|
-
export { type NodeObservabilityConfig, initObservabilityNode, shutdownObservabilityNode };
|
|
44
|
+
export declare function shutdownObservabilityNode(): Promise<void>;
|
|
45
|
+
//# sourceMappingURL=node.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../src/node.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAuBH,MAAM,WAAW,uBAAuB;IACtC,oFAAoF;IACpF,WAAW,EAAE,MAAM,CAAC;IACpB,uDAAuD;IACvD,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAWD;;;;;;;;GAQG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,uBAAuB,GAAG,OAAO,CAyE9E;AAED,sEAAsE;AACtE,wBAAsB,yBAAyB,IAAI,OAAO,CAAC,IAAI,CAAC,CAO/D"}
|
package/dist/process-logger.d.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { Logger } from '@semiont/core';
|
|
2
|
-
|
|
3
1
|
/**
|
|
4
2
|
* Process-level structured logger for Node entry points.
|
|
5
3
|
*
|
|
@@ -17,7 +15,6 @@ import { Logger } from '@semiont/core';
|
|
|
17
15
|
* only reasonably-shaped consumer of that helper, and putting them in
|
|
18
16
|
* the same package keeps the trace-id wiring in one place.
|
|
19
17
|
*/
|
|
20
|
-
|
|
21
|
-
declare function createProcessLogger(component: string): Logger;
|
|
22
|
-
|
|
23
|
-
export { createProcessLogger };
|
|
18
|
+
import type { Logger } from '@semiont/core';
|
|
19
|
+
export declare function createProcessLogger(component: string): Logger;
|
|
20
|
+
//# sourceMappingURL=process-logger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"process-logger.d.ts","sourceRoot":"","sources":["../src/process-logger.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAGH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAY5C,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CA2B7D"}
|
package/dist/web.d.ts
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
* Without an `otlpEndpoint`, falls back to a console exporter (visible
|
|
11
11
|
* in DevTools).
|
|
12
12
|
*/
|
|
13
|
-
interface WebObservabilityConfig {
|
|
13
|
+
export interface WebObservabilityConfig {
|
|
14
14
|
/** Service identity (e.g. `semiont-frontend`). */
|
|
15
15
|
serviceName: string;
|
|
16
16
|
/** Service version. */
|
|
@@ -32,6 +32,5 @@ interface WebObservabilityConfig {
|
|
|
32
32
|
* Initialize OTel for the SPA. Idempotent. Returns `true` if the SDK
|
|
33
33
|
* started, `false` if disabled or already initialized.
|
|
34
34
|
*/
|
|
35
|
-
declare function initObservabilityWeb(config: WebObservabilityConfig): boolean;
|
|
36
|
-
|
|
37
|
-
export { type WebObservabilityConfig, initObservabilityWeb };
|
|
35
|
+
export declare function initObservabilityWeb(config: WebObservabilityConfig): boolean;
|
|
36
|
+
//# sourceMappingURL=web.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"web.d.ts","sourceRoot":"","sources":["../src/web.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAcH,MAAM,WAAW,sBAAsB;IACrC,kDAAkD;IAClD,WAAW,EAAE,MAAM,CAAC;IACpB,uBAAuB;IACvB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,6CAA6C;IAC7C,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACrC;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAID;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,sBAAsB,GAAG,OAAO,CAwB5E"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@semiont/observability",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.4",
|
|
4
4
|
"description": "OpenTelemetry-based tracing for Semiont — Tier 2 of OBSERVABILITY.md. Process-init helpers (Node + Web), withSpan helper, W3C traceparent inject/extract for bus payloads. No-op when no exporter is configured.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"scripts": {
|
|
47
47
|
"pretypecheck": "npm run build --workspace=@semiont/core --if-present",
|
|
48
48
|
"typecheck": "tsc --noEmit",
|
|
49
|
-
"build": "npm run typecheck && tsup",
|
|
49
|
+
"build": "npm run typecheck && tsup && tsc -p tsconfig.build.json",
|
|
50
50
|
"watch": "tsup --watch",
|
|
51
51
|
"clean": "rm -rf dist *.tsbuildinfo",
|
|
52
52
|
"test": "vitest run",
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
"license": "Apache-2.0",
|
|
57
57
|
"devDependencies": {
|
|
58
58
|
"tsup": "^8.5.1",
|
|
59
|
-
"typescript": "^
|
|
59
|
+
"typescript": "^6.0.2",
|
|
60
60
|
"vitest": "^4.1.0"
|
|
61
61
|
},
|
|
62
62
|
"dependencies": {
|