@rasputin-ai/elysia 0.13.1 → 0.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +42 -23
- package/dist/rasputin-init.d.ts +13 -4
- package/dist/rasputin-init.d.ts.map +1 -1
- package/dist/sdk-meta.d.ts +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -10,10 +10,13 @@ import {
|
|
|
10
10
|
} from "@rasputin-ai/core";
|
|
11
11
|
import {
|
|
12
12
|
bindAdaptiveRecorder,
|
|
13
|
+
bindExecutionMetrics,
|
|
13
14
|
bindFunctionMetrics,
|
|
15
|
+
createDynamicDurationSampleBuckets,
|
|
14
16
|
createExecutionRecorder,
|
|
15
17
|
installAutomaticExecutionRuntime,
|
|
16
18
|
installGlobalHandlers,
|
|
19
|
+
releaseExecutionMetricsBindings,
|
|
17
20
|
releaseFunctionMetricsBindings,
|
|
18
21
|
scheduleInstrumentationManifestUpload
|
|
19
22
|
} from "@rasputin-ai/node/internal";
|
|
@@ -21,7 +24,7 @@ import { Elysia } from "elysia";
|
|
|
21
24
|
|
|
22
25
|
// src/sdk-meta.ts
|
|
23
26
|
var SDK_NAME = "@rasputin-ai/elysia";
|
|
24
|
-
var SDK_VERSION = "0.
|
|
27
|
+
var SDK_VERSION = "0.15.0";
|
|
25
28
|
|
|
26
29
|
// src/rasputin-init.ts
|
|
27
30
|
var publicExecution = (runtime) => ({
|
|
@@ -37,7 +40,7 @@ var publicExecution = (runtime) => ({
|
|
|
37
40
|
getStats: runtime.getStats
|
|
38
41
|
});
|
|
39
42
|
var withExecution = (client, runtime, installRuntime, manifest, uninstallHandlers = () => {
|
|
40
|
-
}, policy, metrics) => {
|
|
43
|
+
}, policy, metrics, executionMetrics) => {
|
|
41
44
|
const uninstallRuntime = installRuntime ? installAutomaticExecutionRuntime(runtime) : () => {
|
|
42
45
|
};
|
|
43
46
|
const manifestUpload = scheduleInstrumentationManifestUpload({
|
|
@@ -62,11 +65,13 @@ var withExecution = (client, runtime, installRuntime, manifest, uninstallHandler
|
|
|
62
65
|
if (timeoutMs === void 0) {
|
|
63
66
|
await policy?.flush();
|
|
64
67
|
await metrics?.exporter.flush();
|
|
68
|
+
await executionMetrics?.exporter.flush();
|
|
65
69
|
await manifestUpload.wait();
|
|
66
70
|
return;
|
|
67
71
|
}
|
|
68
72
|
await policy?.flush(Math.max(0, timeoutMs - (Date.now() - startedAt)));
|
|
69
73
|
await metrics?.exporter.flush(Math.max(0, timeoutMs - (Date.now() - startedAt)));
|
|
74
|
+
await executionMetrics?.exporter.flush(Math.max(0, timeoutMs - (Date.now() - startedAt)));
|
|
70
75
|
await manifestUpload.wait(Math.max(0, timeoutMs - (Date.now() - startedAt)));
|
|
71
76
|
},
|
|
72
77
|
close: async () => {
|
|
@@ -77,6 +82,7 @@ var withExecution = (client, runtime, installRuntime, manifest, uninstallHandler
|
|
|
77
82
|
const startedAt = Date.now();
|
|
78
83
|
await policy?.close();
|
|
79
84
|
await releaseFunctionMetricsBindings(metrics);
|
|
85
|
+
await releaseExecutionMetricsBindings(executionMetrics);
|
|
80
86
|
await client.close();
|
|
81
87
|
await manifestUpload.wait(Math.max(0, 2e3 - (Date.now() - startedAt)));
|
|
82
88
|
}
|
|
@@ -195,15 +201,27 @@ function RasputinInit(options, hooks = {}) {
|
|
|
195
201
|
environment: options.environment
|
|
196
202
|
});
|
|
197
203
|
const recorderEnabled = enabled && options.executionRecorder?.enabled !== false;
|
|
204
|
+
const durationSampling = options.dynamicDurationSampling === true;
|
|
198
205
|
const metrics = activation.enabled ? bindFunctionMetrics({
|
|
199
|
-
options: options.functionMetrics,
|
|
200
206
|
clientEnabled: true,
|
|
201
207
|
environment: activation.environment,
|
|
202
208
|
release: activation.release,
|
|
203
209
|
ingestToken: activation.ingestToken,
|
|
204
210
|
apiUrl: activation.apiUrl,
|
|
205
|
-
fetch
|
|
211
|
+
fetch,
|
|
212
|
+
sampledMeasurementFormat: durationSampling
|
|
213
|
+
}) : void 0;
|
|
214
|
+
const executionMetrics = activation.enabled ? bindExecutionMetrics({
|
|
215
|
+
clientEnabled: true,
|
|
216
|
+
environment: activation.environment,
|
|
217
|
+
release: activation.release,
|
|
218
|
+
ingestToken: activation.ingestToken,
|
|
219
|
+
apiUrl: activation.apiUrl,
|
|
220
|
+
fetch,
|
|
221
|
+
sampledMeasurementFormat: durationSampling
|
|
206
222
|
}) : void 0;
|
|
223
|
+
const observeExecutions = recorderEnabled || Boolean(metrics) || Boolean(executionMetrics);
|
|
224
|
+
const durationSampler = durationSampling && observeExecutions ? createDynamicDurationSampleBuckets({ nowMs: () => Date.now() }) : void 0;
|
|
207
225
|
const { runtime, policy } = bindAdaptiveRecorder({
|
|
208
226
|
executionRecorder: options.executionRecorder,
|
|
209
227
|
recorderEnabled,
|
|
@@ -217,7 +235,9 @@ function RasputinInit(options, hooks = {}) {
|
|
|
217
235
|
sdkName: SDK_NAME,
|
|
218
236
|
sdkVersion: SDK_VERSION,
|
|
219
237
|
scrubPII: options.scrubPII,
|
|
220
|
-
functionMetrics: metrics?.collector
|
|
238
|
+
functionMetrics: metrics?.collector,
|
|
239
|
+
executionMetrics: executionMetrics?.collector,
|
|
240
|
+
durationSampler
|
|
221
241
|
});
|
|
222
242
|
const client = createClient(options, {
|
|
223
243
|
fetch,
|
|
@@ -233,7 +253,7 @@ function RasputinInit(options, hooks = {}) {
|
|
|
233
253
|
const { client: wrappedClient, startManifestUpload } = withExecution(
|
|
234
254
|
client,
|
|
235
255
|
runtime,
|
|
236
|
-
|
|
256
|
+
observeExecutions,
|
|
237
257
|
{
|
|
238
258
|
projectApiKey: options.projectApiKey,
|
|
239
259
|
release: options.release,
|
|
@@ -246,27 +266,26 @@ function RasputinInit(options, hooks = {}) {
|
|
|
246
266
|
},
|
|
247
267
|
() => uninstallHandlers(),
|
|
248
268
|
policy,
|
|
249
|
-
metrics
|
|
269
|
+
metrics,
|
|
270
|
+
executionMetrics
|
|
250
271
|
);
|
|
251
272
|
if (enabled && installProcessHandlers) {
|
|
252
273
|
uninstallHandlers = installGlobalHandlers(wrappedClient);
|
|
253
274
|
}
|
|
254
|
-
const plugin = buildPlugin(wrappedClient, runtime,
|
|
255
|
-
()
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
}
|
|
269
|
-
);
|
|
275
|
+
const plugin = buildPlugin(wrappedClient, runtime, observeExecutions).onStart(() => {
|
|
276
|
+
startManifestUpload();
|
|
277
|
+
if (!enabled || announceDeploy === false) return;
|
|
278
|
+
const parsed = parseDsn(options.dsn);
|
|
279
|
+
const apiUrl = typeof options.apiUrl === "string" && options.apiUrl.trim() ? options.apiUrl.trim() : parsed?.apiUrl;
|
|
280
|
+
if (!apiUrl) return;
|
|
281
|
+
scheduleAnnounceDeploy({
|
|
282
|
+
deployUrl: resolveEndpointUrls(apiUrl).deployUrl,
|
|
283
|
+
projectApiKey: options.projectApiKey,
|
|
284
|
+
environment: options.environment,
|
|
285
|
+
release: options.release,
|
|
286
|
+
fetch
|
|
287
|
+
});
|
|
288
|
+
});
|
|
270
289
|
return {
|
|
271
290
|
client: wrappedClient,
|
|
272
291
|
plugin
|
package/dist/rasputin-init.d.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* intentionally limited to lifecycle wiring; recording, serialization, and safety policy stay in
|
|
5
5
|
* the framework-neutral Node recorder.
|
|
6
6
|
*/
|
|
7
|
-
import { type
|
|
7
|
+
import { type RasputinOptions } from '@rasputin-ai/core';
|
|
8
8
|
import type { ExecutionRecorderOptions, RasputinNodeClient } from '@rasputin-ai/node';
|
|
9
9
|
import { type ExecutionRuntime } from '@rasputin-ai/node/internal';
|
|
10
10
|
import { Elysia } from 'elysia';
|
|
@@ -35,10 +35,19 @@ export type RasputinElysiaOptions = RasputinOptions & {
|
|
|
35
35
|
*/
|
|
36
36
|
installTransportSignalHandlers?: boolean;
|
|
37
37
|
/**
|
|
38
|
-
*
|
|
39
|
-
*
|
|
38
|
+
* Measure durations on a progressive schedule shared by function metrics,
|
|
39
|
+
* execution metrics, and lightweight execution recording. Default false
|
|
40
|
+
* times every eligible call and execution. True counts every call,
|
|
41
|
+
* execution, and failure, and times a subset. Function durations are
|
|
42
|
+
* keyed by function, direct caller, and execution type. Execution
|
|
43
|
+
* durations use a separate counter per execution type so they cannot
|
|
44
|
+
* move function sampling. Counters reset hourly. After 5,000 samples
|
|
45
|
+
* the tail rate still samples. Selected sessions, activations, and full
|
|
46
|
+
* capture still record every duration; metric duration statistics follow
|
|
47
|
+
* this schedule so incident traffic does not bias aggregates. Invalid
|
|
48
|
+
* values are treated as false.
|
|
40
49
|
*/
|
|
41
|
-
|
|
50
|
+
dynamicDurationSampling?: boolean;
|
|
42
51
|
};
|
|
43
52
|
declare const buildPlugin: (client: RasputinNodeClient, runtime: ExecutionRuntime, wrapRequests: boolean) => Elysia<"", {
|
|
44
53
|
decorator: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rasputin-init.d.ts","sourceRoot":"","sources":["../src/rasputin-init.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,
|
|
1
|
+
{"version":3,"file":"rasputin-init.d.ts","sourceRoot":"","sources":["../src/rasputin-init.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAON,KAAK,eAAe,EAIpB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EACX,wBAAwB,EAExB,kBAAkB,EAClB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAQN,KAAK,gBAAgB,EAQrB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAIhC,iFAAiF;AACjF,MAAM,MAAM,oBAAoB,GAAG,UAAU,CAAC,OAAO,WAAW,CAAC,CAAC;AAElE,MAAM,MAAM,cAAc,GAAG;IAC5B,8EAA8E;IAC9E,MAAM,EAAE,kBAAkB,CAAC;IAC3B,2EAA2E;IAC3E,MAAM,EAAE,oBAAoB,CAAC;CAC7B,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG,eAAe,GAAG;IACrD;;;OAGG;IACH,iBAAiB,CAAC,EAAE,wBAAwB,CAAC;IAC7C;;;;;OAKG;IACH,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC;;;OAGG;IACH,8BAA8B,CAAC,EAAE,OAAO,CAAC;IACzC;;;;;;;;;;;;OAYG;IACH,uBAAuB,CAAC,EAAE,OAAO,CAAC;CAClC,CAAC;AAgJF,QAAA,MAAM,WAAW,GAChB,QAAQ,kBAAkB,EAC1B,SAAS,gBAAgB,EACzB,cAAc,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAmErB,CAAC;AAEF;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,qBAAqB,GAAG,cAAc,CAAC"}
|
package/dist/sdk-meta.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rasputin-ai/elysia",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.15.0",
|
|
4
4
|
"description": "Official Rasputin AI SDK for Elysia.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -35,8 +35,8 @@
|
|
|
35
35
|
"access": "public"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@rasputin-ai/core": "0.
|
|
39
|
-
"@rasputin-ai/node": "0.
|
|
38
|
+
"@rasputin-ai/core": "0.15.0",
|
|
39
|
+
"@rasputin-ai/node": "0.15.0"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {
|
|
42
42
|
"elysia": ">=1.4.0 <2"
|