autotel-tanstack 1.14.6 → 2.0.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/loaders.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import { i as LoaderFnContext, n as traceBeforeLoad, r as traceLoader, t as createTracedRoute } from "./loaders-CTK-UHdg.js";
1
+ import { i as LoaderFnContext, n as traceBeforeLoad, r as traceLoader, t as createTracedRoute } from "./loaders-CzjfY7s6.js";
2
2
  export { type LoaderFnContext, createTracedRoute, traceBeforeLoad, traceLoader };
package/dist/loaders.js CHANGED
@@ -1,22 +1,63 @@
1
1
  import { i as SPAN_ATTRIBUTES, n as isRealError, t as isControlFlowSignal } from "./control-flow-BsrFPBj2.js";
2
- import { r as isServerSide } from "./env-BpFWNnpL.js";
3
- import { SpanStatusCode } from "@opentelemetry/api";
4
- import { trace as trace$1 } from "autotel";
2
+ import { r as isServerSide } from "./env-rT3_WobG.js";
3
+ import { trace } from "autotel";
5
4
 
6
5
  //#region src/loaders.ts
7
6
  /**
8
- * Wrap a TanStack route loader with OpenTelemetry tracing
9
- *
10
- * This function wraps a loader function to automatically create spans
11
- * for each invocation. It captures route ID, params (optionally),
12
- * and errors.
7
+ * One span per loader / beforeLoad call. The route's function runs inside the
8
+ * span, so spans it starts nest under it. trace.run waits for a returned
9
+ * promise, records real errors, and marks redirect()/notFound() OK through
10
+ * isRealError: they are control flow, not failures.
11
+ */
12
+ function traceRouteLifecycle(kind, context, fn, config) {
13
+ if (!isServerSide()) return fn(context);
14
+ const routeId = context.route?.id || "unknown";
15
+ return trace.run({
16
+ name: config.name || `tanstack.${kind}.${routeId}`,
17
+ isError: isRealError
18
+ }, (ctx) => {
19
+ ctx.setAttributes({
20
+ [SPAN_ATTRIBUTES.TANSTACK_TYPE]: kind,
21
+ [SPAN_ATTRIBUTES.TANSTACK_LOADER_ROUTE_ID]: routeId,
22
+ [SPAN_ATTRIBUTES.TANSTACK_LOADER_TYPE]: kind
23
+ });
24
+ if ((config.captureParams ?? true) && context.params) ctx.setAttribute(SPAN_ATTRIBUTES.TANSTACK_LOADER_PARAMS, toJson(context.params));
25
+ const onValue = (value) => {
26
+ if (kind === "loader" && config.captureResult && value !== void 0) ctx.setAttribute("tanstack.loader.result", toJson(value));
27
+ };
28
+ const onThrown = (cause) => {
29
+ if (kind === "beforeLoad" && isControlFlowSignal(cause)) ctx.setAttribute("tanstack.beforeLoad.redirect", true);
30
+ };
31
+ let result;
32
+ try {
33
+ result = fn(context);
34
+ } catch (error) {
35
+ onThrown(error);
36
+ throw error;
37
+ }
38
+ if (result instanceof Promise) result.then(onValue, onThrown);
39
+ else onValue(result);
40
+ return result;
41
+ });
42
+ }
43
+ function toJson(value) {
44
+ try {
45
+ return JSON.stringify(value);
46
+ } catch {
47
+ return "[non-serializable]";
48
+ }
49
+ }
50
+ /**
51
+ * Trace a TanStack route loader with OpenTelemetry
13
52
  *
14
- * The generic type TLoaderFn preserves the full TanStack Router type inference,
15
- * including typed params, context, and return types.
53
+ * Creates a span per invocation with the route id, params (optionally) and
54
+ * errors. Call it from inside the route's own loader and pass its context
55
+ * through, so TanStack Router keeps typing params and context.
16
56
  *
17
- * @param loaderFn - The loader function to wrap
57
+ * @param context - The loader context TanStack passed in
58
+ * @param loaderFn - The loader logic to trace
18
59
  * @param config - Configuration options
19
- * @returns Wrapped loader function with tracing (preserves original types)
60
+ * @returns Whatever loaderFn returns
20
61
  *
21
62
  * @example
22
63
  * ```typescript
@@ -24,102 +65,29 @@ import { trace as trace$1 } from "autotel";
24
65
  * import { traceLoader } from 'autotel-tanstack/loaders';
25
66
  *
26
67
  * export const Route = createFileRoute('/users/$userId')({
27
- * // Types are fully preserved - params.userId is typed as string
28
- * loader: traceLoader(async ({ params }) => {
29
- * return await db.users.findUnique({ where: { id: params.userId } });
30
- * }),
31
- * });
32
- * ```
33
- *
34
- * @example
35
- * ```typescript
36
- * // Sync loaders are also supported
37
- * export const Route = createFileRoute('/static')({
38
- * loader: traceLoader(({ context }) => ({
39
- * message: `Welcome, ${context.userId}!`,
40
- * })),
68
+ * loader: (ctx) =>
69
+ * traceLoader(ctx, async ({ params }) => {
70
+ * return await db.users.findUnique({ where: { id: params.userId } });
71
+ * }),
41
72
  * });
42
73
  * ```
43
74
  */
44
- function traceLoader(loaderFn, config = {}) {
45
- const captureParams = config.captureParams ?? true;
46
- const captureResult = config.captureResult ?? false;
47
- const wrapped = (context) => {
48
- if (!isServerSide()) return loaderFn(context);
49
- const routeId = context?.route?.id || "unknown";
50
- const spanName = config.name || `tanstack.loader.${routeId}`;
51
- const result = loaderFn(context);
52
- if (!(result instanceof Promise)) return trace$1.run({
53
- name: spanName,
54
- isError: isRealError
55
- }, (ctx) => {
56
- ctx.setAttributes({
57
- [SPAN_ATTRIBUTES.TANSTACK_TYPE]: "loader",
58
- [SPAN_ATTRIBUTES.TANSTACK_LOADER_ROUTE_ID]: routeId,
59
- [SPAN_ATTRIBUTES.TANSTACK_LOADER_TYPE]: "loader"
60
- });
61
- if (captureParams && context?.params) try {
62
- ctx.setAttribute(SPAN_ATTRIBUTES.TANSTACK_LOADER_PARAMS, JSON.stringify(context.params));
63
- } catch {
64
- ctx.setAttribute(SPAN_ATTRIBUTES.TANSTACK_LOADER_PARAMS, "[non-serializable]");
65
- }
66
- if (captureResult && result !== void 0) try {
67
- ctx.setAttribute("tanstack.loader.result", JSON.stringify(result));
68
- } catch {
69
- ctx.setAttribute("tanstack.loader.result", "[non-serializable]");
70
- }
71
- ctx.setStatus({ code: SpanStatusCode.OK });
72
- return result;
73
- });
74
- return trace$1.run({
75
- name: spanName,
76
- isError: isRealError
77
- }, async (ctx) => {
78
- ctx.setAttributes({
79
- [SPAN_ATTRIBUTES.TANSTACK_TYPE]: "loader",
80
- [SPAN_ATTRIBUTES.TANSTACK_LOADER_ROUTE_ID]: routeId,
81
- [SPAN_ATTRIBUTES.TANSTACK_LOADER_TYPE]: "loader"
82
- });
83
- if (captureParams && context?.params) try {
84
- ctx.setAttribute(SPAN_ATTRIBUTES.TANSTACK_LOADER_PARAMS, JSON.stringify(context.params));
85
- } catch {
86
- ctx.setAttribute(SPAN_ATTRIBUTES.TANSTACK_LOADER_PARAMS, "[non-serializable]");
87
- }
88
- try {
89
- const asyncResult = await result;
90
- if (captureResult && asyncResult !== void 0) try {
91
- ctx.setAttribute("tanstack.loader.result", JSON.stringify(asyncResult));
92
- } catch {
93
- ctx.setAttribute("tanstack.loader.result", "[non-serializable]");
94
- }
95
- ctx.setStatus({ code: SpanStatusCode.OK });
96
- return asyncResult;
97
- } catch (error) {
98
- if (isControlFlowSignal(error)) {
99
- ctx.setStatus({ code: SpanStatusCode.OK });
100
- throw error;
101
- }
102
- if ("recordError" in ctx && typeof ctx.recordError === "function") ctx.recordError(error);
103
- else if ("recordException" in ctx && typeof ctx.recordException === "function") ctx.recordException(error);
104
- throw error;
105
- }
106
- });
107
- };
108
- return wrapped;
75
+ function traceLoader(context, loaderFn, config = {}) {
76
+ return traceRouteLifecycle("loader", context, loaderFn, config);
109
77
  }
110
78
  /**
111
- * Wrap a TanStack route beforeLoad function with OpenTelemetry tracing
112
- *
113
- * This function wraps a beforeLoad function to automatically create spans.
114
- * beforeLoad runs before the route component renders and is typically
115
- * used for auth checks, redirects, or data prefetching.
79
+ * Trace a TanStack route beforeLoad with OpenTelemetry
116
80
  *
117
- * The generic type TBeforeLoadFn preserves the full TanStack Router type inference,
118
- * including typed params, context, search, and return types.
81
+ * beforeLoad runs before the route component renders and is typically used
82
+ * for auth checks, redirects, or data prefetching. Call this from inside the
83
+ * route's own beforeLoad and pass its context through. TanStack Router types
84
+ * the context from the function you write, and the return value flows to the
85
+ * loader's context.
119
86
  *
120
- * @param beforeLoadFn - The beforeLoad function to wrap
87
+ * @param context - The beforeLoad context TanStack passed in
88
+ * @param beforeLoadFn - The beforeLoad logic to trace
121
89
  * @param config - Configuration options
122
- * @returns Wrapped beforeLoad function with tracing (preserves original types)
90
+ * @returns Whatever beforeLoadFn returns
123
91
  *
124
92
  * @example
125
93
  * ```typescript
@@ -127,73 +95,19 @@ function traceLoader(loaderFn, config = {}) {
127
95
  * import { traceBeforeLoad } from 'autotel-tanstack/loaders';
128
96
  *
129
97
  * export const Route = createFileRoute('/dashboard')({
130
- * // Types are fully preserved - context, params, search are all typed
131
- * beforeLoad: traceBeforeLoad(async ({ context, params }) => {
132
- * if (!context.auth.isAuthenticated) {
133
- * throw redirect({ to: '/login' });
134
- * }
135
- * return { userId: params.userId }; // Return type flows to loader context
136
- * }),
137
- * loader: ({ context }) => {
138
- * // context.userId is typed from beforeLoad return
139
- * return { user: context.userId };
140
- * },
98
+ * beforeLoad: (ctx) =>
99
+ * traceBeforeLoad(ctx, async ({ context, params }) => {
100
+ * if (!context.auth.isAuthenticated) {
101
+ * throw redirect({ to: '/login' });
102
+ * }
103
+ * return { userId: params.userId }; // flows to the loader's context
104
+ * }),
105
+ * loader: ({ context }) => ({ user: context.userId }),
141
106
  * });
142
107
  * ```
143
108
  */
144
- function traceBeforeLoad(beforeLoadFn, config = {}) {
145
- const captureParams = config.captureParams ?? true;
146
- const wrapped = (input) => {
147
- if (!isServerSide()) return beforeLoadFn(input);
148
- const routeId = input?.route?.id || "unknown";
149
- const spanName = config.name || `tanstack.beforeLoad.${routeId}`;
150
- const result = beforeLoadFn(input);
151
- if (!(result instanceof Promise)) return trace$1.run({
152
- name: spanName,
153
- isError: isRealError
154
- }, (ctx) => {
155
- ctx.setAttributes({
156
- [SPAN_ATTRIBUTES.TANSTACK_TYPE]: "beforeLoad",
157
- [SPAN_ATTRIBUTES.TANSTACK_LOADER_ROUTE_ID]: routeId,
158
- [SPAN_ATTRIBUTES.TANSTACK_LOADER_TYPE]: "beforeLoad"
159
- });
160
- if (captureParams && input?.params) try {
161
- ctx.setAttribute(SPAN_ATTRIBUTES.TANSTACK_LOADER_PARAMS, JSON.stringify(input.params));
162
- } catch {
163
- ctx.setAttribute(SPAN_ATTRIBUTES.TANSTACK_LOADER_PARAMS, "[non-serializable]");
164
- }
165
- ctx.setStatus({ code: SpanStatusCode.OK });
166
- return result;
167
- });
168
- return trace$1.run({
169
- name: spanName,
170
- isError: isRealError
171
- }, async (ctx) => {
172
- ctx.setAttributes({
173
- [SPAN_ATTRIBUTES.TANSTACK_TYPE]: "beforeLoad",
174
- [SPAN_ATTRIBUTES.TANSTACK_LOADER_ROUTE_ID]: routeId,
175
- [SPAN_ATTRIBUTES.TANSTACK_LOADER_TYPE]: "beforeLoad"
176
- });
177
- if (captureParams && input?.params) try {
178
- ctx.setAttribute(SPAN_ATTRIBUTES.TANSTACK_LOADER_PARAMS, JSON.stringify(input.params));
179
- } catch {
180
- ctx.setAttribute(SPAN_ATTRIBUTES.TANSTACK_LOADER_PARAMS, "[non-serializable]");
181
- }
182
- try {
183
- const asyncResult = await result;
184
- ctx.setStatus({ code: SpanStatusCode.OK });
185
- return asyncResult;
186
- } catch (error) {
187
- if (isControlFlowSignal(error)) {
188
- ctx.setAttribute("tanstack.beforeLoad.redirect", true);
189
- ctx.setStatus({ code: SpanStatusCode.OK });
190
- } else if ("recordError" in ctx && typeof ctx.recordError === "function") ctx.recordError(error);
191
- else if ("recordException" in ctx && typeof ctx.recordException === "function") ctx.recordException(error);
192
- throw error;
193
- }
194
- });
195
- };
196
- return wrapped;
109
+ function traceBeforeLoad(context, beforeLoadFn, config = {}) {
110
+ return traceRouteLifecycle("beforeLoad", context, beforeLoadFn, config);
197
111
  }
198
112
  /**
199
113
  * Create a traced route configuration helper
@@ -203,7 +117,7 @@ function traceBeforeLoad(beforeLoadFn, config = {}) {
203
117
  *
204
118
  * @param routeId - The route identifier
205
119
  * @param config - Tracing configuration
206
- * @returns Object with traced loader and beforeLoad wrappers
120
+ * @returns Object with loader and beforeLoad tracers named after the route
207
121
  *
208
122
  * @example
209
123
  * ```typescript
@@ -213,31 +127,33 @@ function traceBeforeLoad(beforeLoadFn, config = {}) {
213
127
  * const traced = createTracedRoute('/users/$userId');
214
128
  *
215
129
  * export const Route = createFileRoute('/users/$userId')({
216
- * beforeLoad: traced.beforeLoad(async ({ context }) => {
217
- * // Auth check
218
- * }),
219
- * loader: traced.loader(async ({ params }) => {
220
- * return await getUser(params.userId);
221
- * }),
130
+ * beforeLoad: (ctx) =>
131
+ * traced.beforeLoad(ctx, async ({ context }) => {
132
+ * // Auth check
133
+ * }),
134
+ * loader: (ctx) =>
135
+ * traced.loader(ctx, async ({ params }) => {
136
+ * return await getUser(params.userId);
137
+ * }),
222
138
  * });
223
139
  * ```
224
140
  */
225
141
  function createTracedRoute(routeId, config = {}) {
226
142
  return {
227
143
  /**
228
- * Wrap a loader function with tracing
144
+ * Trace a loader under this route's span name
229
145
  */
230
- loader(loaderFn) {
231
- return traceLoader(loaderFn, {
146
+ loader(context, loaderFn) {
147
+ return traceLoader(context, loaderFn, {
232
148
  ...config,
233
149
  name: `tanstack.loader.${routeId}`
234
150
  });
235
151
  },
236
152
  /**
237
- * Wrap a beforeLoad function with tracing
153
+ * Trace a beforeLoad under this route's span name
238
154
  */
239
- beforeLoad(beforeLoadFn) {
240
- return traceBeforeLoad(beforeLoadFn, {
155
+ beforeLoad(context, beforeLoadFn) {
156
+ return traceBeforeLoad(context, beforeLoadFn, {
241
157
  ...config,
242
158
  name: `tanstack.beforeLoad.${routeId}`
243
159
  });
package/dist/metrics.d.ts CHANGED
@@ -8,7 +8,7 @@
8
8
  /**
9
9
  * Performance timing data
10
10
  */
11
- interface TimingStats {
11
+ export interface TimingStats {
12
12
  count: number;
13
13
  avg: number;
14
14
  p50: number;
@@ -61,7 +61,7 @@ declare class MetricsCollector {
61
61
  /**
62
62
  * Global metrics collector instance
63
63
  */
64
- declare const metricsCollector: MetricsCollector;
64
+ export declare const metricsCollector: MetricsCollector;
65
65
  /**
66
66
  * Helper to create a metrics endpoint handler
67
67
  *
@@ -84,7 +84,7 @@ declare const metricsCollector: MetricsCollector;
84
84
  * });
85
85
  * ```
86
86
  */
87
- declare function createMetricsHandler(): () => Promise<import("@tanstack/react-start").JsonResponse<{
87
+ export declare function createMetricsHandler(): () => Promise<import("@tanstack/react-start").JsonResponse<{
88
88
  system: {
89
89
  uptime: number;
90
90
  memory: NodeJS.MemoryUsage;
@@ -107,6 +107,5 @@ declare function createMetricsHandler(): () => Promise<import("@tanstack/react-s
107
107
  * }));
108
108
  * ```
109
109
  */
110
- declare function recordTiming<T extends (...args: any[]) => any>(metricName: string, fn: T): T;
111
- //#endregion
112
- export { TimingStats, createMetricsHandler, metricsCollector, recordTiming };
110
+ export declare function recordTiming<T extends (...args: any[]) => any>(metricName: string, fn: T): T;
111
+ //#endregion
@@ -1,4 +1,4 @@
1
- import { o as TracingMiddlewareConfig } from "./types-BZNf5yHJ.js";
1
+ import { o as TracingMiddlewareConfig } from "./types-DD1_xVG9.js";
2
2
  //#region src/middleware.d.ts
3
3
  /**
4
4
  * Generic middleware handler type (compatible with TanStack's middleware pattern)
@@ -6,7 +6,7 @@ import { o as TracingMiddlewareConfig } from "./types-BZNf5yHJ.js";
6
6
  * This type represents the shape of TanStack middleware handlers.
7
7
  * We use a generic type to avoid direct dependency on TanStack packages.
8
8
  */
9
- interface MiddlewareHandler<TContext = unknown> {
9
+ export interface MiddlewareHandler<TContext = unknown> {
10
10
  (opts: {
11
11
  next: (ctx?: Partial<TContext>) => Promise<TContext>;
12
12
  context: TContext;
@@ -57,7 +57,7 @@ interface MiddlewareHandler<TContext = unknown> {
57
57
  * });
58
58
  * ```
59
59
  */
60
- declare function createTracingMiddleware<TContext = unknown>(config?: TracingMiddlewareConfig): MiddlewareHandler<TContext>;
60
+ export declare function createTracingMiddleware<TContext = unknown>(config?: TracingMiddlewareConfig): MiddlewareHandler<TContext>;
61
61
  /**
62
62
  * Pre-configured tracing middleware with sensible defaults
63
63
  *
@@ -77,7 +77,7 @@ declare function createTracingMiddleware<TContext = unknown>(config?: TracingMid
77
77
  * }));
78
78
  * ```
79
79
  */
80
- declare function tracingMiddleware<TContext = unknown>(config?: TracingMiddlewareConfig): MiddlewareHandler<TContext>;
80
+ export declare function tracingMiddleware<TContext = unknown>(config?: TracingMiddlewareConfig): MiddlewareHandler<TContext>;
81
81
  /**
82
82
  * Create function-specific tracing middleware
83
83
  *
@@ -98,7 +98,7 @@ declare function tracingMiddleware<TContext = unknown>(config?: TracingMiddlewar
98
98
  * });
99
99
  * ```
100
100
  */
101
- declare function functionTracingMiddleware<TContext = unknown>(config?: Omit<TracingMiddlewareConfig, 'type'>): MiddlewareHandler<TContext>;
101
+ export declare function functionTracingMiddleware<TContext = unknown>(config?: Omit<TracingMiddlewareConfig, 'type'>): MiddlewareHandler<TContext>;
102
102
  /**
103
103
  * Create a tracing handler for use with TanStack's native createMiddleware()
104
104
  *
@@ -141,6 +141,5 @@ declare function functionTracingMiddleware<TContext = unknown>(config?: Omit<Tra
141
141
  * }));
142
142
  * ```
143
143
  */
144
- declare function createTracingServerHandler<TContext = unknown>(config?: TracingMiddlewareConfig): (opts: any) => any;
145
- //#endregion
146
- export { MiddlewareHandler, createTracingMiddleware, createTracingServerHandler, functionTracingMiddleware, tracingMiddleware };
144
+ export declare function createTracingServerHandler<TContext = unknown>(config?: TracingMiddlewareConfig): (opts: any) => any;
145
+ //#endregion
@@ -1,6 +1,6 @@
1
1
  import { i as SPAN_ATTRIBUTES, n as isRealError, r as DEFAULT_CONFIG, t as isControlFlowSignal } from "./control-flow-BsrFPBj2.js";
2
2
  import { extractContextFromRequest } from "./context.js";
3
- import { r as isServerSide } from "./env-BpFWNnpL.js";
3
+ import { r as isServerSide } from "./env-rT3_WobG.js";
4
4
  import { t as isExcludedPath } from "./route-filter-dLg-j3jR.js";
5
5
  import { SpanStatusCode, context } from "@opentelemetry/api";
6
6
  import { trace as trace$1 } from "autotel";
@@ -1,4 +1,4 @@
1
- import { a as TraceServerFnConfig } from "./types-BZNf5yHJ.js";
1
+ import { a as TraceServerFnConfig } from "./types-DD1_xVG9.js";
2
2
  //#region src/server-functions.d.ts
3
3
  /**
4
4
  * Wrap a TanStack server function with OpenTelemetry tracing
@@ -40,7 +40,7 @@ import { a as TraceServerFnConfig } from "./types-BZNf5yHJ.js";
40
40
  * );
41
41
  * ```
42
42
  */
43
- declare function traceServerFn<T extends (...args: any[]) => any>(serverFn: T, config?: TraceServerFnConfig): T;
43
+ export declare function traceServerFn<T extends (...args: any[]) => any>(serverFn: T, config?: TraceServerFnConfig): T;
44
44
  /**
45
45
  * Create a traced version of createServerFn
46
46
  *
@@ -65,6 +65,5 @@ declare function traceServerFn<T extends (...args: any[]) => any>(serverFn: T, c
65
65
  * });
66
66
  * ```
67
67
  */
68
- declare function createTracedServerFnFactory<TCreateServerFn extends (...args: any[]) => any>(createServerFnOriginal: TCreateServerFn, defaultConfig?: Omit<TraceServerFnConfig, 'name'>): TCreateServerFn;
69
- //#endregion
70
- export { createTracedServerFnFactory, traceServerFn };
68
+ export declare function createTracedServerFnFactory<TCreateServerFn extends (...args: any[]) => any>(createServerFnOriginal: TCreateServerFn, defaultConfig?: Omit<TraceServerFnConfig, 'name'>): TCreateServerFn;
69
+ //#endregion
@@ -1,5 +1,5 @@
1
1
  import { i as SPAN_ATTRIBUTES, n as isRealError, t as isControlFlowSignal } from "./control-flow-BsrFPBj2.js";
2
- import { r as isServerSide } from "./env-BpFWNnpL.js";
2
+ import { r as isServerSide } from "./env-rT3_WobG.js";
3
3
  import { SpanStatusCode } from "@opentelemetry/api";
4
4
  import { trace as trace$1 } from "autotel";
5
5
 
package/dist/testing.d.ts CHANGED
@@ -103,7 +103,7 @@ interface ReadableSpan {
103
103
  * Provides utilities for testing TanStack Start applications
104
104
  * with autotel-tanstack instrumentation.
105
105
  */
106
- interface TestHarness {
106
+ export interface TestHarness {
107
107
  /**
108
108
  * The in-memory span exporter
109
109
  */
@@ -189,7 +189,7 @@ interface TestHarness {
189
189
  * });
190
190
  * ```
191
191
  */
192
- declare function createTestHarness(): TestHarness;
192
+ export declare function createTestHarness(): TestHarness;
193
193
  /**
194
194
  * Mock request factory for testing
195
195
  *
@@ -202,7 +202,7 @@ declare function createTestHarness(): TestHarness;
202
202
  * });
203
203
  * ```
204
204
  */
205
- declare function createMockRequest(method: string, path: string, options?: {
205
+ export declare function createMockRequest(method: string, path: string, options?: {
206
206
  headers?: Record<string, string>;
207
207
  body?: string;
208
208
  traceparent?: string;
@@ -220,7 +220,7 @@ declare function createMockRequest(method: string, path: string, options?: {
220
220
  * const request = createMockRequest('GET', '/api/users', { traceparent });
221
221
  * ```
222
222
  */
223
- declare function generateTraceparent(traceId?: string, spanId?: string): string;
223
+ export declare function generateTraceparent(traceId?: string, spanId?: string): string;
224
224
  /**
225
225
  * Serialized span shape returned by the test-spans HTTP endpoint.
226
226
  * Mirrors the fields the Playwright side needs for assertions.
@@ -228,7 +228,7 @@ declare function generateTraceparent(traceId?: string, spanId?: string): string;
228
228
  * Defined as a `type` (not `interface`) so it is assignable to
229
229
  * `Record<string, unknown>` in TypeScript 6+ strict mode.
230
230
  */
231
- type SerializedSpan = {
231
+ export type SerializedSpan = {
232
232
  name: string;
233
233
  spanId: string;
234
234
  traceId: string;
@@ -287,10 +287,9 @@ type CreateFileRoute = (path: string) => (options: any) => any;
287
287
  * export const Route = createTestSpansRoute(createFileRoute);
288
288
  * ```
289
289
  */
290
- declare function createTestSpansRoute(createFileRoute: CreateFileRoute, path?: string): any;
291
- declare function createTestSpansHandlers(): {
290
+ export declare function createTestSpansRoute(createFileRoute: CreateFileRoute, path?: string): any;
291
+ export declare function createTestSpansHandlers(): {
292
292
  GET: (input: HandlerInput) => Response;
293
293
  DELETE: (input: HandlerInput) => Response;
294
294
  };
295
- //#endregion
296
- export { SerializedSpan, TestHarness, createMockRequest, createTestHarness, createTestSpansHandlers, createTestSpansRoute, generateTraceparent };
295
+ //#endregion
@@ -64,23 +64,23 @@ declare const DEFAULT_CONFIG: Required<Omit<TanStackInstrumentationConfig, 'cust
64
64
  * Span attribute keys (stub - values are strings)
65
65
  */
66
66
  declare const SPAN_ATTRIBUTES: {
67
- readonly HTTP_REQUEST_METHOD: "http.request.method";
68
- readonly HTTP_RESPONSE_STATUS_CODE: "http.response.status_code";
69
- readonly URL_PATH: "url.path";
70
- readonly URL_QUERY: "url.query";
71
- readonly URL_FULL: "url.full";
72
- readonly RPC_SYSTEM: "rpc.system.name";
73
- readonly RPC_METHOD: "rpc.method";
74
- readonly TANSTACK_TYPE: "tanstack.type";
75
- readonly TANSTACK_SERVER_FN_NAME: "tanstack.server_function.name";
76
- readonly TANSTACK_SERVER_FN_METHOD: "tanstack.server_function.method";
77
- readonly TANSTACK_SERVER_FN_ARGS: "tanstack.server_function.args";
78
- readonly TANSTACK_SERVER_FN_RESULT: "tanstack.server_function.result";
79
- readonly TANSTACK_LOADER_ROUTE_ID: "tanstack.loader.route_id";
80
- readonly TANSTACK_LOADER_TYPE: "tanstack.loader.type";
81
- readonly TANSTACK_LOADER_PARAMS: "tanstack.loader.params";
82
- readonly TANSTACK_MIDDLEWARE_NAME: "tanstack.middleware.name";
83
- readonly TANSTACK_REQUEST_DURATION_MS: "tanstack.request.duration_ms";
67
+ readonly HTTP_REQUEST_METHOD: 'http.request.method';
68
+ readonly HTTP_RESPONSE_STATUS_CODE: 'http.response.status_code';
69
+ readonly URL_PATH: 'url.path';
70
+ readonly URL_QUERY: 'url.query';
71
+ readonly URL_FULL: 'url.full';
72
+ readonly RPC_SYSTEM: 'rpc.system.name';
73
+ readonly RPC_METHOD: 'rpc.method';
74
+ readonly TANSTACK_TYPE: 'tanstack.type';
75
+ readonly TANSTACK_SERVER_FN_NAME: 'tanstack.server_function.name';
76
+ readonly TANSTACK_SERVER_FN_METHOD: 'tanstack.server_function.method';
77
+ readonly TANSTACK_SERVER_FN_ARGS: 'tanstack.server_function.args';
78
+ readonly TANSTACK_SERVER_FN_RESULT: 'tanstack.server_function.result';
79
+ readonly TANSTACK_LOADER_ROUTE_ID: 'tanstack.loader.route_id';
80
+ readonly TANSTACK_LOADER_TYPE: 'tanstack.loader.type';
81
+ readonly TANSTACK_LOADER_PARAMS: 'tanstack.loader.params';
82
+ readonly TANSTACK_MIDDLEWARE_NAME: 'tanstack.middleware.name';
83
+ readonly TANSTACK_REQUEST_DURATION_MS: 'tanstack.request.duration_ms';
84
84
  };
85
85
  //#endregion
86
86
  export { TraceLoaderConfig as a, WrapStartHandlerConfig as c, TanStackInstrumentationConfig as i, DEFAULT_CONFIG as n, TraceServerFnConfig as o, SPAN_ATTRIBUTES as r, TracingMiddlewareConfig as s, Attributes as t };
@@ -130,23 +130,23 @@ declare const DEFAULT_CONFIG: Required<Omit<TanStackInstrumentationConfig, 'cust
130
130
  * Span attribute keys following OpenTelemetry semantic conventions
131
131
  */
132
132
  declare const SPAN_ATTRIBUTES: {
133
- readonly HTTP_REQUEST_METHOD: "http.request.method";
134
- readonly HTTP_RESPONSE_STATUS_CODE: "http.response.status_code";
135
- readonly URL_PATH: "url.path";
136
- readonly URL_QUERY: "url.query";
137
- readonly URL_FULL: "url.full";
138
- readonly RPC_SYSTEM: "rpc.system.name";
139
- readonly RPC_METHOD: "rpc.method";
140
- readonly TANSTACK_TYPE: "tanstack.type";
141
- readonly TANSTACK_SERVER_FN_NAME: "tanstack.server_function.name";
142
- readonly TANSTACK_SERVER_FN_METHOD: "tanstack.server_function.method";
143
- readonly TANSTACK_SERVER_FN_ARGS: "tanstack.server_function.args";
144
- readonly TANSTACK_SERVER_FN_RESULT: "tanstack.server_function.result";
145
- readonly TANSTACK_LOADER_ROUTE_ID: "tanstack.loader.route_id";
146
- readonly TANSTACK_LOADER_TYPE: "tanstack.loader.type";
147
- readonly TANSTACK_LOADER_PARAMS: "tanstack.loader.params";
148
- readonly TANSTACK_MIDDLEWARE_NAME: "tanstack.middleware.name";
149
- readonly TANSTACK_REQUEST_DURATION_MS: "tanstack.request.duration_ms";
133
+ readonly HTTP_REQUEST_METHOD: 'http.request.method';
134
+ readonly HTTP_RESPONSE_STATUS_CODE: 'http.response.status_code';
135
+ readonly URL_PATH: 'url.path';
136
+ readonly URL_QUERY: 'url.query';
137
+ readonly URL_FULL: 'url.full';
138
+ readonly RPC_SYSTEM: 'rpc.system.name';
139
+ readonly RPC_METHOD: 'rpc.method';
140
+ readonly TANSTACK_TYPE: 'tanstack.type';
141
+ readonly TANSTACK_SERVER_FN_NAME: 'tanstack.server_function.name';
142
+ readonly TANSTACK_SERVER_FN_METHOD: 'tanstack.server_function.method';
143
+ readonly TANSTACK_SERVER_FN_ARGS: 'tanstack.server_function.args';
144
+ readonly TANSTACK_SERVER_FN_RESULT: 'tanstack.server_function.result';
145
+ readonly TANSTACK_LOADER_ROUTE_ID: 'tanstack.loader.route_id';
146
+ readonly TANSTACK_LOADER_TYPE: 'tanstack.loader.type';
147
+ readonly TANSTACK_LOADER_PARAMS: 'tanstack.loader.params';
148
+ readonly TANSTACK_MIDDLEWARE_NAME: 'tanstack.middleware.name';
149
+ readonly TANSTACK_REQUEST_DURATION_MS: 'tanstack.request.duration_ms';
150
150
  };
151
151
  //#endregion
152
152
  export { TraceServerFnConfig as a, TraceLoaderConfig as i, SPAN_ATTRIBUTES as n, TracingMiddlewareConfig as o, TanStackInstrumentationConfig as r, WrapStartHandlerConfig as s, DEFAULT_CONFIG as t };