@glassflow-ai/rius 0.1.0 → 0.2.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 +49 -0
- package/dist/index.cjs +340 -14
- package/dist/index.d.cts +52 -0
- package/dist/index.d.ts +52 -0
- package/dist/index.js +335 -10
- package/package.json +22 -2
package/dist/index.d.cts
CHANGED
|
@@ -5,6 +5,11 @@ import { SpanExporter } from '@opentelemetry/sdk-trace-base';
|
|
|
5
5
|
type Mask = (value: unknown, context?: {
|
|
6
6
|
key: string;
|
|
7
7
|
}) => unknown;
|
|
8
|
+
/**
|
|
9
|
+
* Configuration shared by every client. Each option can also come from a
|
|
10
|
+
* `RIUS_*` environment variable; explicit options win over the environment,
|
|
11
|
+
* which wins over defaults.
|
|
12
|
+
*/
|
|
8
13
|
interface RiusOptions {
|
|
9
14
|
endpoint?: string;
|
|
10
15
|
apiKey?: string;
|
|
@@ -13,12 +18,29 @@ interface RiusOptions {
|
|
|
13
18
|
sampleRate?: number;
|
|
14
19
|
captureContent?: boolean;
|
|
15
20
|
mask?: Mask;
|
|
21
|
+
/** Seconds between agent-lifetime heartbeat pings. */
|
|
22
|
+
heartbeatInterval?: number;
|
|
23
|
+
heartbeat?: boolean;
|
|
24
|
+
agentName?: string;
|
|
25
|
+
partialSpans?: boolean;
|
|
26
|
+
/** Seconds to debounce a pending-span snapshot after span start. */
|
|
27
|
+
partialSpansDelay?: number;
|
|
16
28
|
}
|
|
17
29
|
|
|
30
|
+
type HeartbeatTransport = (payload: Record<string, unknown>, timeoutMs: number) => Promise<void>;
|
|
31
|
+
|
|
32
|
+
/** Options accepted by {@link init}, extending the shared configuration. */
|
|
18
33
|
interface InitOptions extends RiusOptions {
|
|
19
34
|
/** Inject an exporter instead of OTLP. The test seam; prefer this to mocking. */
|
|
20
35
|
spanExporter?: SpanExporter;
|
|
36
|
+
/** Override the heartbeat HTTP transport. The test seam; prefer this to mocking fetch. */
|
|
37
|
+
heartbeatTransport?: HeartbeatTransport;
|
|
21
38
|
}
|
|
39
|
+
/**
|
|
40
|
+
* Handle over a configured tracer pipeline, returned by {@link init}.
|
|
41
|
+
* Exposes the lifecycle operations (`flush`, `shutdown`) and `ready`, which
|
|
42
|
+
* resolves with the auto-instrumentations that attached.
|
|
43
|
+
*/
|
|
22
44
|
declare class RiusClient {
|
|
23
45
|
private readonly provider;
|
|
24
46
|
private readonly health?;
|
|
@@ -30,13 +52,37 @@ declare class RiusClient {
|
|
|
30
52
|
/**
|
|
31
53
|
* Drains and tears down the provider, then releases the global registration
|
|
32
54
|
* so a later init() can reconfigure the SDK.
|
|
55
|
+
*
|
|
56
|
+
* The heartbeat's final `stopped: true` ping is sent before the provider
|
|
57
|
+
* shuts down, so the backend hears "stopped" while the trace pipeline can
|
|
58
|
+
* still export it. Idempotent: `sender.stop()` no-ops on a second call, and
|
|
59
|
+
* the `beforeExit` listener is removed here so repeated init/shutdown
|
|
60
|
+
* cycles never leak listeners.
|
|
33
61
|
*/
|
|
34
62
|
shutdown(): Promise<void>;
|
|
35
63
|
}
|
|
64
|
+
/**
|
|
65
|
+
* Initialize the SDK: build a tracer pipeline that exports OTLP traces and
|
|
66
|
+
* enable every bundled auto-instrumentation whose package is installed.
|
|
67
|
+
*
|
|
68
|
+
* Call it once, as early as possible in your process. A second call while a
|
|
69
|
+
* client is active logs a warning and returns the existing client unchanged;
|
|
70
|
+
* `shutdown()` releases the slot. `init()` is synchronous; await
|
|
71
|
+
* {@link RiusClient.ready} if instrumentation must be attached before your
|
|
72
|
+
* first span.
|
|
73
|
+
*
|
|
74
|
+
* The SDK installs no process exit hook: short-lived processes must call
|
|
75
|
+
* {@link RiusClient.flush} before exiting or spans still in the batch queue
|
|
76
|
+
* are lost.
|
|
77
|
+
*/
|
|
36
78
|
declare function init(options?: InitOptions): RiusClient;
|
|
37
79
|
/** The SDK tracer. Scope name is wire-visible; do not parameterize it. */
|
|
38
80
|
declare function getTracer(): Tracer;
|
|
39
81
|
|
|
82
|
+
/**
|
|
83
|
+
* Observation kind. Values are OpenInference `openinference.span.kind`
|
|
84
|
+
* values, the taxonomy the platform's agent analytics group by.
|
|
85
|
+
*/
|
|
40
86
|
declare enum SpanKind {
|
|
41
87
|
AGENT = "AGENT",
|
|
42
88
|
LLM = "LLM",
|
|
@@ -46,6 +92,7 @@ declare enum SpanKind {
|
|
|
46
92
|
CHAIN = "CHAIN"
|
|
47
93
|
}
|
|
48
94
|
|
|
95
|
+
/** Options for {@link startSpan} and {@link startAsCurrentSpan}. */
|
|
49
96
|
interface SpanOptions {
|
|
50
97
|
kind?: SpanKind;
|
|
51
98
|
input?: unknown;
|
|
@@ -88,6 +135,10 @@ type SpanBody<T> = (observation: Observation) => Promise<T> | T;
|
|
|
88
135
|
declare function startAsCurrentSpan<T>(name: string, fn: SpanBody<T>): Promise<T>;
|
|
89
136
|
declare function startAsCurrentSpan<T>(name: string, options: SpanOptions, fn: SpanBody<T>): Promise<T>;
|
|
90
137
|
|
|
138
|
+
/**
|
|
139
|
+
* Options for {@link startGeneration} and {@link startAsCurrentGeneration}:
|
|
140
|
+
* the model identity and request parameters an LLM span carries.
|
|
141
|
+
*/
|
|
91
142
|
interface GenerationOptions {
|
|
92
143
|
model?: string;
|
|
93
144
|
provider?: string;
|
|
@@ -136,6 +187,7 @@ type GenerationBody<T> = (generation: Generation) => Promise<T> | T;
|
|
|
136
187
|
declare function startAsCurrentGeneration<T>(name: string, fn: GenerationBody<T>): Promise<T>;
|
|
137
188
|
declare function startAsCurrentGeneration<T>(name: string, options: GenerationOptions, fn: GenerationBody<T>): Promise<T>;
|
|
138
189
|
|
|
190
|
+
/** Options for {@link observe}. */
|
|
139
191
|
interface ObserveOptions {
|
|
140
192
|
name?: string;
|
|
141
193
|
kind?: SpanKind;
|
package/dist/index.d.ts
CHANGED
|
@@ -5,6 +5,11 @@ import { SpanExporter } from '@opentelemetry/sdk-trace-base';
|
|
|
5
5
|
type Mask = (value: unknown, context?: {
|
|
6
6
|
key: string;
|
|
7
7
|
}) => unknown;
|
|
8
|
+
/**
|
|
9
|
+
* Configuration shared by every client. Each option can also come from a
|
|
10
|
+
* `RIUS_*` environment variable; explicit options win over the environment,
|
|
11
|
+
* which wins over defaults.
|
|
12
|
+
*/
|
|
8
13
|
interface RiusOptions {
|
|
9
14
|
endpoint?: string;
|
|
10
15
|
apiKey?: string;
|
|
@@ -13,12 +18,29 @@ interface RiusOptions {
|
|
|
13
18
|
sampleRate?: number;
|
|
14
19
|
captureContent?: boolean;
|
|
15
20
|
mask?: Mask;
|
|
21
|
+
/** Seconds between agent-lifetime heartbeat pings. */
|
|
22
|
+
heartbeatInterval?: number;
|
|
23
|
+
heartbeat?: boolean;
|
|
24
|
+
agentName?: string;
|
|
25
|
+
partialSpans?: boolean;
|
|
26
|
+
/** Seconds to debounce a pending-span snapshot after span start. */
|
|
27
|
+
partialSpansDelay?: number;
|
|
16
28
|
}
|
|
17
29
|
|
|
30
|
+
type HeartbeatTransport = (payload: Record<string, unknown>, timeoutMs: number) => Promise<void>;
|
|
31
|
+
|
|
32
|
+
/** Options accepted by {@link init}, extending the shared configuration. */
|
|
18
33
|
interface InitOptions extends RiusOptions {
|
|
19
34
|
/** Inject an exporter instead of OTLP. The test seam; prefer this to mocking. */
|
|
20
35
|
spanExporter?: SpanExporter;
|
|
36
|
+
/** Override the heartbeat HTTP transport. The test seam; prefer this to mocking fetch. */
|
|
37
|
+
heartbeatTransport?: HeartbeatTransport;
|
|
21
38
|
}
|
|
39
|
+
/**
|
|
40
|
+
* Handle over a configured tracer pipeline, returned by {@link init}.
|
|
41
|
+
* Exposes the lifecycle operations (`flush`, `shutdown`) and `ready`, which
|
|
42
|
+
* resolves with the auto-instrumentations that attached.
|
|
43
|
+
*/
|
|
22
44
|
declare class RiusClient {
|
|
23
45
|
private readonly provider;
|
|
24
46
|
private readonly health?;
|
|
@@ -30,13 +52,37 @@ declare class RiusClient {
|
|
|
30
52
|
/**
|
|
31
53
|
* Drains and tears down the provider, then releases the global registration
|
|
32
54
|
* so a later init() can reconfigure the SDK.
|
|
55
|
+
*
|
|
56
|
+
* The heartbeat's final `stopped: true` ping is sent before the provider
|
|
57
|
+
* shuts down, so the backend hears "stopped" while the trace pipeline can
|
|
58
|
+
* still export it. Idempotent: `sender.stop()` no-ops on a second call, and
|
|
59
|
+
* the `beforeExit` listener is removed here so repeated init/shutdown
|
|
60
|
+
* cycles never leak listeners.
|
|
33
61
|
*/
|
|
34
62
|
shutdown(): Promise<void>;
|
|
35
63
|
}
|
|
64
|
+
/**
|
|
65
|
+
* Initialize the SDK: build a tracer pipeline that exports OTLP traces and
|
|
66
|
+
* enable every bundled auto-instrumentation whose package is installed.
|
|
67
|
+
*
|
|
68
|
+
* Call it once, as early as possible in your process. A second call while a
|
|
69
|
+
* client is active logs a warning and returns the existing client unchanged;
|
|
70
|
+
* `shutdown()` releases the slot. `init()` is synchronous; await
|
|
71
|
+
* {@link RiusClient.ready} if instrumentation must be attached before your
|
|
72
|
+
* first span.
|
|
73
|
+
*
|
|
74
|
+
* The SDK installs no process exit hook: short-lived processes must call
|
|
75
|
+
* {@link RiusClient.flush} before exiting or spans still in the batch queue
|
|
76
|
+
* are lost.
|
|
77
|
+
*/
|
|
36
78
|
declare function init(options?: InitOptions): RiusClient;
|
|
37
79
|
/** The SDK tracer. Scope name is wire-visible; do not parameterize it. */
|
|
38
80
|
declare function getTracer(): Tracer;
|
|
39
81
|
|
|
82
|
+
/**
|
|
83
|
+
* Observation kind. Values are OpenInference `openinference.span.kind`
|
|
84
|
+
* values, the taxonomy the platform's agent analytics group by.
|
|
85
|
+
*/
|
|
40
86
|
declare enum SpanKind {
|
|
41
87
|
AGENT = "AGENT",
|
|
42
88
|
LLM = "LLM",
|
|
@@ -46,6 +92,7 @@ declare enum SpanKind {
|
|
|
46
92
|
CHAIN = "CHAIN"
|
|
47
93
|
}
|
|
48
94
|
|
|
95
|
+
/** Options for {@link startSpan} and {@link startAsCurrentSpan}. */
|
|
49
96
|
interface SpanOptions {
|
|
50
97
|
kind?: SpanKind;
|
|
51
98
|
input?: unknown;
|
|
@@ -88,6 +135,10 @@ type SpanBody<T> = (observation: Observation) => Promise<T> | T;
|
|
|
88
135
|
declare function startAsCurrentSpan<T>(name: string, fn: SpanBody<T>): Promise<T>;
|
|
89
136
|
declare function startAsCurrentSpan<T>(name: string, options: SpanOptions, fn: SpanBody<T>): Promise<T>;
|
|
90
137
|
|
|
138
|
+
/**
|
|
139
|
+
* Options for {@link startGeneration} and {@link startAsCurrentGeneration}:
|
|
140
|
+
* the model identity and request parameters an LLM span carries.
|
|
141
|
+
*/
|
|
91
142
|
interface GenerationOptions {
|
|
92
143
|
model?: string;
|
|
93
144
|
provider?: string;
|
|
@@ -136,6 +187,7 @@ type GenerationBody<T> = (generation: Generation) => Promise<T> | T;
|
|
|
136
187
|
declare function startAsCurrentGeneration<T>(name: string, fn: GenerationBody<T>): Promise<T>;
|
|
137
188
|
declare function startAsCurrentGeneration<T>(name: string, options: GenerationOptions, fn: GenerationBody<T>): Promise<T>;
|
|
138
189
|
|
|
190
|
+
/** Options for {@link observe}. */
|
|
139
191
|
interface ObserveOptions {
|
|
140
192
|
name?: string;
|
|
141
193
|
kind?: SpanKind;
|