autotel-tanstack 1.14.5 → 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/README.md +13 -9
- package/dist/auto.d.ts +5 -5
- package/dist/browser/context.d.ts +11 -12
- package/dist/browser/debug-headers.d.ts +2 -3
- package/dist/browser/error-reporting.d.ts +7 -8
- package/dist/browser/handlers.d.ts +4 -5
- package/dist/browser/index.d.ts +1 -1
- package/dist/browser/loaders.d.ts +10 -11
- package/dist/browser/loaders.js +11 -11
- package/dist/browser/metrics.d.ts +8 -9
- package/dist/browser/middleware.d.ts +7 -8
- package/dist/browser/server-functions.d.ts +4 -5
- package/dist/browser/testing.d.ts +9 -10
- package/dist/browser/types.d.ts +1 -1
- package/dist/context.d.ts +11 -12
- package/dist/debug-headers.d.ts +3 -4
- package/dist/debug-headers.js +1 -1
- package/dist/{env-BpFWNnpL.js → env-rT3_WobG.js} +2 -2
- package/dist/error-reporting.d.ts +6 -7
- package/dist/handlers.d.ts +4 -5
- package/dist/index.d.ts +6 -6
- package/dist/index.js +1 -1
- package/dist/{loaders-CTK-UHdg.d.ts → loaders-CzjfY7s6.d.ts} +475 -383
- package/dist/loaders.d.ts +1 -1
- package/dist/loaders.js +93 -177
- package/dist/metrics.d.ts +5 -6
- package/dist/middleware.d.ts +7 -8
- package/dist/middleware.js +1 -1
- package/dist/server-functions.d.ts +4 -5
- package/dist/server-functions.js +1 -1
- package/dist/testing.d.ts +8 -9
- package/dist/{types-CrBF_-MC.d.ts → types-CjDnjt3Q.d.ts} +17 -17
- package/dist/{types-BZNf5yHJ.d.ts → types-DD1_xVG9.d.ts} +17 -17
- package/package.json +14 -14
package/README.md
CHANGED
|
@@ -146,24 +146,28 @@ export const sensitiveOperation = createServerFn({ method: 'POST' })
|
|
|
146
146
|
|
|
147
147
|
### Route Loaders
|
|
148
148
|
|
|
149
|
-
Use `traceLoader` and `traceBeforeLoad` for route-level tracing:
|
|
149
|
+
Use `traceLoader` and `traceBeforeLoad` for route-level tracing. Call them from inside the route's own `beforeLoad` / `loader`, passing the context through:
|
|
150
150
|
|
|
151
151
|
```typescript
|
|
152
152
|
import { createFileRoute, redirect } from '@tanstack/react-router';
|
|
153
153
|
import { traceLoader, traceBeforeLoad } from 'autotel-tanstack/loaders';
|
|
154
154
|
|
|
155
155
|
export const Route = createFileRoute('/users/$userId')({
|
|
156
|
-
beforeLoad:
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
156
|
+
beforeLoad: (ctx) =>
|
|
157
|
+
traceBeforeLoad(ctx, async ({ context }) => {
|
|
158
|
+
if (!context.auth.isAuthenticated) {
|
|
159
|
+
throw redirect({ to: '/login' });
|
|
160
|
+
}
|
|
161
|
+
}),
|
|
162
|
+
loader: (ctx) =>
|
|
163
|
+
traceLoader(ctx, async ({ params }) => {
|
|
164
|
+
return await getUser(params.userId);
|
|
165
|
+
}),
|
|
164
166
|
});
|
|
165
167
|
```
|
|
166
168
|
|
|
169
|
+
TanStack Router types each route's `beforeLoad` and `loader` from the function you write. Passing `ctx` through keeps that inference, so `params`, `search` and the context `beforeLoad` returns stay typed inside the traced function.
|
|
170
|
+
|
|
167
171
|
## Configuration
|
|
168
172
|
|
|
169
173
|
### createTracingServerHandler Options
|
package/dist/auto.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { n as instrument } from "./instrument-B4bfWksz.js";
|
|
2
2
|
import { functionTracingMiddleware, tracingMiddleware } from "./middleware.js";
|
|
3
3
|
import { traceServerFn } from "./server-functions.js";
|
|
4
|
-
import { n as traceBeforeLoad, r as traceLoader } from "./loaders-
|
|
4
|
+
import { n as traceBeforeLoad, r as traceLoader } from "./loaders-CzjfY7s6.js";
|
|
5
5
|
//#region src/auto.d.ts
|
|
6
6
|
/** Check if auto-instrumentation is active. */
|
|
7
|
-
declare function isAutoInstrumentationActive(): boolean;
|
|
7
|
+
export declare function isAutoInstrumentationActive(): boolean;
|
|
8
8
|
/** The configured service name. */
|
|
9
|
-
declare function getServiceName(): string;
|
|
9
|
+
export declare function getServiceName(): string;
|
|
10
10
|
/** The configured OTLP endpoint, if any. */
|
|
11
|
-
declare function getEndpoint(): string | undefined;
|
|
11
|
+
export declare function getEndpoint(): string | undefined;
|
|
12
12
|
//#endregion
|
|
13
|
-
export { functionTracingMiddleware,
|
|
13
|
+
export { functionTracingMiddleware, instrument, traceBeforeLoad, traceLoader, traceServerFn, tracingMiddleware };
|
|
@@ -8,42 +8,41 @@
|
|
|
8
8
|
/**
|
|
9
9
|
* Type representing values that can be used to initialize Headers
|
|
10
10
|
*/
|
|
11
|
-
type HeadersInitType = Headers | Record<string, string> | [string, string][];
|
|
11
|
+
export type HeadersInitType = Headers | Record<string, string> | [string, string][];
|
|
12
12
|
/**
|
|
13
13
|
* Browser stub: Returns root context (no parent)
|
|
14
14
|
*/
|
|
15
|
-
declare function extractContextFromRequest(_request: Request): unknown;
|
|
15
|
+
export declare function extractContextFromRequest(_request: Request): unknown;
|
|
16
16
|
/**
|
|
17
17
|
* Browser stub: Returns headers unchanged
|
|
18
18
|
*/
|
|
19
|
-
declare function injectContextToHeaders(headers: Headers, ctx?: unknown): Headers;
|
|
19
|
+
export declare function injectContextToHeaders(headers: Headers, ctx?: unknown): Headers;
|
|
20
20
|
/**
|
|
21
21
|
* Browser stub: Create headers with optional initial values
|
|
22
22
|
*/
|
|
23
|
-
declare function createTracedHeaders(existingHeaders?: HeadersInitType, ctx?: unknown): Headers;
|
|
23
|
+
export declare function createTracedHeaders(existingHeaders?: HeadersInitType, ctx?: unknown): Headers;
|
|
24
24
|
/**
|
|
25
25
|
* Browser stub: Run function and return result
|
|
26
26
|
*/
|
|
27
|
-
declare function runInContext<T>(parentContext: unknown, fn: () => T): T;
|
|
27
|
+
export declare function runInContext<T>(parentContext: unknown, fn: () => T): T;
|
|
28
28
|
/**
|
|
29
29
|
* Browser stub: Returns empty context object
|
|
30
30
|
*/
|
|
31
|
-
declare function getActiveContext(): unknown;
|
|
31
|
+
export declare function getActiveContext(): unknown;
|
|
32
32
|
/**
|
|
33
33
|
* Browser stub: Returns empty string
|
|
34
34
|
*/
|
|
35
|
-
declare function getTraceParent(): string;
|
|
35
|
+
export declare function getTraceParent(): string;
|
|
36
36
|
/**
|
|
37
37
|
* Browser stub: Returns empty string
|
|
38
38
|
*/
|
|
39
|
-
declare function getTraceState(): string;
|
|
39
|
+
export declare function getTraceState(): string;
|
|
40
40
|
/**
|
|
41
41
|
* Browser stub: Returns undefined
|
|
42
42
|
*/
|
|
43
|
-
declare function getCurrentTraceId(): string | undefined;
|
|
43
|
+
export declare function getCurrentTraceId(): string | undefined;
|
|
44
44
|
/**
|
|
45
45
|
* Browser stub: Returns undefined
|
|
46
46
|
*/
|
|
47
|
-
declare function getCurrentSpanId(): string | undefined;
|
|
48
|
-
//#endregion
|
|
49
|
-
export { HeadersInitType, createTracedHeaders, extractContextFromRequest, getActiveContext, getCurrentSpanId, getCurrentTraceId, getTraceParent, getTraceState, injectContextToHeaders, runInContext };
|
|
47
|
+
export declare function getCurrentSpanId(): string | undefined;
|
|
48
|
+
//#endregion
|
|
@@ -3,6 +3,5 @@ import { MiddlewareHandler } from "./middleware.js";
|
|
|
3
3
|
/**
|
|
4
4
|
* Browser stub: Returns pass-through middleware
|
|
5
5
|
*/
|
|
6
|
-
declare function debugHeadersMiddleware<TContext = unknown>(): MiddlewareHandler<TContext>;
|
|
7
|
-
//#endregion
|
|
8
|
-
export { debugHeadersMiddleware };
|
|
6
|
+
export declare function debugHeadersMiddleware<TContext = unknown>(): MiddlewareHandler<TContext>;
|
|
7
|
+
//#endregion
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
/**
|
|
9
9
|
* Error entry structure (stub)
|
|
10
10
|
*/
|
|
11
|
-
interface ErrorEntry {
|
|
11
|
+
export interface ErrorEntry {
|
|
12
12
|
timestamp: string;
|
|
13
13
|
message: string;
|
|
14
14
|
stack?: string;
|
|
@@ -17,22 +17,21 @@ interface ErrorEntry {
|
|
|
17
17
|
/**
|
|
18
18
|
* Browser stub: No-op
|
|
19
19
|
*/
|
|
20
|
-
declare function reportError(error: Error, context?: Record<string, unknown>): void;
|
|
20
|
+
export declare function reportError(error: Error, context?: Record<string, unknown>): void;
|
|
21
21
|
/**
|
|
22
22
|
* Browser stub: Returns empty array
|
|
23
23
|
*/
|
|
24
|
-
declare function getRecentErrors(limit?: number): ErrorEntry[];
|
|
24
|
+
export declare function getRecentErrors(limit?: number): ErrorEntry[];
|
|
25
25
|
/**
|
|
26
26
|
* Browser stub: No-op
|
|
27
27
|
*/
|
|
28
|
-
declare function clearErrors(): void;
|
|
28
|
+
export declare function clearErrors(): void;
|
|
29
29
|
/**
|
|
30
30
|
* Browser stub: Returns JSON Response with empty errors
|
|
31
31
|
*/
|
|
32
|
-
declare function createErrorReportingHandler(): () => Response;
|
|
32
|
+
export declare function createErrorReportingHandler(): () => Response;
|
|
33
33
|
/**
|
|
34
34
|
* Browser stub: Returns function unchanged
|
|
35
35
|
*/
|
|
36
|
-
declare function withErrorReporting<T extends (...args: any[]) => any>(fn: T, context?: Record<string, unknown>): T;
|
|
37
|
-
//#endregion
|
|
38
|
-
export { ErrorEntry, clearErrors, createErrorReportingHandler, getRecentErrors, reportError, withErrorReporting };
|
|
36
|
+
export declare function withErrorReporting<T extends (...args: any[]) => any>(fn: T, context?: Record<string, unknown>): T;
|
|
37
|
+
//#endregion
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import { c as WrapStartHandlerConfig } from "../types-
|
|
1
|
+
import { c as WrapStartHandlerConfig } from "../types-CjDnjt3Q.js";
|
|
2
2
|
//#region src/browser/handlers.d.ts
|
|
3
3
|
/**
|
|
4
4
|
* Handler type
|
|
5
5
|
*/
|
|
6
|
-
type StartHandler<T = unknown> = (request: Request) => Promise<T>;
|
|
6
|
+
export type StartHandler<T = unknown> = (request: Request) => Promise<T>;
|
|
7
7
|
/**
|
|
8
8
|
* Browser stub: Returns the handler unchanged
|
|
9
9
|
*/
|
|
10
|
-
declare function wrapStartHandler<T>(config?: WrapStartHandlerConfig): (handler: StartHandler<T>) => StartHandler<T>;
|
|
11
|
-
//#endregion
|
|
12
|
-
export { StartHandler, wrapStartHandler };
|
|
10
|
+
export declare function wrapStartHandler<T>(config?: WrapStartHandlerConfig): (handler: StartHandler<T>) => StartHandler<T>;
|
|
11
|
+
//#endregion
|
package/dist/browser/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { HeadersInitType, createTracedHeaders, extractContextFromRequest, getActiveContext, getCurrentSpanId, getCurrentTraceId, getTraceParent, getTraceState, injectContextToHeaders, runInContext } from "./context.js";
|
|
2
|
-
import { a as TraceLoaderConfig, c as WrapStartHandlerConfig, i as TanStackInstrumentationConfig, n as DEFAULT_CONFIG, o as TraceServerFnConfig, r as SPAN_ATTRIBUTES, s as TracingMiddlewareConfig, t as Attributes } from "../types-
|
|
2
|
+
import { a as TraceLoaderConfig, c as WrapStartHandlerConfig, i as TanStackInstrumentationConfig, n as DEFAULT_CONFIG, o as TraceServerFnConfig, r as SPAN_ATTRIBUTES, s as TracingMiddlewareConfig, t as Attributes } from "../types-CjDnjt3Q.js";
|
|
3
3
|
import { MiddlewareHandler, createTracingMiddleware, createTracingServerHandler, functionTracingMiddleware, tracingMiddleware } from "./middleware.js";
|
|
4
4
|
import { debugHeadersMiddleware } from "./debug-headers.js";
|
|
5
5
|
import { ErrorEntry, clearErrors, createErrorReportingHandler, getRecentErrors, reportError, withErrorReporting } from "./error-reporting.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as TraceLoaderConfig } from "../types-
|
|
1
|
+
import { a as TraceLoaderConfig } from "../types-CjDnjt3Q.js";
|
|
2
2
|
//#region src/browser/loaders.d.ts
|
|
3
3
|
/**
|
|
4
4
|
* Loader context type (compatible with TanStack router loader context)
|
|
@@ -11,19 +11,18 @@ interface LoaderContext {
|
|
|
11
11
|
[key: string]: unknown;
|
|
12
12
|
}
|
|
13
13
|
/**
|
|
14
|
-
* Browser stub:
|
|
14
|
+
* Browser stub: Runs the loader logic untraced
|
|
15
15
|
*/
|
|
16
|
-
declare function traceLoader<
|
|
16
|
+
export declare function traceLoader<TContext extends LoaderContext, TResult>(context: TContext, loaderFn: (context: TContext) => TResult, config?: TraceLoaderConfig): TResult;
|
|
17
17
|
/**
|
|
18
|
-
* Browser stub:
|
|
18
|
+
* Browser stub: Runs the beforeLoad logic untraced
|
|
19
19
|
*/
|
|
20
|
-
declare function traceBeforeLoad<
|
|
20
|
+
export declare function traceBeforeLoad<TContext extends LoaderContext, TResult>(context: TContext, beforeLoadFn: (context: TContext) => TResult, config?: TraceLoaderConfig): TResult;
|
|
21
21
|
/**
|
|
22
|
-
* Browser stub: Returns object with
|
|
22
|
+
* Browser stub: Returns object with untraced runners
|
|
23
23
|
*/
|
|
24
|
-
declare function createTracedRoute(routeId: string, config?: Omit<TraceLoaderConfig, 'name'>): {
|
|
25
|
-
loader<
|
|
26
|
-
beforeLoad<
|
|
24
|
+
export declare function createTracedRoute(routeId: string, config?: Omit<TraceLoaderConfig, 'name'>): {
|
|
25
|
+
loader<TContext extends LoaderContext, TResult>(context: TContext, loaderFn: (context: TContext) => TResult): TResult;
|
|
26
|
+
beforeLoad<TContext extends LoaderContext, TResult>(context: TContext, beforeLoadFn: (context: TContext) => TResult): TResult;
|
|
27
27
|
};
|
|
28
|
-
//#endregion
|
|
29
|
-
export { createTracedRoute, traceBeforeLoad, traceLoader };
|
|
28
|
+
//#endregion
|
package/dist/browser/loaders.js
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
//#region src/browser/loaders.ts
|
|
2
2
|
/**
|
|
3
|
-
* Browser stub:
|
|
3
|
+
* Browser stub: Runs the loader logic untraced
|
|
4
4
|
*/
|
|
5
|
-
function traceLoader(loaderFn, config) {
|
|
6
|
-
return loaderFn;
|
|
5
|
+
function traceLoader(context, loaderFn, config) {
|
|
6
|
+
return loaderFn(context);
|
|
7
7
|
}
|
|
8
8
|
/**
|
|
9
|
-
* Browser stub:
|
|
9
|
+
* Browser stub: Runs the beforeLoad logic untraced
|
|
10
10
|
*/
|
|
11
|
-
function traceBeforeLoad(beforeLoadFn, config) {
|
|
12
|
-
return beforeLoadFn;
|
|
11
|
+
function traceBeforeLoad(context, beforeLoadFn, config) {
|
|
12
|
+
return beforeLoadFn(context);
|
|
13
13
|
}
|
|
14
14
|
/**
|
|
15
|
-
* Browser stub: Returns object with
|
|
15
|
+
* Browser stub: Returns object with untraced runners
|
|
16
16
|
*/
|
|
17
17
|
function createTracedRoute(routeId, config) {
|
|
18
18
|
return {
|
|
19
|
-
loader(loaderFn) {
|
|
20
|
-
return loaderFn;
|
|
19
|
+
loader(context, loaderFn) {
|
|
20
|
+
return loaderFn(context);
|
|
21
21
|
},
|
|
22
|
-
beforeLoad(beforeLoadFn) {
|
|
23
|
-
return beforeLoadFn;
|
|
22
|
+
beforeLoad(context, beforeLoadFn) {
|
|
23
|
+
return beforeLoadFn(context);
|
|
24
24
|
}
|
|
25
25
|
};
|
|
26
26
|
}
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
/**
|
|
9
9
|
* Metrics data structure (stub)
|
|
10
10
|
*/
|
|
11
|
-
interface MetricsData {
|
|
11
|
+
export interface MetricsData {
|
|
12
12
|
requestCount: number;
|
|
13
13
|
errorCount: number;
|
|
14
14
|
avgLatency: number;
|
|
@@ -25,23 +25,23 @@ interface MetricsData {
|
|
|
25
25
|
/**
|
|
26
26
|
* Browser stub: Returns empty metrics
|
|
27
27
|
*/
|
|
28
|
-
declare function getMetrics(): MetricsData;
|
|
28
|
+
export declare function getMetrics(): MetricsData;
|
|
29
29
|
/**
|
|
30
30
|
* Browser stub: No-op
|
|
31
31
|
*/
|
|
32
|
-
declare function recordTiming(name: string, durationMs: number): void;
|
|
32
|
+
export declare function recordTiming(name: string, durationMs: number): void;
|
|
33
33
|
/**
|
|
34
34
|
* Browser stub: No-op
|
|
35
35
|
*/
|
|
36
|
-
declare function recordError(name: string): void;
|
|
36
|
+
export declare function recordError(name: string): void;
|
|
37
37
|
/**
|
|
38
38
|
* Browser stub: No-op
|
|
39
39
|
*/
|
|
40
|
-
declare function resetMetrics(): void;
|
|
40
|
+
export declare function resetMetrics(): void;
|
|
41
41
|
/**
|
|
42
42
|
* Browser stub: No-op metrics collector
|
|
43
43
|
*/
|
|
44
|
-
declare const metricsCollector: {
|
|
44
|
+
export declare const metricsCollector: {
|
|
45
45
|
recordTiming: typeof recordTiming;
|
|
46
46
|
recordError: typeof recordError;
|
|
47
47
|
getMetrics: typeof getMetrics;
|
|
@@ -50,6 +50,5 @@ declare const metricsCollector: {
|
|
|
50
50
|
/**
|
|
51
51
|
* Browser stub: Returns JSON Response with empty metrics
|
|
52
52
|
*/
|
|
53
|
-
declare function createMetricsHandler(): () => Response;
|
|
54
|
-
//#endregion
|
|
55
|
-
export { MetricsData, createMetricsHandler, getMetrics, metricsCollector, recordError, recordTiming, resetMetrics };
|
|
53
|
+
export declare function createMetricsHandler(): () => Response;
|
|
54
|
+
//#endregion
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { s as TracingMiddlewareConfig } from "../types-
|
|
1
|
+
import { s as TracingMiddlewareConfig } from "../types-CjDnjt3Q.js";
|
|
2
2
|
//#region src/browser/middleware.d.ts
|
|
3
3
|
/**
|
|
4
4
|
* Generic middleware handler type
|
|
5
5
|
*/
|
|
6
|
-
interface MiddlewareHandler<TContext = unknown> {
|
|
6
|
+
export interface MiddlewareHandler<TContext = unknown> {
|
|
7
7
|
(opts: {
|
|
8
8
|
next: (ctx?: Partial<TContext>) => Promise<TContext>;
|
|
9
9
|
context: TContext;
|
|
@@ -19,22 +19,21 @@ interface MiddlewareHandler<TContext = unknown> {
|
|
|
19
19
|
/**
|
|
20
20
|
* Browser stub: Returns pass-through middleware
|
|
21
21
|
*/
|
|
22
|
-
declare function createTracingMiddleware<TContext = unknown>(config?: TracingMiddlewareConfig): MiddlewareHandler<TContext>;
|
|
22
|
+
export declare function createTracingMiddleware<TContext = unknown>(config?: TracingMiddlewareConfig): MiddlewareHandler<TContext>;
|
|
23
23
|
/**
|
|
24
24
|
* Browser stub: Returns pass-through middleware
|
|
25
25
|
*/
|
|
26
|
-
declare function tracingMiddleware<TContext = unknown>(config?: TracingMiddlewareConfig): MiddlewareHandler<TContext>;
|
|
26
|
+
export declare function tracingMiddleware<TContext = unknown>(config?: TracingMiddlewareConfig): MiddlewareHandler<TContext>;
|
|
27
27
|
/**
|
|
28
28
|
* Browser stub: Returns pass-through middleware
|
|
29
29
|
*/
|
|
30
|
-
declare function functionTracingMiddleware<TContext = unknown>(config?: Omit<TracingMiddlewareConfig, 'type'>): MiddlewareHandler<TContext>;
|
|
30
|
+
export declare function functionTracingMiddleware<TContext = unknown>(config?: Omit<TracingMiddlewareConfig, 'type'>): MiddlewareHandler<TContext>;
|
|
31
31
|
/**
|
|
32
32
|
* Browser stub: Returns pass-through handler for createMiddleware().server()
|
|
33
33
|
*/
|
|
34
|
-
declare function createTracingServerHandler<TContext = unknown>(config?: TracingMiddlewareConfig): (opts: {
|
|
34
|
+
export declare function createTracingServerHandler<TContext = unknown>(config?: TracingMiddlewareConfig): (opts: {
|
|
35
35
|
next: (ctx?: Partial<TContext>) => Promise<TContext>;
|
|
36
36
|
context: TContext;
|
|
37
37
|
request?: Request;
|
|
38
38
|
}) => Promise<TContext>;
|
|
39
|
-
//#endregion
|
|
40
|
-
export { MiddlewareHandler, createTracingMiddleware, createTracingServerHandler, functionTracingMiddleware, tracingMiddleware };
|
|
39
|
+
//#endregion
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import { o as TraceServerFnConfig } from "../types-
|
|
1
|
+
import { o as TraceServerFnConfig } from "../types-CjDnjt3Q.js";
|
|
2
2
|
//#region src/browser/server-functions.d.ts
|
|
3
3
|
/**
|
|
4
4
|
* Browser stub: Returns the server function unchanged
|
|
5
5
|
*/
|
|
6
|
-
declare function traceServerFn<T extends (...args: unknown[]) => Promise<unknown>>(serverFn: T, config?: TraceServerFnConfig): T;
|
|
6
|
+
export declare function traceServerFn<T extends (...args: unknown[]) => Promise<unknown>>(serverFn: T, config?: TraceServerFnConfig): T;
|
|
7
7
|
/**
|
|
8
8
|
* Browser stub: Returns the createServerFn unchanged
|
|
9
9
|
*/
|
|
10
|
-
declare function createTracedServerFnFactory<TCreateServerFn extends (...args: unknown[]) => unknown>(createServerFnOriginal: TCreateServerFn, defaultConfig?: Omit<TraceServerFnConfig, 'name'>): TCreateServerFn;
|
|
11
|
-
//#endregion
|
|
12
|
-
export { createTracedServerFnFactory, traceServerFn };
|
|
10
|
+
export declare function createTracedServerFnFactory<TCreateServerFn extends (...args: unknown[]) => unknown>(createServerFnOriginal: TCreateServerFn, defaultConfig?: Omit<TraceServerFnConfig, 'name'>): TCreateServerFn;
|
|
11
|
+
//#endregion
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
/**
|
|
9
9
|
* Test span structure (stub)
|
|
10
10
|
*/
|
|
11
|
-
interface TestSpan {
|
|
11
|
+
export interface TestSpan {
|
|
12
12
|
name: string;
|
|
13
13
|
attributes: Record<string, unknown>;
|
|
14
14
|
status: {
|
|
@@ -24,7 +24,7 @@ interface TestSpan {
|
|
|
24
24
|
/**
|
|
25
25
|
* Test collector structure (stub)
|
|
26
26
|
*/
|
|
27
|
-
interface TestCollector {
|
|
27
|
+
export interface TestCollector {
|
|
28
28
|
getSpans(): TestSpan[];
|
|
29
29
|
getSpansByName(name: string): TestSpan[];
|
|
30
30
|
clear(): void;
|
|
@@ -33,22 +33,22 @@ interface TestCollector {
|
|
|
33
33
|
/**
|
|
34
34
|
* Browser stub: Returns empty collector
|
|
35
35
|
*/
|
|
36
|
-
declare function createTestCollector(): TestCollector;
|
|
36
|
+
export declare function createTestCollector(): TestCollector;
|
|
37
37
|
/**
|
|
38
38
|
* Browser stub: No-op
|
|
39
39
|
*/
|
|
40
|
-
declare function assertSpanCreated(collector: TestCollector, name: string): void;
|
|
40
|
+
export declare function assertSpanCreated(collector: TestCollector, name: string): void;
|
|
41
41
|
/**
|
|
42
42
|
* Browser stub: No-op
|
|
43
43
|
*/
|
|
44
|
-
declare function assertSpanHasAttribute(collector: TestCollector, name: string, key: string, value?: unknown): void;
|
|
44
|
+
export declare function assertSpanHasAttribute(collector: TestCollector, name: string, key: string, value?: unknown): void;
|
|
45
45
|
/**
|
|
46
46
|
* Serialized span type (browser stub - mirrors server SerializedSpan).
|
|
47
47
|
*
|
|
48
48
|
* Defined as a `type` (not `interface`) so it is assignable to
|
|
49
49
|
* `Record<string, unknown>` in TypeScript 6+ strict mode.
|
|
50
50
|
*/
|
|
51
|
-
type SerializedSpan = {
|
|
51
|
+
export type SerializedSpan = {
|
|
52
52
|
name: string;
|
|
53
53
|
spanId: string;
|
|
54
54
|
traceId: string;
|
|
@@ -71,7 +71,7 @@ type CreateFileRoute = (path: string) => (options: any) => any;
|
|
|
71
71
|
/**
|
|
72
72
|
* Browser stub: createTestSpansRoute is server-only.
|
|
73
73
|
*/
|
|
74
|
-
declare function createTestSpansRoute(createFileRoute: CreateFileRoute, path?: string): unknown;
|
|
74
|
+
export declare function createTestSpansRoute(createFileRoute: CreateFileRoute, path?: string): unknown;
|
|
75
75
|
/** What createTestSpansHandlers() answers with. */
|
|
76
76
|
interface CreateTestSpansHandlersResult {
|
|
77
77
|
GET: (input: HandlerInput) => Response;
|
|
@@ -81,6 +81,5 @@ interface CreateTestSpansHandlersResult {
|
|
|
81
81
|
* Browser stub: test-spans handlers are server-only.
|
|
82
82
|
* Returns no-op handlers that always return 404.
|
|
83
83
|
*/
|
|
84
|
-
declare function createTestSpansHandlers(): CreateTestSpansHandlersResult;
|
|
85
|
-
//#endregion
|
|
86
|
-
export { SerializedSpan, TestCollector, TestSpan, assertSpanCreated, assertSpanHasAttribute, createTestCollector, createTestSpansHandlers, createTestSpansRoute };
|
|
84
|
+
export declare function createTestSpansHandlers(): CreateTestSpansHandlersResult;
|
|
85
|
+
//#endregion
|
package/dist/browser/types.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as TraceLoaderConfig, c as WrapStartHandlerConfig, i as TanStackInstrumentationConfig, n as DEFAULT_CONFIG, o as TraceServerFnConfig, r as SPAN_ATTRIBUTES, s as TracingMiddlewareConfig, t as Attributes } from "../types-
|
|
1
|
+
import { a as TraceLoaderConfig, c as WrapStartHandlerConfig, i as TanStackInstrumentationConfig, n as DEFAULT_CONFIG, o as TraceServerFnConfig, r as SPAN_ATTRIBUTES, s as TracingMiddlewareConfig, t as Attributes } from "../types-CjDnjt3Q.js";
|
|
2
2
|
export { Attributes, DEFAULT_CONFIG, SPAN_ATTRIBUTES, TanStackInstrumentationConfig, TraceLoaderConfig, TraceServerFnConfig, TracingMiddlewareConfig, WrapStartHandlerConfig };
|
package/dist/context.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { Context } from "@opentelemetry/api";
|
|
|
4
4
|
* Type representing values that can be used to initialize Headers
|
|
5
5
|
* This is equivalent to the DOM's HeadersInit type but works in Node.js
|
|
6
6
|
*/
|
|
7
|
-
type HeadersInitType = Headers | Record<string, string> | [string, string][];
|
|
7
|
+
export type HeadersInitType = Headers | Record<string, string> | [string, string][];
|
|
8
8
|
/**
|
|
9
9
|
* Extract OpenTelemetry context from HTTP request headers
|
|
10
10
|
*
|
|
@@ -25,7 +25,7 @@ type HeadersInitType = Headers | Record<string, string> | [string, string][];
|
|
|
25
25
|
* });
|
|
26
26
|
* ```
|
|
27
27
|
*/
|
|
28
|
-
declare function extractContextFromRequest(request: Request): Context;
|
|
28
|
+
export declare function extractContextFromRequest(request: Request): Context;
|
|
29
29
|
/**
|
|
30
30
|
* Inject OpenTelemetry context into HTTP headers
|
|
31
31
|
*
|
|
@@ -45,7 +45,7 @@ declare function extractContextFromRequest(request: Request): Context;
|
|
|
45
45
|
* await fetch('https://api.example.com', { headers });
|
|
46
46
|
* ```
|
|
47
47
|
*/
|
|
48
|
-
declare function injectContextToHeaders(headers: Headers, ctx?: Context): Headers;
|
|
48
|
+
export declare function injectContextToHeaders(headers: Headers, ctx?: Context): Headers;
|
|
49
49
|
/**
|
|
50
50
|
* Create a new Headers object with injected trace context
|
|
51
51
|
*
|
|
@@ -66,7 +66,7 @@ declare function injectContextToHeaders(headers: Headers, ctx?: Context): Header
|
|
|
66
66
|
* });
|
|
67
67
|
* ```
|
|
68
68
|
*/
|
|
69
|
-
declare function createTracedHeaders(existingHeaders?: HeadersInitType, ctx?: Context): Headers;
|
|
69
|
+
export declare function createTracedHeaders(existingHeaders?: HeadersInitType, ctx?: Context): Headers;
|
|
70
70
|
/**
|
|
71
71
|
* Run a function within a specific OpenTelemetry context
|
|
72
72
|
*
|
|
@@ -85,25 +85,24 @@ declare function createTracedHeaders(existingHeaders?: HeadersInitType, ctx?: Co
|
|
|
85
85
|
* });
|
|
86
86
|
* ```
|
|
87
87
|
*/
|
|
88
|
-
declare function runInContext<T>(parentContext: Context, fn: () => T): T;
|
|
88
|
+
export declare function runInContext<T>(parentContext: Context, fn: () => T): T;
|
|
89
89
|
/**
|
|
90
90
|
* Get the current active context
|
|
91
91
|
*
|
|
92
92
|
* @returns The current active OpenTelemetry context
|
|
93
93
|
*/
|
|
94
|
-
declare function getActiveContext(): Context;
|
|
94
|
+
export declare function getActiveContext(): Context;
|
|
95
95
|
/**
|
|
96
96
|
* The `traceparent` header value for the active context, or `''` when there is
|
|
97
97
|
* no active span. Use it to log the id you send downstream.
|
|
98
98
|
*/
|
|
99
|
-
declare function getTraceParent(ctx?: Context): string;
|
|
99
|
+
export declare function getTraceParent(ctx?: Context): string;
|
|
100
100
|
/**
|
|
101
101
|
* The `tracestate` header value for the active context, or `''` when unset.
|
|
102
102
|
*/
|
|
103
|
-
declare function getTraceState(ctx?: Context): string;
|
|
103
|
+
export declare function getTraceState(ctx?: Context): string;
|
|
104
104
|
/** Trace id of the active span, or `undefined` outside a span. */
|
|
105
|
-
declare function getCurrentTraceId(ctx?: Context): string | undefined;
|
|
105
|
+
export declare function getCurrentTraceId(ctx?: Context): string | undefined;
|
|
106
106
|
/** Span id of the active span, or `undefined` outside a span. */
|
|
107
|
-
declare function getCurrentSpanId(ctx?: Context): string | undefined;
|
|
108
|
-
//#endregion
|
|
109
|
-
export { HeadersInitType, createTracedHeaders, extractContextFromRequest, getActiveContext, getCurrentSpanId, getCurrentTraceId, getTraceParent, getTraceState, injectContextToHeaders, runInContext };
|
|
107
|
+
export declare function getCurrentSpanId(ctx?: Context): string | undefined;
|
|
108
|
+
//#endregion
|
package/dist/debug-headers.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { MiddlewareHandler } from "./middleware.js";
|
|
|
3
3
|
/**
|
|
4
4
|
* Configuration for debug headers middleware
|
|
5
5
|
*/
|
|
6
|
-
interface DebugHeadersConfig {
|
|
6
|
+
export interface DebugHeadersConfig {
|
|
7
7
|
/**
|
|
8
8
|
* Whether to enable debug headers
|
|
9
9
|
* @default process.env.NODE_ENV === 'development'
|
|
@@ -36,6 +36,5 @@ interface DebugHeadersConfig {
|
|
|
36
36
|
* }));
|
|
37
37
|
* ```
|
|
38
38
|
*/
|
|
39
|
-
declare function debugHeadersMiddleware(config?: DebugHeadersConfig): MiddlewareHandler;
|
|
40
|
-
//#endregion
|
|
41
|
-
export { DebugHeadersConfig, debugHeadersMiddleware };
|
|
39
|
+
export declare function debugHeadersMiddleware(config?: DebugHeadersConfig): MiddlewareHandler;
|
|
40
|
+
//#endregion
|
package/dist/debug-headers.js
CHANGED
|
@@ -8,13 +8,13 @@
|
|
|
8
8
|
* Uses typeof checks to avoid TypeScript DOM type requirements
|
|
9
9
|
*/
|
|
10
10
|
function isBrowser() {
|
|
11
|
-
return typeof globalThis !== "undefined" &&
|
|
11
|
+
return typeof globalThis !== "undefined" && globalThis.window !== void 0 && globalThis.document !== void 0;
|
|
12
12
|
}
|
|
13
13
|
/**
|
|
14
14
|
* Check if we're running in a Node.js environment
|
|
15
15
|
*/
|
|
16
16
|
function isNode() {
|
|
17
|
-
return typeof process !== "undefined" &&
|
|
17
|
+
return typeof process !== "undefined" && process.versions !== void 0 && process.versions.node !== void 0;
|
|
18
18
|
}
|
|
19
19
|
/**
|
|
20
20
|
* Check if we're in a server-side context
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
/**
|
|
9
9
|
* Error report data structure
|
|
10
10
|
*/
|
|
11
|
-
interface ErrorReport {
|
|
11
|
+
export interface ErrorReport {
|
|
12
12
|
id: string;
|
|
13
13
|
count: number;
|
|
14
14
|
lastSeen: Date;
|
|
@@ -52,7 +52,7 @@ declare class ErrorStore {
|
|
|
52
52
|
/**
|
|
53
53
|
* Global error store instance
|
|
54
54
|
*/
|
|
55
|
-
declare const errorStore: ErrorStore;
|
|
55
|
+
export declare const errorStore: ErrorStore;
|
|
56
56
|
/**
|
|
57
57
|
* Report an error to the error store
|
|
58
58
|
*
|
|
@@ -71,7 +71,7 @@ declare const errorStore: ErrorStore;
|
|
|
71
71
|
* }
|
|
72
72
|
* ```
|
|
73
73
|
*/
|
|
74
|
-
declare function reportError(error: Error, context?: unknown): string;
|
|
74
|
+
export declare function reportError(error: Error, context?: unknown): string;
|
|
75
75
|
/**
|
|
76
76
|
* Create an error reporting endpoint handler
|
|
77
77
|
*
|
|
@@ -94,7 +94,7 @@ declare function reportError(error: Error, context?: unknown): string;
|
|
|
94
94
|
* });
|
|
95
95
|
* ```
|
|
96
96
|
*/
|
|
97
|
-
declare function createErrorReportingHandler(): () => Promise<import("@tanstack/react-start").JsonResponse<{
|
|
97
|
+
export declare function createErrorReportingHandler(): () => Promise<import("@tanstack/react-start").JsonResponse<{
|
|
98
98
|
errors: ErrorReport[];
|
|
99
99
|
}>>;
|
|
100
100
|
/**
|
|
@@ -112,6 +112,5 @@ declare function createErrorReportingHandler(): () => Promise<import("@tanstack/
|
|
|
112
112
|
* }, { operation: 'riskyOperation' }));
|
|
113
113
|
* ```
|
|
114
114
|
*/
|
|
115
|
-
declare function withErrorReporting<TArgs extends unknown[], TReturn>(fn: (...args: TArgs) => Promise<TReturn>, context?: Record<string, unknown>): (...args: TArgs) => Promise<TReturn>;
|
|
116
|
-
//#endregion
|
|
117
|
-
export { ErrorReport, createErrorReportingHandler, errorStore, reportError, withErrorReporting };
|
|
115
|
+
export declare function withErrorReporting<TArgs extends unknown[], TReturn>(fn: (...args: TArgs) => Promise<TReturn>, context?: Record<string, unknown>): (...args: TArgs) => Promise<TReturn>;
|
|
116
|
+
//#endregion
|
package/dist/handlers.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { s as WrapStartHandlerConfig } from "./types-
|
|
1
|
+
import { s as WrapStartHandlerConfig } from "./types-DD1_xVG9.js";
|
|
2
2
|
//#region src/handlers.d.ts
|
|
3
3
|
/**
|
|
4
4
|
* Request handler type (compatible with TanStack Start handlers)
|
|
@@ -36,7 +36,7 @@ type RequestHandler = (request: Request, opts?: {
|
|
|
36
36
|
* export default wrapStartHandler()(createStartHandler(defaultStreamHandler));
|
|
37
37
|
* ```
|
|
38
38
|
*/
|
|
39
|
-
declare function wrapStartHandler(config?: WrapStartHandlerConfig): (handler: RequestHandler) => RequestHandler;
|
|
39
|
+
export declare function wrapStartHandler(config?: WrapStartHandlerConfig): (handler: RequestHandler) => RequestHandler;
|
|
40
40
|
/**
|
|
41
41
|
* Create a traced handler without auto-initialization
|
|
42
42
|
*
|
|
@@ -64,6 +64,5 @@ declare function wrapStartHandler(config?: WrapStartHandlerConfig): (handler: Re
|
|
|
64
64
|
* })(createStartHandler(defaultStreamHandler));
|
|
65
65
|
* ```
|
|
66
66
|
*/
|
|
67
|
-
declare function createTracedHandler(config?: Omit<WrapStartHandlerConfig, 'endpoint' | 'headers' | 'service'>): (handler: RequestHandler) => RequestHandler;
|
|
68
|
-
//#endregion
|
|
69
|
-
export { createTracedHandler, wrapStartHandler };
|
|
67
|
+
export declare function createTracedHandler(config?: Omit<WrapStartHandlerConfig, 'endpoint' | 'headers' | 'service'>): (handler: RequestHandler) => RequestHandler;
|
|
68
|
+
//#endregion
|