autotel-tanstack 1.13.51 → 1.13.53
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/auto.js +1 -1
- package/dist/browser/testing.d.ts +6 -4
- package/dist/context.d.ts +3 -2
- package/dist/context.js +3 -2
- package/dist/{control-flow-p-dnko0G.js → control-flow-Bahm3i0B.js} +7 -7
- package/dist/handlers.js +8 -10
- package/dist/index.js +2 -2
- package/dist/{instrument-DdLlMfRi.js → instrument-PWcmxYT9.js} +1 -1
- package/dist/loaders.js +14 -18
- package/dist/middleware.js +8 -10
- package/dist/server-functions.js +5 -6
- package/package.json +4 -4
package/dist/auto.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { functionTracingMiddleware, tracingMiddleware } from "./middleware.js";
|
|
2
2
|
import { traceServerFn } from "./server-functions.js";
|
|
3
3
|
import { traceBeforeLoad, traceLoader } from "./loaders.js";
|
|
4
|
-
import { t as instrument } from "./instrument-
|
|
4
|
+
import { t as instrument } from "./instrument-PWcmxYT9.js";
|
|
5
5
|
|
|
6
6
|
//#region src/auto.ts
|
|
7
7
|
/**
|
|
@@ -72,13 +72,15 @@ type CreateFileRoute = (path: string) => (options: any) => any;
|
|
|
72
72
|
* Browser stub: createTestSpansRoute is server-only.
|
|
73
73
|
*/
|
|
74
74
|
declare function createTestSpansRoute(createFileRoute: CreateFileRoute, path?: string): unknown;
|
|
75
|
+
/** What createTestSpansHandlers() answers with. */
|
|
76
|
+
interface CreateTestSpansHandlersResult {
|
|
77
|
+
GET: (input: HandlerInput) => Response;
|
|
78
|
+
DELETE: (input: HandlerInput) => Response;
|
|
79
|
+
}
|
|
75
80
|
/**
|
|
76
81
|
* Browser stub: test-spans handlers are server-only.
|
|
77
82
|
* Returns no-op handlers that always return 404.
|
|
78
83
|
*/
|
|
79
|
-
declare function createTestSpansHandlers():
|
|
80
|
-
GET: (input: HandlerInput) => Response;
|
|
81
|
-
DELETE: (input: HandlerInput) => Response;
|
|
82
|
-
};
|
|
84
|
+
declare function createTestSpansHandlers(): CreateTestSpansHandlersResult;
|
|
83
85
|
//#endregion
|
|
84
86
|
export { SerializedSpan, TestCollector, TestSpan, assertSpanCreated, assertSpanHasAttribute, createTestCollector, createTestSpansHandlers, createTestSpansRoute };
|
package/dist/context.d.ts
CHANGED
|
@@ -19,8 +19,9 @@ type HeadersInitType = Headers | Record<string, string> | [string, string][];
|
|
|
19
19
|
* const parentContext = extractContextFromRequest(request);
|
|
20
20
|
* context.with(parentContext, async () => {
|
|
21
21
|
* // Spans created here will be children of the extracted context
|
|
22
|
-
* await trace('my-operation', async ()=> {
|
|
23
|
-
|
|
22
|
+
* await trace.run('my-operation', async (ctx) => {
|
|
23
|
+
* ctx.setAttribute('operation.kind', 'example');
|
|
24
|
+
* });
|
|
24
25
|
* });
|
|
25
26
|
* ```
|
|
26
27
|
*/
|
package/dist/context.js
CHANGED
|
@@ -15,8 +15,9 @@ import { ROOT_CONTEXT, context, propagation, trace } from "@opentelemetry/api";
|
|
|
15
15
|
* const parentContext = extractContextFromRequest(request);
|
|
16
16
|
* context.with(parentContext, async () => {
|
|
17
17
|
* // Spans created here will be children of the extracted context
|
|
18
|
-
* await trace('my-operation', async ()=> {
|
|
19
|
-
|
|
18
|
+
* await trace.run('my-operation', async (ctx) => {
|
|
19
|
+
* ctx.setAttribute('operation.kind', 'example');
|
|
20
|
+
* });
|
|
20
21
|
* });
|
|
21
22
|
* ```
|
|
22
23
|
*/
|
|
@@ -55,11 +55,11 @@ const SPAN_ATTRIBUTES = {
|
|
|
55
55
|
* The `name`-based branch keeps older TanStack versions covered, which threw
|
|
56
56
|
* `RedirectError` / `NotFoundError` instances instead.
|
|
57
57
|
*/
|
|
58
|
-
function isControlFlowSignal(
|
|
59
|
-
if (
|
|
60
|
-
if (typeof
|
|
61
|
-
if (
|
|
62
|
-
const name =
|
|
58
|
+
function isControlFlowSignal(cause) {
|
|
59
|
+
if (globalThis.Response !== void 0 && cause instanceof Response && cause.options != null) return true;
|
|
60
|
+
if (typeof cause === "object" && cause !== null) {
|
|
61
|
+
if (cause.isNotFound === true) return true;
|
|
62
|
+
const name = cause.name;
|
|
63
63
|
if (name === "RedirectError" || name === "NotFoundError") return true;
|
|
64
64
|
}
|
|
65
65
|
return false;
|
|
@@ -69,8 +69,8 @@ function isControlFlowSignal(error) {
|
|
|
69
69
|
* `isError` option: returns `false` for control-flow signals so the span is
|
|
70
70
|
* marked OK and no exception is recorded, `true` for real errors.
|
|
71
71
|
*/
|
|
72
|
-
function isRealError(
|
|
73
|
-
return !isControlFlowSignal(
|
|
72
|
+
function isRealError(cause) {
|
|
73
|
+
return !isControlFlowSignal(cause);
|
|
74
74
|
}
|
|
75
75
|
|
|
76
76
|
//#endregion
|
package/dist/handlers.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { i as SPAN_ATTRIBUTES, n as isRealError, r as DEFAULT_CONFIG, t as isControlFlowSignal } from "./control-flow-
|
|
1
|
+
import { i as SPAN_ATTRIBUTES, n as isRealError, r as DEFAULT_CONFIG, t as isControlFlowSignal } from "./control-flow-Bahm3i0B.js";
|
|
2
2
|
import { extractContextFromRequest } from "./context.js";
|
|
3
3
|
import { t as isExcludedPath } from "./route-filter-dLg-j3jR.js";
|
|
4
4
|
import { SpanStatusCode, context } from "@opentelemetry/api";
|
|
5
|
-
import {
|
|
5
|
+
import { init, trace as trace$1 } from "autotel";
|
|
6
6
|
|
|
7
7
|
//#region src/handlers.ts
|
|
8
8
|
/**
|
|
@@ -63,11 +63,10 @@ function wrapStartHandler(config = {}) {
|
|
|
63
63
|
const parentContext = extractContextFromRequest(request);
|
|
64
64
|
return context.with(parentContext, async () => {
|
|
65
65
|
const spanName = `${request.method} ${url.pathname}`;
|
|
66
|
-
return trace$1({
|
|
66
|
+
return trace$1.run({
|
|
67
67
|
name: spanName,
|
|
68
68
|
isError: isRealError
|
|
69
|
-
}, async () => {
|
|
70
|
-
const ctx = getActiveTraceContext();
|
|
69
|
+
}, async (ctx) => {
|
|
71
70
|
ctx.setAttributes({
|
|
72
71
|
[SPAN_ATTRIBUTES.HTTP_REQUEST_METHOD]: request.method,
|
|
73
72
|
[SPAN_ATTRIBUTES.URL_PATH]: url.pathname,
|
|
@@ -109,7 +108,7 @@ function wrapStartHandler(config = {}) {
|
|
|
109
108
|
if (mergedConfig.captureErrors) ctx.recordError(error);
|
|
110
109
|
throw error;
|
|
111
110
|
}
|
|
112
|
-
})
|
|
111
|
+
});
|
|
113
112
|
});
|
|
114
113
|
};
|
|
115
114
|
};
|
|
@@ -153,11 +152,10 @@ function createTracedHandler(config = {}) {
|
|
|
153
152
|
const parentContext = extractContextFromRequest(request);
|
|
154
153
|
return context.with(parentContext, async () => {
|
|
155
154
|
const spanName = `${request.method} ${url.pathname}`;
|
|
156
|
-
return trace$1({
|
|
155
|
+
return trace$1.run({
|
|
157
156
|
name: spanName,
|
|
158
157
|
isError: isRealError
|
|
159
|
-
}, async () => {
|
|
160
|
-
const ctx = getActiveTraceContext();
|
|
158
|
+
}, async (ctx) => {
|
|
161
159
|
ctx.setAttributes({
|
|
162
160
|
[SPAN_ATTRIBUTES.HTTP_REQUEST_METHOD]: request.method,
|
|
163
161
|
[SPAN_ATTRIBUTES.URL_PATH]: url.pathname,
|
|
@@ -198,7 +196,7 @@ function createTracedHandler(config = {}) {
|
|
|
198
196
|
if (mergedConfig.captureErrors) ctx.recordError(error);
|
|
199
197
|
throw error;
|
|
200
198
|
}
|
|
201
|
-
})
|
|
199
|
+
});
|
|
202
200
|
});
|
|
203
201
|
};
|
|
204
202
|
};
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as SPAN_ATTRIBUTES, r as DEFAULT_CONFIG } from "./control-flow-
|
|
1
|
+
import { i as SPAN_ATTRIBUTES, r as DEFAULT_CONFIG } from "./control-flow-Bahm3i0B.js";
|
|
2
2
|
import { createTracedHeaders, extractContextFromRequest, getActiveContext, getCurrentSpanId, getCurrentTraceId, getTraceParent, getTraceState, injectContextToHeaders, runInContext } from "./context.js";
|
|
3
3
|
import { n as isNode, r as isServerSide, t as isBrowser } from "./env-BpFWNnpL.js";
|
|
4
4
|
import { createTracingMiddleware, createTracingServerHandler, functionTracingMiddleware, tracingMiddleware } from "./middleware.js";
|
|
@@ -8,7 +8,7 @@ import { createTracedHandler, wrapStartHandler } from "./handlers.js";
|
|
|
8
8
|
import { debugHeadersMiddleware } from "./debug-headers.js";
|
|
9
9
|
import { createMetricsHandler, metricsCollector, recordTiming } from "./metrics.js";
|
|
10
10
|
import { createErrorReportingHandler, errorStore, reportError, withErrorReporting } from "./error-reporting.js";
|
|
11
|
-
import { t as instrument } from "./instrument-
|
|
11
|
+
import { t as instrument } from "./instrument-PWcmxYT9.js";
|
|
12
12
|
import { flush, init, shutdown, span, trace } from "autotel";
|
|
13
13
|
|
|
14
14
|
export { DEFAULT_CONFIG, SPAN_ATTRIBUTES, createErrorReportingHandler, createMetricsHandler, createTracedHandler, createTracedHeaders, createTracedRoute, createTracedServerFnFactory, createTracingMiddleware, createTracingServerHandler, debugHeadersMiddleware, errorStore, extractContextFromRequest, flush, functionTracingMiddleware, getActiveContext, getCurrentSpanId, getCurrentTraceId, getTraceParent, getTraceState, init, injectContextToHeaders, instrument, isBrowser, isNode, isServerSide, metricsCollector, recordTiming, reportError, runInContext, shutdown, span, trace, traceBeforeLoad, traceLoader, traceServerFn, tracingMiddleware, withErrorReporting, wrapStartHandler };
|
|
@@ -27,7 +27,7 @@ import { SimpleSpanProcessor } from "autotel/processors";
|
|
|
27
27
|
* @example
|
|
28
28
|
* ```ts
|
|
29
29
|
* import { instrument } from 'autotel-tanstack';
|
|
30
|
-
* import { PostHogSubscriber } from 'autotel-
|
|
30
|
+
* import { PostHogSubscriber } from 'autotel-posthog/subscriber';
|
|
31
31
|
*
|
|
32
32
|
* instrument({
|
|
33
33
|
* subscribers: process.env.POSTHOG_KEY
|
package/dist/loaders.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { i as SPAN_ATTRIBUTES, n as isRealError, t as isControlFlowSignal } from "./control-flow-
|
|
1
|
+
import { i as SPAN_ATTRIBUTES, n as isRealError, t as isControlFlowSignal } from "./control-flow-Bahm3i0B.js";
|
|
2
2
|
import { r as isServerSide } from "./env-BpFWNnpL.js";
|
|
3
3
|
import { SpanStatusCode } from "@opentelemetry/api";
|
|
4
|
-
import {
|
|
4
|
+
import { trace as trace$1 } from "autotel";
|
|
5
5
|
|
|
6
6
|
//#region src/loaders.ts
|
|
7
7
|
/**
|
|
@@ -49,11 +49,10 @@ function traceLoader(loaderFn, config = {}) {
|
|
|
49
49
|
const routeId = context?.route?.id || "unknown";
|
|
50
50
|
const spanName = config.name || `tanstack.loader.${routeId}`;
|
|
51
51
|
const result = loaderFn(context);
|
|
52
|
-
if (!(result instanceof Promise)) return trace$1({
|
|
52
|
+
if (!(result instanceof Promise)) return trace$1.run({
|
|
53
53
|
name: spanName,
|
|
54
54
|
isError: isRealError
|
|
55
|
-
}, () => {
|
|
56
|
-
const ctx = getActiveTraceContext();
|
|
55
|
+
}, (ctx) => {
|
|
57
56
|
ctx.setAttributes({
|
|
58
57
|
[SPAN_ATTRIBUTES.TANSTACK_TYPE]: "loader",
|
|
59
58
|
[SPAN_ATTRIBUTES.TANSTACK_LOADER_ROUTE_ID]: routeId,
|
|
@@ -71,12 +70,11 @@ function traceLoader(loaderFn, config = {}) {
|
|
|
71
70
|
}
|
|
72
71
|
ctx.setStatus({ code: SpanStatusCode.OK });
|
|
73
72
|
return result;
|
|
74
|
-
})
|
|
75
|
-
return trace$1({
|
|
73
|
+
});
|
|
74
|
+
return trace$1.run({
|
|
76
75
|
name: spanName,
|
|
77
76
|
isError: isRealError
|
|
78
|
-
}, async () => {
|
|
79
|
-
const ctx = getActiveTraceContext();
|
|
77
|
+
}, async (ctx) => {
|
|
80
78
|
ctx.setAttributes({
|
|
81
79
|
[SPAN_ATTRIBUTES.TANSTACK_TYPE]: "loader",
|
|
82
80
|
[SPAN_ATTRIBUTES.TANSTACK_LOADER_ROUTE_ID]: routeId,
|
|
@@ -105,7 +103,7 @@ function traceLoader(loaderFn, config = {}) {
|
|
|
105
103
|
else if ("recordException" in ctx && typeof ctx.recordException === "function") ctx.recordException(error);
|
|
106
104
|
throw error;
|
|
107
105
|
}
|
|
108
|
-
})
|
|
106
|
+
});
|
|
109
107
|
};
|
|
110
108
|
return wrapped;
|
|
111
109
|
}
|
|
@@ -150,11 +148,10 @@ function traceBeforeLoad(beforeLoadFn, config = {}) {
|
|
|
150
148
|
const routeId = input?.route?.id || "unknown";
|
|
151
149
|
const spanName = config.name || `tanstack.beforeLoad.${routeId}`;
|
|
152
150
|
const result = beforeLoadFn(input);
|
|
153
|
-
if (!(result instanceof Promise)) return trace$1({
|
|
151
|
+
if (!(result instanceof Promise)) return trace$1.run({
|
|
154
152
|
name: spanName,
|
|
155
153
|
isError: isRealError
|
|
156
|
-
}, () => {
|
|
157
|
-
const ctx = getActiveTraceContext();
|
|
154
|
+
}, (ctx) => {
|
|
158
155
|
ctx.setAttributes({
|
|
159
156
|
[SPAN_ATTRIBUTES.TANSTACK_TYPE]: "beforeLoad",
|
|
160
157
|
[SPAN_ATTRIBUTES.TANSTACK_LOADER_ROUTE_ID]: routeId,
|
|
@@ -167,12 +164,11 @@ function traceBeforeLoad(beforeLoadFn, config = {}) {
|
|
|
167
164
|
}
|
|
168
165
|
ctx.setStatus({ code: SpanStatusCode.OK });
|
|
169
166
|
return result;
|
|
170
|
-
})
|
|
171
|
-
return trace$1({
|
|
167
|
+
});
|
|
168
|
+
return trace$1.run({
|
|
172
169
|
name: spanName,
|
|
173
170
|
isError: isRealError
|
|
174
|
-
}, async () => {
|
|
175
|
-
const ctx = getActiveTraceContext();
|
|
171
|
+
}, async (ctx) => {
|
|
176
172
|
ctx.setAttributes({
|
|
177
173
|
[SPAN_ATTRIBUTES.TANSTACK_TYPE]: "beforeLoad",
|
|
178
174
|
[SPAN_ATTRIBUTES.TANSTACK_LOADER_ROUTE_ID]: routeId,
|
|
@@ -195,7 +191,7 @@ function traceBeforeLoad(beforeLoadFn, config = {}) {
|
|
|
195
191
|
else if ("recordException" in ctx && typeof ctx.recordException === "function") ctx.recordException(error);
|
|
196
192
|
throw error;
|
|
197
193
|
}
|
|
198
|
-
})
|
|
194
|
+
});
|
|
199
195
|
};
|
|
200
196
|
return wrapped;
|
|
201
197
|
}
|
package/dist/middleware.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { i as SPAN_ATTRIBUTES, n as isRealError, r as DEFAULT_CONFIG, t as isControlFlowSignal } from "./control-flow-
|
|
1
|
+
import { i as SPAN_ATTRIBUTES, n as isRealError, r as DEFAULT_CONFIG, t as isControlFlowSignal } from "./control-flow-Bahm3i0B.js";
|
|
2
2
|
import { extractContextFromRequest } from "./context.js";
|
|
3
3
|
import { r as isServerSide } from "./env-BpFWNnpL.js";
|
|
4
4
|
import { t as isExcludedPath } from "./route-filter-dLg-j3jR.js";
|
|
5
5
|
import { SpanStatusCode, context } from "@opentelemetry/api";
|
|
6
|
-
import {
|
|
6
|
+
import { trace as trace$1 } from "autotel";
|
|
7
7
|
|
|
8
8
|
//#region src/middleware.ts
|
|
9
9
|
/**
|
|
@@ -91,11 +91,10 @@ function createTracingMiddleware(config) {
|
|
|
91
91
|
if (mergedConfig.type === "function") {
|
|
92
92
|
const fnName = functionId || "unknown";
|
|
93
93
|
const method = opts.method || "POST";
|
|
94
|
-
return trace$1({
|
|
94
|
+
return trace$1.run({
|
|
95
95
|
name: `tanstack.serverFn.${fnName}`,
|
|
96
96
|
isError: isRealError
|
|
97
|
-
}, async () => {
|
|
98
|
-
const ctx = getActiveTraceContext();
|
|
97
|
+
}, async (ctx) => {
|
|
99
98
|
const attrs = buildServerFnAttributes(fnName, method, data, mergedConfig);
|
|
100
99
|
ctx.setAttributes(attrs);
|
|
101
100
|
if (config?.customAttributes) {
|
|
@@ -134,7 +133,7 @@ function createTracingMiddleware(config) {
|
|
|
134
133
|
}
|
|
135
134
|
throw error;
|
|
136
135
|
}
|
|
137
|
-
})
|
|
136
|
+
});
|
|
138
137
|
}
|
|
139
138
|
if (!request) return next();
|
|
140
139
|
const url = new URL(request.url);
|
|
@@ -142,11 +141,10 @@ function createTracingMiddleware(config) {
|
|
|
142
141
|
const parentContext = extractContextFromRequest(request);
|
|
143
142
|
return context.with(parentContext, async () => {
|
|
144
143
|
const spanName = `${request.method} ${pathname || url.pathname}`;
|
|
145
|
-
return trace$1({
|
|
144
|
+
return trace$1.run({
|
|
146
145
|
name: spanName,
|
|
147
146
|
isError: isRealError
|
|
148
|
-
}, async () => {
|
|
149
|
-
const ctx = getActiveTraceContext();
|
|
147
|
+
}, async (ctx) => {
|
|
150
148
|
const attrs = buildRequestAttributes(request, mergedConfig);
|
|
151
149
|
ctx.setAttributes(attrs);
|
|
152
150
|
if (config?.customAttributes) {
|
|
@@ -190,7 +188,7 @@ function createTracingMiddleware(config) {
|
|
|
190
188
|
}
|
|
191
189
|
throw error;
|
|
192
190
|
}
|
|
193
|
-
})
|
|
191
|
+
});
|
|
194
192
|
});
|
|
195
193
|
};
|
|
196
194
|
}
|
package/dist/server-functions.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { i as SPAN_ATTRIBUTES, n as isRealError, t as isControlFlowSignal } from "./control-flow-
|
|
1
|
+
import { i as SPAN_ATTRIBUTES, n as isRealError, t as isControlFlowSignal } from "./control-flow-Bahm3i0B.js";
|
|
2
2
|
import { r as isServerSide } from "./env-BpFWNnpL.js";
|
|
3
3
|
import { SpanStatusCode } from "@opentelemetry/api";
|
|
4
|
-
import {
|
|
4
|
+
import { trace as trace$1 } from "autotel";
|
|
5
5
|
|
|
6
6
|
//#region src/server-functions.ts
|
|
7
7
|
/**
|
|
@@ -51,11 +51,10 @@ function traceServerFn(serverFn, config = {}) {
|
|
|
51
51
|
return new Proxy(serverFn, {
|
|
52
52
|
apply(target, thisArg, argArray) {
|
|
53
53
|
if (!isServerSide()) return target.apply(thisArg, argArray);
|
|
54
|
-
return trace$1({
|
|
54
|
+
return trace$1.run({
|
|
55
55
|
name: `tanstack.serverFn.${fnName}`,
|
|
56
56
|
isError: isRealError
|
|
57
|
-
}, async () => {
|
|
58
|
-
const ctx = getActiveTraceContext();
|
|
57
|
+
}, async (ctx) => {
|
|
59
58
|
ctx.setAttributes({
|
|
60
59
|
[SPAN_ATTRIBUTES.RPC_SYSTEM]: "tanstack-start",
|
|
61
60
|
[SPAN_ATTRIBUTES.RPC_METHOD]: fnName,
|
|
@@ -88,7 +87,7 @@ function traceServerFn(serverFn, config = {}) {
|
|
|
88
87
|
else if ("recordException" in ctx && typeof ctx.recordException === "function") ctx.recordException(error);
|
|
89
88
|
throw error;
|
|
90
89
|
}
|
|
91
|
-
})
|
|
90
|
+
});
|
|
92
91
|
},
|
|
93
92
|
get(target, prop, receiver) {
|
|
94
93
|
return Reflect.get(target, prop, receiver);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "autotel-tanstack",
|
|
3
|
-
"version": "1.13.
|
|
3
|
+
"version": "1.13.53",
|
|
4
4
|
"description": "OpenTelemetry instrumentation for TanStack Start - automatic tracing for server functions, middleware, and route loaders",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -118,9 +118,9 @@
|
|
|
118
118
|
"license": "Apache-2.0",
|
|
119
119
|
"dependencies": {
|
|
120
120
|
"@opentelemetry/api": "^1.9.1",
|
|
121
|
-
"autotel": "
|
|
122
|
-
"autotel-adapters": "2.0.
|
|
123
|
-
"autotel-edge": "
|
|
121
|
+
"autotel": "7.0.0",
|
|
122
|
+
"autotel-adapters": "2.0.9",
|
|
123
|
+
"autotel-edge": "5.0.0"
|
|
124
124
|
},
|
|
125
125
|
"peerDependencies": {
|
|
126
126
|
"@tanstack/react-start": "^1.168.32",
|