@rasputin-ai/sveltekit 0.13.1 → 0.14.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.
@@ -1 +1 @@
1
- {"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../../src/runtime/node.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAc7D,OAAO,KAAK,EACX,aAAa,EAKb,MAAM,0BAA0B,CAAC;AAElC,MAAM,MAAM,wBAAwB,GAAG,mBAAmB,CAAC;AAkM3D;;;;GAIG;AACH,wBAAgB,IAAI,CAAC,OAAO,EAAE,wBAAwB,GAAG,aAAa,CAAC"}
1
+ {"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../../src/runtime/node.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAkB7D,OAAO,KAAK,EACX,aAAa,EAKb,MAAM,0BAA0B,CAAC;AAElC,MAAM,MAAM,wBAAwB,GAAG,mBAAmB,CAAC;AA6N3D;;;;GAIG;AACH,wBAAgB,IAAI,CAAC,OAAO,EAAE,wBAAwB,GAAG,aAAa,CAAC"}
@@ -7,17 +7,20 @@ import {
7
7
  } from "@rasputin-ai/core";
8
8
  import {
9
9
  bindAdaptiveRecorder,
10
+ bindExecutionMetrics,
10
11
  bindFunctionMetrics,
12
+ createDynamicDurationSampleBuckets,
11
13
  inertErrorObservation,
12
14
  installAutomaticExecutionRuntime,
13
15
  installGlobalHandlers,
16
+ releaseExecutionMetricsBindings,
14
17
  releaseFunctionMetricsBindings,
15
18
  scheduleInstrumentationManifestUpload
16
19
  } from "@rasputin-ai/node/internal";
17
20
 
18
21
  // src/sdk-meta.ts
19
22
  var SDK_NAME = "@rasputin-ai/sveltekit";
20
- var SDK_VERSION = "0.13.1";
23
+ var SDK_VERSION = "0.14.0";
21
24
 
22
25
  // src/runtime/node.ts
23
26
  var inertScope = () => ({
@@ -48,7 +51,7 @@ var publicScope = (runtime, request) => {
48
51
  return inertScope();
49
52
  }
50
53
  };
51
- var bindClient = (client, runtime, installRuntime, manifest, uninstallHandlers, policy, metrics) => {
54
+ var bindClient = (client, runtime, installRuntime, manifest, uninstallHandlers, policy, metrics, executionMetrics) => {
52
55
  const uninstallRuntime = installRuntime ? installAutomaticExecutionRuntime(runtime) : () => {
53
56
  };
54
57
  const manifestUpload = scheduleInstrumentationManifestUpload({
@@ -64,6 +67,7 @@ var bindClient = (client, runtime, installRuntime, manifest, uninstallHandlers,
64
67
  const startedAt = Date.now();
65
68
  await policy?.close();
66
69
  await releaseFunctionMetricsBindings(metrics);
70
+ await releaseExecutionMetricsBindings(executionMetrics);
67
71
  await client.close();
68
72
  await manifestUpload.wait(Math.max(0, 2e3 - (Date.now() - startedAt)));
69
73
  };
@@ -81,11 +85,13 @@ var bindClient = (client, runtime, installRuntime, manifest, uninstallHandlers,
81
85
  if (timeoutMs === void 0) {
82
86
  await policy?.flush();
83
87
  await metrics?.exporter.flush();
88
+ await executionMetrics?.exporter.flush();
84
89
  await manifestUpload.wait();
85
90
  return;
86
91
  }
87
92
  await policy?.flush(Math.max(0, timeoutMs - (Date.now() - startedAt)));
88
93
  await metrics?.exporter.flush(Math.max(0, timeoutMs - (Date.now() - startedAt)));
94
+ await executionMetrics?.exporter.flush(Math.max(0, timeoutMs - (Date.now() - startedAt)));
89
95
  await manifestUpload.wait(Math.max(0, timeoutMs - (Date.now() - startedAt)));
90
96
  },
91
97
  close: shutdown
@@ -96,6 +102,7 @@ var bindClient = (client, runtime, installRuntime, manifest, uninstallHandlers,
96
102
  var createBoundRuntime = (options, hooks, capture) => {
97
103
  const enabled = capture && isClientEnabled(options);
98
104
  const recorderEnabled = enabled && options.executionRecorder?.enabled !== false;
105
+ const durationSampling = options.dynamicDurationSampling === true;
99
106
  const activation = resolveClientActivation({
100
107
  enabled: options.enabled === false || !capture ? false : options.enabled,
101
108
  dsn: options.dsn,
@@ -111,8 +118,20 @@ var createBoundRuntime = (options, hooks, capture) => {
111
118
  release: activation.release,
112
119
  ingestToken: activation.ingestToken,
113
120
  apiUrl: activation.apiUrl,
114
- fetch: hooks.fetch
121
+ fetch: hooks.fetch,
122
+ sampledMeasurementFormat: durationSampling
123
+ }) : void 0;
124
+ const executionMetrics = activation.enabled ? bindExecutionMetrics({
125
+ options: options.executionMetrics,
126
+ clientEnabled: true,
127
+ environment: activation.environment,
128
+ release: activation.release,
129
+ ingestToken: activation.ingestToken,
130
+ apiUrl: activation.apiUrl,
131
+ fetch: hooks.fetch,
132
+ sampledMeasurementFormat: durationSampling
115
133
  }) : void 0;
134
+ const durationSampler = durationSampling && (recorderEnabled || Boolean(metrics) || Boolean(executionMetrics)) ? createDynamicDurationSampleBuckets({ nowMs: () => Date.now() }) : void 0;
116
135
  const { runtime, policy } = bindAdaptiveRecorder({
117
136
  executionRecorder: options.executionRecorder,
118
137
  recorderEnabled,
@@ -126,7 +145,9 @@ var createBoundRuntime = (options, hooks, capture) => {
126
145
  sdkName: SDK_NAME,
127
146
  sdkVersion: SDK_VERSION,
128
147
  scrubPII: options.scrubPII,
129
- functionMetrics: metrics?.collector
148
+ functionMetrics: metrics?.collector,
149
+ executionMetrics: executionMetrics?.collector,
150
+ durationSampler
130
151
  });
131
152
  const client = createClient(
132
153
  { ...options, enabled },
@@ -158,7 +179,8 @@ var createBoundRuntime = (options, hooks, capture) => {
158
179
  },
159
180
  () => uninstallHandlers(),
160
181
  policy,
161
- metrics
182
+ metrics,
183
+ executionMetrics
162
184
  );
163
185
  if (enabled && (hooks.installGlobalHandlers ?? options.installGlobalHandlers) === true) {
164
186
  uninstallHandlers = installGlobalHandlers(bound.client);
@@ -1,4 +1,4 @@
1
1
  /** Generated by scripts/generate-sdk-meta.ts — do not edit. */
2
2
  export declare const SDK_NAME = "@rasputin-ai/sveltekit";
3
- export declare const SDK_VERSION = "0.13.1";
3
+ export declare const SDK_VERSION = "0.14.0";
4
4
  //# sourceMappingURL=sdk-meta.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rasputin-ai/sveltekit",
3
- "version": "0.13.1",
3
+ "version": "0.14.0",
4
4
  "description": "Official Rasputin AI SDK for SvelteKit.",
5
5
  "type": "module",
6
6
  "exports": {
@@ -42,9 +42,9 @@
42
42
  "access": "public"
43
43
  },
44
44
  "dependencies": {
45
- "@rasputin-ai/browser": "0.13.1",
46
- "@rasputin-ai/core": "0.13.1",
47
- "@rasputin-ai/node": "0.13.1",
45
+ "@rasputin-ai/browser": "0.14.0",
46
+ "@rasputin-ai/core": "0.14.0",
47
+ "@rasputin-ai/node": "0.14.0",
48
48
  "typescript": "5"
49
49
  },
50
50
  "peerDependencies": {