autotel-playwright 0.4.34 → 0.4.36
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.cjs +266 -208
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +27 -29
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.ts +27 -29
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +240 -193
- package/dist/index.js.map +1 -1
- package/dist/reporter.cjs +63 -68
- package/dist/reporter.cjs.map +1 -1
- package/dist/reporter.d.cts +12 -27
- package/dist/reporter.d.cts.map +1 -0
- package/dist/reporter.d.ts +12 -27
- package/dist/reporter.d.ts.map +1 -0
- package/dist/reporter.js +58 -63
- package/dist/reporter.js.map +1 -1
- package/package.json +6 -5
package/dist/index.cjs
CHANGED
|
@@ -1,238 +1,296 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
let _playwright_test = require("@playwright/test");
|
|
3
|
+
let autotel = require("autotel");
|
|
4
|
+
let autotel_test_span_collector = require("autotel/test-span-collector");
|
|
5
|
+
let autotel_processors = require("autotel/processors");
|
|
6
|
+
//#region src/index.ts
|
|
7
|
+
/**
|
|
8
|
+
* autotel-playwright
|
|
9
|
+
*
|
|
10
|
+
* Playwright fixture that creates one OTel span per test and injects W3C trace
|
|
11
|
+
* context into requests to your API so "test → API" appears as one trace.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* // globalSetup.ts: init({ service: 'e2e-tests' });
|
|
15
|
+
* // In spec:
|
|
16
|
+
* import { test, expect } from 'autotel-playwright';
|
|
17
|
+
* test('checks health', async ({ page }) => {
|
|
18
|
+
* await page.goto(API_BASE_URL + '/health'); // request gets traceparent
|
|
19
|
+
* });
|
|
20
|
+
* // Node-side API calls with trace context:
|
|
21
|
+
* test('api health', async ({ requestWithTrace }) => {
|
|
22
|
+
* const res = await requestWithTrace.get(API_BASE_URL + '/health');
|
|
23
|
+
* expect(res.ok()).toBeTruthy();
|
|
24
|
+
* });
|
|
25
|
+
*/
|
|
26
|
+
const TRACER_NAME = "playwright-tests";
|
|
27
|
+
const TRACER_VERSION = "0.1.0";
|
|
28
|
+
let collector = null;
|
|
12
29
|
function ensureCollector() {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
);
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
return collector;
|
|
30
|
+
if (!collector) {
|
|
31
|
+
collector = new autotel_test_span_collector.TestSpanCollector();
|
|
32
|
+
const provider = (0, autotel.getAutotelTracerProvider)();
|
|
33
|
+
if ("addSpanProcessor" in provider) provider.addSpanProcessor(new autotel_processors.SimpleSpanProcessor(collector));
|
|
34
|
+
}
|
|
35
|
+
return collector;
|
|
23
36
|
}
|
|
24
|
-
|
|
25
|
-
|
|
37
|
+
/** Env keys for API base URL (requests to this origin get trace context injected). */
|
|
38
|
+
const ENV_API_BASE_URL = "API_BASE_URL";
|
|
39
|
+
const ENV_API_ORIGIN = "AUTOTEL_PLAYWRIGHT_API_ORIGIN";
|
|
26
40
|
function getApiBaseUrls() {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
41
|
+
const a = process.env[ENV_API_BASE_URL];
|
|
42
|
+
const b = process.env[ENV_API_ORIGIN];
|
|
43
|
+
const urls = [];
|
|
44
|
+
if (a) urls.push(a.replace(/\/$/, ""));
|
|
45
|
+
if (b) urls.push(b.replace(/\/$/, ""));
|
|
46
|
+
return [...new Set(urls)];
|
|
33
47
|
}
|
|
48
|
+
/**
|
|
49
|
+
* Returns true if requestUrl should receive trace headers for the given apiBaseUrls.
|
|
50
|
+
* When a base URL includes a path (e.g. http://localhost:3000/api), only requests
|
|
51
|
+
* whose path starts with that path segment match; same-origin but different path
|
|
52
|
+
* (e.g. /health) must not match to avoid leaking trace context to unrelated endpoints.
|
|
53
|
+
*/
|
|
34
54
|
function urlMatchesApiOrigin(requestUrl, apiBaseUrls) {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
55
|
+
if (apiBaseUrls.length === 0) return false;
|
|
56
|
+
try {
|
|
57
|
+
const u = new URL(requestUrl);
|
|
58
|
+
const requestOrigin = u.origin;
|
|
59
|
+
const requestPathname = u.pathname;
|
|
60
|
+
return apiBaseUrls.some((base) => {
|
|
61
|
+
try {
|
|
62
|
+
const b = new URL(base);
|
|
63
|
+
if (requestOrigin !== b.origin) return false;
|
|
64
|
+
const basePathname = b.pathname.replace(/\/$/, "") || "/";
|
|
65
|
+
if (basePathname === "/") return true;
|
|
66
|
+
return requestPathname === basePathname || requestPathname.startsWith(basePathname + "/");
|
|
67
|
+
} catch {
|
|
68
|
+
return requestUrl.startsWith(base);
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
} catch {
|
|
72
|
+
return apiBaseUrls.some((base) => requestUrl.startsWith(base));
|
|
73
|
+
}
|
|
54
74
|
}
|
|
55
|
-
|
|
75
|
+
/** Annotation type for custom span attributes: description should be "key=value" or "key=value1;key2=value2". */
|
|
76
|
+
const AUTOTEL_ATTRIBUTE_ANNOTATION = "autotel.attribute";
|
|
56
77
|
function setAttributesFromAnnotations(span, testInfo) {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
78
|
+
for (const a of testInfo.annotations) {
|
|
79
|
+
if (a.type !== "autotel.attribute" || !a.description) continue;
|
|
80
|
+
const entries = a.description.split(";");
|
|
81
|
+
for (const entry of entries) {
|
|
82
|
+
const parts = entry.split("=");
|
|
83
|
+
if (parts.length >= 2) {
|
|
84
|
+
const key = parts[0].trim();
|
|
85
|
+
const value = parts.slice(1).join("=").trim();
|
|
86
|
+
span.setAttribute(key, value);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
69
90
|
}
|
|
70
91
|
function mergeTraceHeaders(url, options, apiBaseUrls, carrier, testName) {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
92
|
+
const opts = options ?? {};
|
|
93
|
+
if (!urlMatchesApiOrigin(url, apiBaseUrls)) return opts;
|
|
94
|
+
return {
|
|
95
|
+
...opts,
|
|
96
|
+
headers: {
|
|
97
|
+
...opts.headers,
|
|
98
|
+
...carrier,
|
|
99
|
+
"x-test-name": testName
|
|
100
|
+
}
|
|
101
|
+
};
|
|
77
102
|
}
|
|
103
|
+
/** Wraps APIRequestContext so requests to API_BASE_URL get trace context injected. */
|
|
78
104
|
function createRequestWithTrace(request, apiBaseUrls, carrier, testInfo) {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
105
|
+
const merge = (url, options) => mergeTraceHeaders(url, options, apiBaseUrls, carrier, testInfo.title);
|
|
106
|
+
return {
|
|
107
|
+
get: (url, options) => request.get(url, merge(url, options)),
|
|
108
|
+
post: (url, options) => request.post(url, merge(url, options)),
|
|
109
|
+
put: (url, options) => request.put(url, merge(url, options)),
|
|
110
|
+
patch: (url, options) => request.patch(url, merge(url, options)),
|
|
111
|
+
delete: (url, options) => request.delete(url, merge(url, options)),
|
|
112
|
+
head: (url, options) => request.head(url, merge(url, options)),
|
|
113
|
+
fetch: (urlOrRequest, options) => request.fetch(urlOrRequest, merge(typeof urlOrRequest === "string" ? urlOrRequest : urlOrRequest.url(), options)),
|
|
114
|
+
storageState: (options) => request.storageState(options),
|
|
115
|
+
dispose: () => request.dispose()
|
|
116
|
+
};
|
|
91
117
|
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
}
|
|
153
|
-
await use(page);
|
|
154
|
-
},
|
|
155
|
-
requestWithTrace: async ({ request, _otelTestSpan }, use) => {
|
|
156
|
-
const wrapped = createRequestWithTrace(
|
|
157
|
-
request,
|
|
158
|
-
_otelTestSpan.apiBaseUrls,
|
|
159
|
-
_otelTestSpan.carrier,
|
|
160
|
-
_otelTestSpan.testInfo
|
|
161
|
-
);
|
|
162
|
-
await use(wrapped);
|
|
163
|
-
}
|
|
118
|
+
const test = _playwright_test.test.extend({
|
|
119
|
+
_otelTestSpan: [async ({}, use, testInfo) => {
|
|
120
|
+
ensureCollector();
|
|
121
|
+
const apiBaseUrls = getApiBaseUrls();
|
|
122
|
+
const tracer = (0, autotel.getTracer)(TRACER_NAME, TRACER_VERSION);
|
|
123
|
+
const spanName = `e2e:${testInfo.title}`;
|
|
124
|
+
const span = tracer.startSpan(spanName, { attributes: {
|
|
125
|
+
"test.title": testInfo.title,
|
|
126
|
+
"test.project": testInfo.project.name,
|
|
127
|
+
"test.file": testInfo.file ?? "",
|
|
128
|
+
"test.line": testInfo.line ?? 0
|
|
129
|
+
} });
|
|
130
|
+
setAttributesFromAnnotations(span, testInfo);
|
|
131
|
+
const ctx = autotel.otelTrace.setSpan(autotel.context.active(), span);
|
|
132
|
+
const carrier = {};
|
|
133
|
+
autotel.context.with(ctx, () => {
|
|
134
|
+
autotel.propagation.inject(autotel.context.active(), carrier);
|
|
135
|
+
});
|
|
136
|
+
try {
|
|
137
|
+
await autotel.context.with(ctx, () => use({
|
|
138
|
+
carrier,
|
|
139
|
+
apiBaseUrls,
|
|
140
|
+
testInfo
|
|
141
|
+
}));
|
|
142
|
+
} catch (error) {
|
|
143
|
+
span.setStatus({
|
|
144
|
+
code: autotel.SpanStatusCode.ERROR,
|
|
145
|
+
message: error instanceof Error ? error.message : "Unknown error"
|
|
146
|
+
});
|
|
147
|
+
span.recordException(error instanceof Error ? error : new Error(String(error)));
|
|
148
|
+
throw error;
|
|
149
|
+
} finally {
|
|
150
|
+
span.end();
|
|
151
|
+
const traceId = span.spanContext().traceId;
|
|
152
|
+
const rootSpanId = span.spanContext().spanId;
|
|
153
|
+
const spans = collector.drainTrace(traceId, rootSpanId);
|
|
154
|
+
if (spans.length > 0) testInfo.annotations.push({
|
|
155
|
+
type: "otel-spans",
|
|
156
|
+
description: JSON.stringify(spans)
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
}, { scope: "test" }],
|
|
160
|
+
page: async ({ page, _otelTestSpan }, use) => {
|
|
161
|
+
const { carrier, apiBaseUrls, testInfo } = _otelTestSpan;
|
|
162
|
+
if (apiBaseUrls.length > 0) await page.route("**/*", async (route) => {
|
|
163
|
+
const request = route.request();
|
|
164
|
+
if (urlMatchesApiOrigin(request.url(), apiBaseUrls)) {
|
|
165
|
+
const headers = {
|
|
166
|
+
...request.headers(),
|
|
167
|
+
...carrier,
|
|
168
|
+
"x-test-name": testInfo.title
|
|
169
|
+
};
|
|
170
|
+
await route.continue({ headers });
|
|
171
|
+
} else await route.continue();
|
|
172
|
+
});
|
|
173
|
+
await use(page);
|
|
174
|
+
},
|
|
175
|
+
requestWithTrace: async ({ request, _otelTestSpan }, use) => {
|
|
176
|
+
await use(createRequestWithTrace(request, _otelTestSpan.apiBaseUrls, _otelTestSpan.carrier, _otelTestSpan.testInfo));
|
|
177
|
+
}
|
|
164
178
|
});
|
|
179
|
+
/**
|
|
180
|
+
* Runs a named step as a child span of the current test span. Use inside a test to get
|
|
181
|
+
* step-level spans (e.g. "step:login", "step:navigate") under the test span in the same trace.
|
|
182
|
+
*
|
|
183
|
+
* @example
|
|
184
|
+
* test('user flow', async ({ page }) => {
|
|
185
|
+
* await step('login', async () => {
|
|
186
|
+
* await page.click('button[type=submit]');
|
|
187
|
+
* });
|
|
188
|
+
* await step('open profile', async () => {
|
|
189
|
+
* await page.goto('/profile');
|
|
190
|
+
* });
|
|
191
|
+
* });
|
|
192
|
+
*/
|
|
165
193
|
async function step(name, fn) {
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
194
|
+
const span = (0, autotel.getTracer)(TRACER_NAME, TRACER_VERSION).startSpan(`step:${name}`, { attributes: { "step.name": name } });
|
|
195
|
+
try {
|
|
196
|
+
return await autotel.context.with(autotel.otelTrace.setSpan(autotel.context.active(), span), fn);
|
|
197
|
+
} catch (error) {
|
|
198
|
+
span.setStatus({
|
|
199
|
+
code: autotel.SpanStatusCode.ERROR,
|
|
200
|
+
message: error instanceof Error ? error.message : "Unknown error"
|
|
201
|
+
});
|
|
202
|
+
span.recordException(error instanceof Error ? error : new Error(String(error)));
|
|
203
|
+
throw error;
|
|
204
|
+
} finally {
|
|
205
|
+
span.end();
|
|
206
|
+
}
|
|
179
207
|
}
|
|
208
|
+
/**
|
|
209
|
+
* Returns a function suitable for Playwright globalSetup that inits autotel.
|
|
210
|
+
* Call autotel.init() with the given options (or defaults) so test spans are exported.
|
|
211
|
+
*/
|
|
180
212
|
function createGlobalSetup(initOptions) {
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
213
|
+
return async () => {
|
|
214
|
+
const { init } = await import("autotel");
|
|
215
|
+
init({
|
|
216
|
+
service: "e2e-tests",
|
|
217
|
+
debug: true,
|
|
218
|
+
...initOptions
|
|
219
|
+
});
|
|
220
|
+
};
|
|
189
221
|
}
|
|
222
|
+
/**
|
|
223
|
+
* Creates a typed client for the test-spans HTTP endpoint.
|
|
224
|
+
*
|
|
225
|
+
* Pairs with `createTestSpansHandlers()` from `autotel-tanstack/testing`.
|
|
226
|
+
*
|
|
227
|
+
* @param baseUrl - Base URL of the app under test (e.g. 'http://localhost:3100')
|
|
228
|
+
* @param options.path - Path of the test-spans endpoint (default: '/api/test-spans')
|
|
229
|
+
*
|
|
230
|
+
* @example
|
|
231
|
+
* ```typescript
|
|
232
|
+
* const spansClient = createTestSpansClient('http://localhost:3100');
|
|
233
|
+
*
|
|
234
|
+
* test('server function is traced', async ({ request }) => {
|
|
235
|
+
* await spansClient.clearSpans(request);
|
|
236
|
+
* await page.goto('/');
|
|
237
|
+
* // ... trigger action ...
|
|
238
|
+
* const spans = await spansClient.getSpans(request);
|
|
239
|
+
* expect(spans.find(s => s.name === 'sendMoney.handler')).toBeDefined();
|
|
240
|
+
* });
|
|
241
|
+
* ```
|
|
242
|
+
*/
|
|
190
243
|
function createTestSpansClient(baseUrl, options) {
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
if (!res.ok()) {
|
|
206
|
-
throw new Error(`DELETE ${path} failed: ${res.status()}`);
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
};
|
|
244
|
+
const base = baseUrl.replace(/\/$/, "");
|
|
245
|
+
const path = options?.path ?? "/api/test-spans";
|
|
246
|
+
const url = `${base}${path}`;
|
|
247
|
+
return {
|
|
248
|
+
async getSpans(request) {
|
|
249
|
+
const res = await request.get(url);
|
|
250
|
+
if (!res.ok()) throw new Error(`GET ${path} failed: ${res.status()}`);
|
|
251
|
+
return (await res.json()).spans;
|
|
252
|
+
},
|
|
253
|
+
async clearSpans(request) {
|
|
254
|
+
const res = await request.delete(url);
|
|
255
|
+
if (!res.ok()) throw new Error(`DELETE ${path} failed: ${res.status()}`);
|
|
256
|
+
}
|
|
257
|
+
};
|
|
210
258
|
}
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
});
|
|
259
|
+
//#endregion
|
|
260
|
+
exports.AUTOTEL_ATTRIBUTE_ANNOTATION = AUTOTEL_ATTRIBUTE_ANNOTATION;
|
|
261
|
+
exports.createGlobalSetup = createGlobalSetup;
|
|
262
|
+
exports.createTestSpansClient = createTestSpansClient;
|
|
216
263
|
Object.defineProperty(exports, "enrichWithTraceContext", {
|
|
217
|
-
|
|
218
|
-
|
|
264
|
+
enumerable: true,
|
|
265
|
+
get: function() {
|
|
266
|
+
return autotel.enrichWithTraceContext;
|
|
267
|
+
}
|
|
268
|
+
});
|
|
269
|
+
Object.defineProperty(exports, "expect", {
|
|
270
|
+
enumerable: true,
|
|
271
|
+
get: function() {
|
|
272
|
+
return _playwright_test.expect;
|
|
273
|
+
}
|
|
219
274
|
});
|
|
220
275
|
Object.defineProperty(exports, "getTraceContext", {
|
|
221
|
-
|
|
222
|
-
|
|
276
|
+
enumerable: true,
|
|
277
|
+
get: function() {
|
|
278
|
+
return autotel.getTraceContext;
|
|
279
|
+
}
|
|
223
280
|
});
|
|
224
281
|
Object.defineProperty(exports, "isTracing", {
|
|
225
|
-
|
|
226
|
-
|
|
282
|
+
enumerable: true,
|
|
283
|
+
get: function() {
|
|
284
|
+
return autotel.isTracing;
|
|
285
|
+
}
|
|
227
286
|
});
|
|
228
287
|
Object.defineProperty(exports, "resolveTraceUrl", {
|
|
229
|
-
|
|
230
|
-
|
|
288
|
+
enumerable: true,
|
|
289
|
+
get: function() {
|
|
290
|
+
return autotel.resolveTraceUrl;
|
|
291
|
+
}
|
|
231
292
|
});
|
|
232
|
-
exports.AUTOTEL_ATTRIBUTE_ANNOTATION = AUTOTEL_ATTRIBUTE_ANNOTATION;
|
|
233
|
-
exports.createGlobalSetup = createGlobalSetup;
|
|
234
|
-
exports.createTestSpansClient = createTestSpansClient;
|
|
235
293
|
exports.step = step;
|
|
236
294
|
exports.test = test;
|
|
237
|
-
|
|
295
|
+
|
|
238
296
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"names":["TestSpanCollector","getAutotelTracerProvider","SimpleSpanProcessor","base","getTracer","otelTrace","otelContext","propagation","SpanStatusCode"],"mappings":";;;;;;;;AAmCA,IAAM,WAAA,GAAc,kBAAA;AACpB,IAAM,cAAA,GAAiB,OAAA;AAEvB,IAAI,SAAA,GAAsC,IAAA;AAM1C,SAAS,eAAA,GAAqC;AAC5C,EAAA,IAAI,CAAC,SAAA,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,CAAQ,GAAA,CAAI,GAAG,CAAA;AACjC,MAAA,IAAI,CAAC,GAAA,CAAI,EAAA,EAAG,EAAG;AACb,QAAA,MAAM,IAAI,MAAM,CAAA,IAAA,EAAO,IAAI,YAAY,GAAA,CAAI,MAAA,EAAQ,CAAA,CAAE,CAAA;AAAA,MACvD;AACA,MAAA,MAAM,IAAA,GAAO,MAAM,GAAA,CAAI,IAAA,EAAK;AAC5B,MAAA,OAAO,IAAA,CAAK,KAAA;AAAA,IACd,CAAA;AAAA,IAEA,MAAM,WAAW,OAAA,EAA2C;AAC1D,MAAA,MAAM,GAAA,GAAM,MAAM,OAAA,CAAQ,MAAA,CAAO,GAAG,CAAA;AACpC,MAAA,IAAI,CAAC,GAAA,CAAI,EAAA,EAAG,EAAG;AACb,QAAA,MAAM,IAAI,MAAM,CAAA,OAAA,EAAU,IAAI,YAAY,GAAA,CAAI,MAAA,EAAQ,CAAA,CAAE,CAAA;AAAA,MAC1D;AAAA,IACF;AAAA,GACF;AACF","file":"index.cjs","sourcesContent":["/**\n * autotel-playwright\n *\n * Playwright fixture that creates one OTel span per test and injects W3C trace\n * context into requests to your API so \"test → API\" appears as one trace.\n *\n * @example\n * // globalSetup.ts: init({ service: 'e2e-tests' });\n * // In spec:\n * import { test, expect } from 'autotel-playwright';\n * test('checks health', async ({ page }) => {\n * await page.goto(API_BASE_URL + '/health'); // request gets traceparent\n * });\n * // Node-side API calls with trace context:\n * test('api health', async ({ requestWithTrace }) => {\n * const res = await requestWithTrace.get(API_BASE_URL + '/health');\n * expect(res.ok()).toBeTruthy();\n * });\n */\n\nimport { test as base } from '@playwright/test';\nimport type { Page, APIRequestContext, Request as PlaywrightRequest } from '@playwright/test';\nimport type { TestInfo } from '@playwright/test';\nimport type { AutotelConfig } from 'autotel';\nimport {\n getTracer,\n getAutotelTracerProvider,\n context as otelContext,\n propagation,\n otelTrace,\n SpanStatusCode,\n} from 'autotel';\nimport { TestSpanCollector } from 'autotel/test-span-collector';\nimport { SimpleSpanProcessor } from 'autotel/processors';\n\nconst TRACER_NAME = 'playwright-tests';\nconst TRACER_VERSION = '0.1.0';\n\nlet collector: TestSpanCollector | null = null;\n\ninterface TracerProviderWithProcessor {\n addSpanProcessor(processor: unknown): void;\n}\n\nfunction ensureCollector(): TestSpanCollector {\n if (!collector) {\n collector = new TestSpanCollector();\n const provider = getAutotelTracerProvider();\n if ('addSpanProcessor' in provider) {\n (provider as TracerProviderWithProcessor).addSpanProcessor(\n new SimpleSpanProcessor(collector),\n );\n }\n }\n return collector;\n}\n\n/** Env keys for API base URL (requests to this origin get trace context injected). */\nconst ENV_API_BASE_URL = 'API_BASE_URL';\nconst ENV_API_ORIGIN = 'AUTOTEL_PLAYWRIGHT_API_ORIGIN';\n\nfunction getApiBaseUrls(): string[] {\n const a = process.env[ENV_API_BASE_URL];\n const b = process.env[ENV_API_ORIGIN];\n const urls: string[] = [];\n if (a) urls.push(a.replace(/\\/$/, ''));\n if (b) urls.push(b.replace(/\\/$/, ''));\n return [...new Set(urls)];\n}\n\n/**\n * Returns true if requestUrl should receive trace headers for the given apiBaseUrls.\n * When a base URL includes a path (e.g. http://localhost:3000/api), only requests\n * whose path starts with that path segment match; same-origin but different path\n * (e.g. /health) must not match to avoid leaking trace context to unrelated endpoints.\n */\nfunction urlMatchesApiOrigin(requestUrl: string, apiBaseUrls: string[]): boolean {\n if (apiBaseUrls.length === 0) return false;\n try {\n const u = new URL(requestUrl);\n const requestOrigin = u.origin;\n const requestPathname = u.pathname;\n return apiBaseUrls.some((base) => {\n try {\n const b = new URL(base);\n if (requestOrigin !== b.origin) return false;\n const basePathname = b.pathname.replace(/\\/$/, '') || '/';\n if (basePathname === '/') return true;\n return (\n requestPathname === basePathname || requestPathname.startsWith(basePathname + '/')\n );\n } catch {\n return requestUrl.startsWith(base);\n }\n });\n } catch {\n return apiBaseUrls.some((base) => requestUrl.startsWith(base));\n }\n}\n\n/** Annotation type for custom span attributes: description should be \"key=value\" or \"key=value1;key2=value2\". */\nexport const AUTOTEL_ATTRIBUTE_ANNOTATION = 'autotel.attribute';\n\nfunction setAttributesFromAnnotations(\n span: { setAttribute: (k: string, v: string | number | boolean) => void },\n testInfo: { annotations: Array<{ type: string; description?: string }> },\n): void {\n for (const a of testInfo.annotations) {\n if (a.type !== AUTOTEL_ATTRIBUTE_ANNOTATION || !a.description) continue;\n const entries = a.description.split(';');\n for (const entry of entries) {\n const parts = entry.split('=');\n if (parts.length >= 2) {\n const key = parts[0].trim();\n const value = parts.slice(1).join('=').trim();\n span.setAttribute(key, value);\n }\n }\n }\n}\n\n/** Internal: options for get/post/put/patch/delete/head/fetch that may include headers. */\ntype RequestOptions = Record<string, unknown> & { headers?: Record<string, string> };\n\nfunction mergeTraceHeaders(\n url: string,\n options: RequestOptions | undefined,\n apiBaseUrls: string[],\n carrier: Record<string, string>,\n testName: string,\n): RequestOptions {\n const opts = options ?? {};\n if (!urlMatchesApiOrigin(url, apiBaseUrls)) return opts;\n return {\n ...opts,\n headers: { ...(opts.headers as Record<string, string>), ...carrier, 'x-test-name': testName },\n };\n}\n\n/** Wraps APIRequestContext so requests to API_BASE_URL get trace context injected. */\nfunction createRequestWithTrace(\n request: APIRequestContext,\n apiBaseUrls: string[],\n carrier: Record<string, string>,\n testInfo: TestInfo,\n): APIRequestContext {\n const merge = (url: string, options?: RequestOptions) =>\n mergeTraceHeaders(url, options, apiBaseUrls, carrier, testInfo.title);\n\n return {\n get: (url: string, options?: RequestOptions) => request.get(url, merge(url, options)),\n post: (url: string, options?: RequestOptions) => request.post(url, merge(url, options)),\n put: (url: string, options?: RequestOptions) => request.put(url, merge(url, options)),\n patch: (url: string, options?: RequestOptions) => request.patch(url, merge(url, options)),\n delete: (url: string, options?: RequestOptions) => request.delete(url, merge(url, options)),\n head: (url: string, options?: RequestOptions) => request.head(url, merge(url, options)),\n fetch: (urlOrRequest: string | PlaywrightRequest, options?: RequestOptions) =>\n request.fetch(urlOrRequest, merge(typeof urlOrRequest === 'string' ? urlOrRequest : urlOrRequest.url(), options)),\n storageState: (options?: { path?: string }) => request.storageState(options),\n dispose: () => request.dispose(),\n } as APIRequestContext;\n}\n\ntype OtelTestSpan = {\n carrier: Record<string, string>;\n apiBaseUrls: string[];\n testInfo: TestInfo;\n};\n\nexport const test = base.extend<{\n page: Page;\n requestWithTrace: APIRequestContext;\n _otelTestSpan: OtelTestSpan;\n}>({\n _otelTestSpan: [\n // eslint-disable-next-line no-empty-pattern\n async ({}, use, testInfo) => {\n ensureCollector();\n const apiBaseUrls = getApiBaseUrls();\n const tracer = getTracer(TRACER_NAME, TRACER_VERSION);\n const spanName = `e2e:${testInfo.title}`;\n const span = tracer.startSpan(spanName, {\n attributes: {\n 'test.title': testInfo.title,\n 'test.project': testInfo.project.name,\n 'test.file': testInfo.file ?? '',\n 'test.line': testInfo.line ?? 0,\n },\n });\n setAttributesFromAnnotations(span, testInfo);\n const ctx = otelTrace.setSpan(otelContext.active(), span);\n const carrier: Record<string, string> = {};\n otelContext.with(ctx, () => {\n propagation.inject(otelContext.active(), carrier);\n });\n try {\n await otelContext.with(ctx, () => use({ carrier, apiBaseUrls, testInfo }));\n } catch (error) {\n span.setStatus({ code: SpanStatusCode.ERROR, message: error instanceof Error ? error.message : 'Unknown error' });\n span.recordException(error instanceof Error ? error : new Error(String(error)));\n throw error;\n } finally {\n span.end();\n const traceId = span.spanContext().traceId;\n const rootSpanId = span.spanContext().spanId;\n const spans = collector!.drainTrace(traceId, rootSpanId);\n if (spans.length > 0) {\n testInfo.annotations.push({\n type: 'otel-spans',\n description: JSON.stringify(spans),\n });\n }\n }\n },\n { scope: 'test' },\n ],\n\n page: async ({ page, _otelTestSpan }, use) => {\n const { carrier, apiBaseUrls, testInfo } = _otelTestSpan;\n if (apiBaseUrls.length > 0) {\n await page.route('**/*', async (route) => {\n const request = route.request();\n const url = request.url();\n if (urlMatchesApiOrigin(url, apiBaseUrls)) {\n const headers = {\n ...request.headers(),\n ...carrier,\n 'x-test-name': testInfo.title,\n };\n await route.continue({ headers });\n } else {\n await route.continue();\n }\n });\n }\n await use(page);\n },\n\n requestWithTrace: async ({ request, _otelTestSpan }, use) => {\n const wrapped = createRequestWithTrace(\n request,\n _otelTestSpan.apiBaseUrls,\n _otelTestSpan.carrier,\n _otelTestSpan.testInfo,\n );\n await use(wrapped);\n },\n});\n\nexport { expect } from '@playwright/test';\n\n// Re-export trace context helpers for DX convenience\nexport {\n getTraceContext,\n resolveTraceUrl,\n isTracing,\n enrichWithTraceContext,\n} from 'autotel';\n\nexport type { OtelTraceContext } from 'autotel';\n\n/**\n * Runs a named step as a child span of the current test span. Use inside a test to get\n * step-level spans (e.g. \"step:login\", \"step:navigate\") under the test span in the same trace.\n *\n * @example\n * test('user flow', async ({ page }) => {\n * await step('login', async () => {\n * await page.click('button[type=submit]');\n * });\n * await step('open profile', async () => {\n * await page.goto('/profile');\n * });\n * });\n */\nexport async function step<T>(name: string, fn: () => Promise<T>): Promise<T> {\n const tracer = getTracer(TRACER_NAME, TRACER_VERSION);\n const span = tracer.startSpan(`step:${name}`, {\n attributes: { 'step.name': name },\n });\n try {\n return await otelContext.with(otelTrace.setSpan(otelContext.active(), span), fn);\n } catch (error) {\n span.setStatus({ code: SpanStatusCode.ERROR, message: error instanceof Error ? error.message : 'Unknown error' });\n span.recordException(error instanceof Error ? error : new Error(String(error)));\n throw error;\n } finally {\n span.end();\n }\n}\n\n/**\n * Returns a function suitable for Playwright globalSetup that inits autotel.\n * Call autotel.init() with the given options (or defaults) so test spans are exported.\n */\nexport function createGlobalSetup(initOptions?: AutotelConfig): () => Promise<void> {\n return async () => {\n const { init } = await import('autotel');\n init({\n service: 'e2e-tests',\n debug: true,\n ...initOptions,\n });\n };\n}\n\n/**\n * Serialized span returned by the test-spans endpoint (matches autotel-tanstack/testing SerializedSpan).\n */\nexport interface SerializedSpan {\n name: string;\n spanId: string;\n traceId: string;\n parentSpanId?: string;\n attributes?: Record<string, unknown>;\n status: { code: number; message?: string };\n durationMs: number;\n}\n\n/**\n * Creates a typed client for the test-spans HTTP endpoint.\n *\n * Pairs with `createTestSpansHandlers()` from `autotel-tanstack/testing`.\n *\n * @param baseUrl - Base URL of the app under test (e.g. 'http://localhost:3100')\n * @param options.path - Path of the test-spans endpoint (default: '/api/test-spans')\n *\n * @example\n * ```typescript\n * const spansClient = createTestSpansClient('http://localhost:3100');\n *\n * test('server function is traced', async ({ request }) => {\n * await spansClient.clearSpans(request);\n * await page.goto('/');\n * // ... trigger action ...\n * const spans = await spansClient.getSpans(request);\n * expect(spans.find(s => s.name === 'sendMoney.handler')).toBeDefined();\n * });\n * ```\n */\nexport function createTestSpansClient(\n baseUrl: string,\n options?: { path?: string },\n): {\n getSpans(request: APIRequestContext): Promise<SerializedSpan[]>;\n clearSpans(request: APIRequestContext): Promise<void>;\n} {\n const base = baseUrl.replace(/\\/$/, '');\n const path = options?.path ?? '/api/test-spans';\n const url = `${base}${path}`;\n\n return {\n async getSpans(request: APIRequestContext): Promise<SerializedSpan[]> {\n const res = await request.get(url);\n if (!res.ok()) {\n throw new Error(`GET ${path} failed: ${res.status()}`);\n }\n const body = await res.json() as { spans: SerializedSpan[] };\n return body.spans;\n },\n\n async clearSpans(request: APIRequestContext): Promise<void> {\n const res = await request.delete(url);\n if (!res.ok()) {\n throw new Error(`DELETE ${path} failed: ${res.status()}`);\n }\n },\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["TestSpanCollector","SimpleSpanProcessor","base","otelTrace","otelContext","SpanStatusCode"],"sources":["../src/index.ts"],"sourcesContent":["/**\n * autotel-playwright\n *\n * Playwright fixture that creates one OTel span per test and injects W3C trace\n * context into requests to your API so \"test → API\" appears as one trace.\n *\n * @example\n * // globalSetup.ts: init({ service: 'e2e-tests' });\n * // In spec:\n * import { test, expect } from 'autotel-playwright';\n * test('checks health', async ({ page }) => {\n * await page.goto(API_BASE_URL + '/health'); // request gets traceparent\n * });\n * // Node-side API calls with trace context:\n * test('api health', async ({ requestWithTrace }) => {\n * const res = await requestWithTrace.get(API_BASE_URL + '/health');\n * expect(res.ok()).toBeTruthy();\n * });\n */\n\nimport { test as base } from '@playwright/test';\nimport type { Page, APIRequestContext, Request as PlaywrightRequest } from '@playwright/test';\nimport type { TestInfo } from '@playwright/test';\nimport type { AutotelConfig } from 'autotel';\nimport {\n getTracer,\n getAutotelTracerProvider,\n context as otelContext,\n propagation,\n otelTrace,\n SpanStatusCode,\n} from 'autotel';\nimport { TestSpanCollector } from 'autotel/test-span-collector';\nimport { SimpleSpanProcessor } from 'autotel/processors';\n\nconst TRACER_NAME = 'playwright-tests';\nconst TRACER_VERSION = '0.1.0';\n\nlet collector: TestSpanCollector | null = null;\n\ninterface TracerProviderWithProcessor {\n addSpanProcessor(processor: unknown): void;\n}\n\nfunction ensureCollector(): TestSpanCollector {\n if (!collector) {\n collector = new TestSpanCollector();\n const provider = getAutotelTracerProvider();\n if ('addSpanProcessor' in provider) {\n (provider as TracerProviderWithProcessor).addSpanProcessor(\n new SimpleSpanProcessor(collector),\n );\n }\n }\n return collector;\n}\n\n/** Env keys for API base URL (requests to this origin get trace context injected). */\nconst ENV_API_BASE_URL = 'API_BASE_URL';\nconst ENV_API_ORIGIN = 'AUTOTEL_PLAYWRIGHT_API_ORIGIN';\n\nfunction getApiBaseUrls(): string[] {\n const a = process.env[ENV_API_BASE_URL];\n const b = process.env[ENV_API_ORIGIN];\n const urls: string[] = [];\n if (a) urls.push(a.replace(/\\/$/, ''));\n if (b) urls.push(b.replace(/\\/$/, ''));\n return [...new Set(urls)];\n}\n\n/**\n * Returns true if requestUrl should receive trace headers for the given apiBaseUrls.\n * When a base URL includes a path (e.g. http://localhost:3000/api), only requests\n * whose path starts with that path segment match; same-origin but different path\n * (e.g. /health) must not match to avoid leaking trace context to unrelated endpoints.\n */\nfunction urlMatchesApiOrigin(requestUrl: string, apiBaseUrls: string[]): boolean {\n if (apiBaseUrls.length === 0) return false;\n try {\n const u = new URL(requestUrl);\n const requestOrigin = u.origin;\n const requestPathname = u.pathname;\n return apiBaseUrls.some((base) => {\n try {\n const b = new URL(base);\n if (requestOrigin !== b.origin) return false;\n const basePathname = b.pathname.replace(/\\/$/, '') || '/';\n if (basePathname === '/') return true;\n return (\n requestPathname === basePathname || requestPathname.startsWith(basePathname + '/')\n );\n } catch {\n return requestUrl.startsWith(base);\n }\n });\n } catch {\n return apiBaseUrls.some((base) => requestUrl.startsWith(base));\n }\n}\n\n/** Annotation type for custom span attributes: description should be \"key=value\" or \"key=value1;key2=value2\". */\nexport const AUTOTEL_ATTRIBUTE_ANNOTATION = 'autotel.attribute';\n\nfunction setAttributesFromAnnotations(\n span: { setAttribute: (k: string, v: string | number | boolean) => void },\n testInfo: { annotations: Array<{ type: string; description?: string }> },\n): void {\n for (const a of testInfo.annotations) {\n if (a.type !== AUTOTEL_ATTRIBUTE_ANNOTATION || !a.description) continue;\n const entries = a.description.split(';');\n for (const entry of entries) {\n const parts = entry.split('=');\n if (parts.length >= 2) {\n const key = parts[0].trim();\n const value = parts.slice(1).join('=').trim();\n span.setAttribute(key, value);\n }\n }\n }\n}\n\n/** Internal: options for get/post/put/patch/delete/head/fetch that may include headers. */\ntype RequestOptions = Record<string, unknown> & { headers?: Record<string, string> };\n\nfunction mergeTraceHeaders(\n url: string,\n options: RequestOptions | undefined,\n apiBaseUrls: string[],\n carrier: Record<string, string>,\n testName: string,\n): RequestOptions {\n const opts = options ?? {};\n if (!urlMatchesApiOrigin(url, apiBaseUrls)) return opts;\n return {\n ...opts,\n headers: { ...(opts.headers as Record<string, string>), ...carrier, 'x-test-name': testName },\n };\n}\n\n/** Wraps APIRequestContext so requests to API_BASE_URL get trace context injected. */\nfunction createRequestWithTrace(\n request: APIRequestContext,\n apiBaseUrls: string[],\n carrier: Record<string, string>,\n testInfo: TestInfo,\n): APIRequestContext {\n const merge = (url: string, options?: RequestOptions) =>\n mergeTraceHeaders(url, options, apiBaseUrls, carrier, testInfo.title);\n\n return {\n get: (url: string, options?: RequestOptions) => request.get(url, merge(url, options)),\n post: (url: string, options?: RequestOptions) => request.post(url, merge(url, options)),\n put: (url: string, options?: RequestOptions) => request.put(url, merge(url, options)),\n patch: (url: string, options?: RequestOptions) => request.patch(url, merge(url, options)),\n delete: (url: string, options?: RequestOptions) => request.delete(url, merge(url, options)),\n head: (url: string, options?: RequestOptions) => request.head(url, merge(url, options)),\n fetch: (urlOrRequest: string | PlaywrightRequest, options?: RequestOptions) =>\n request.fetch(urlOrRequest, merge(typeof urlOrRequest === 'string' ? urlOrRequest : urlOrRequest.url(), options)),\n storageState: (options?: { path?: string }) => request.storageState(options),\n dispose: () => request.dispose(),\n } as APIRequestContext;\n}\n\ntype OtelTestSpan = {\n carrier: Record<string, string>;\n apiBaseUrls: string[];\n testInfo: TestInfo;\n};\n\nexport const test = base.extend<{\n page: Page;\n requestWithTrace: APIRequestContext;\n _otelTestSpan: OtelTestSpan;\n}>({\n _otelTestSpan: [\n // eslint-disable-next-line no-empty-pattern\n async ({}, use, testInfo) => {\n ensureCollector();\n const apiBaseUrls = getApiBaseUrls();\n const tracer = getTracer(TRACER_NAME, TRACER_VERSION);\n const spanName = `e2e:${testInfo.title}`;\n const span = tracer.startSpan(spanName, {\n attributes: {\n 'test.title': testInfo.title,\n 'test.project': testInfo.project.name,\n 'test.file': testInfo.file ?? '',\n 'test.line': testInfo.line ?? 0,\n },\n });\n setAttributesFromAnnotations(span, testInfo);\n const ctx = otelTrace.setSpan(otelContext.active(), span);\n const carrier: Record<string, string> = {};\n otelContext.with(ctx, () => {\n propagation.inject(otelContext.active(), carrier);\n });\n try {\n await otelContext.with(ctx, () => use({ carrier, apiBaseUrls, testInfo }));\n } catch (error) {\n span.setStatus({ code: SpanStatusCode.ERROR, message: error instanceof Error ? error.message : 'Unknown error' });\n span.recordException(error instanceof Error ? error : new Error(String(error)));\n throw error;\n } finally {\n span.end();\n const traceId = span.spanContext().traceId;\n const rootSpanId = span.spanContext().spanId;\n const spans = collector!.drainTrace(traceId, rootSpanId);\n if (spans.length > 0) {\n testInfo.annotations.push({\n type: 'otel-spans',\n description: JSON.stringify(spans),\n });\n }\n }\n },\n { scope: 'test' },\n ],\n\n page: async ({ page, _otelTestSpan }, use) => {\n const { carrier, apiBaseUrls, testInfo } = _otelTestSpan;\n if (apiBaseUrls.length > 0) {\n await page.route('**/*', async (route) => {\n const request = route.request();\n const url = request.url();\n if (urlMatchesApiOrigin(url, apiBaseUrls)) {\n const headers = {\n ...request.headers(),\n ...carrier,\n 'x-test-name': testInfo.title,\n };\n await route.continue({ headers });\n } else {\n await route.continue();\n }\n });\n }\n await use(page);\n },\n\n requestWithTrace: async ({ request, _otelTestSpan }, use) => {\n const wrapped = createRequestWithTrace(\n request,\n _otelTestSpan.apiBaseUrls,\n _otelTestSpan.carrier,\n _otelTestSpan.testInfo,\n );\n await use(wrapped);\n },\n});\n\nexport { expect } from '@playwright/test';\n\n// Re-export trace context helpers for DX convenience\nexport {\n getTraceContext,\n resolveTraceUrl,\n isTracing,\n enrichWithTraceContext,\n} from 'autotel';\n\nexport type { OtelTraceContext } from 'autotel';\n\n/**\n * Runs a named step as a child span of the current test span. Use inside a test to get\n * step-level spans (e.g. \"step:login\", \"step:navigate\") under the test span in the same trace.\n *\n * @example\n * test('user flow', async ({ page }) => {\n * await step('login', async () => {\n * await page.click('button[type=submit]');\n * });\n * await step('open profile', async () => {\n * await page.goto('/profile');\n * });\n * });\n */\nexport async function step<T>(name: string, fn: () => Promise<T>): Promise<T> {\n const tracer = getTracer(TRACER_NAME, TRACER_VERSION);\n const span = tracer.startSpan(`step:${name}`, {\n attributes: { 'step.name': name },\n });\n try {\n return await otelContext.with(otelTrace.setSpan(otelContext.active(), span), fn);\n } catch (error) {\n span.setStatus({ code: SpanStatusCode.ERROR, message: error instanceof Error ? error.message : 'Unknown error' });\n span.recordException(error instanceof Error ? error : new Error(String(error)));\n throw error;\n } finally {\n span.end();\n }\n}\n\n/**\n * Returns a function suitable for Playwright globalSetup that inits autotel.\n * Call autotel.init() with the given options (or defaults) so test spans are exported.\n */\nexport function createGlobalSetup(initOptions?: AutotelConfig): () => Promise<void> {\n return async () => {\n const { init } = await import('autotel');\n init({\n service: 'e2e-tests',\n debug: true,\n ...initOptions,\n });\n };\n}\n\n/**\n * Serialized span returned by the test-spans endpoint (matches autotel-tanstack/testing SerializedSpan).\n */\nexport interface SerializedSpan {\n name: string;\n spanId: string;\n traceId: string;\n parentSpanId?: string;\n attributes?: Record<string, unknown>;\n status: { code: number; message?: string };\n durationMs: number;\n}\n\n/**\n * Creates a typed client for the test-spans HTTP endpoint.\n *\n * Pairs with `createTestSpansHandlers()` from `autotel-tanstack/testing`.\n *\n * @param baseUrl - Base URL of the app under test (e.g. 'http://localhost:3100')\n * @param options.path - Path of the test-spans endpoint (default: '/api/test-spans')\n *\n * @example\n * ```typescript\n * const spansClient = createTestSpansClient('http://localhost:3100');\n *\n * test('server function is traced', async ({ request }) => {\n * await spansClient.clearSpans(request);\n * await page.goto('/');\n * // ... trigger action ...\n * const spans = await spansClient.getSpans(request);\n * expect(spans.find(s => s.name === 'sendMoney.handler')).toBeDefined();\n * });\n * ```\n */\nexport function createTestSpansClient(\n baseUrl: string,\n options?: { path?: string },\n): {\n getSpans(request: APIRequestContext): Promise<SerializedSpan[]>;\n clearSpans(request: APIRequestContext): Promise<void>;\n} {\n const base = baseUrl.replace(/\\/$/, '');\n const path = options?.path ?? '/api/test-spans';\n const url = `${base}${path}`;\n\n return {\n async getSpans(request: APIRequestContext): Promise<SerializedSpan[]> {\n const res = await request.get(url);\n if (!res.ok()) {\n throw new Error(`GET ${path} failed: ${res.status()}`);\n }\n const body = await res.json() as { spans: SerializedSpan[] };\n return body.spans;\n },\n\n async clearSpans(request: APIRequestContext): Promise<void> {\n const res = await request.delete(url);\n if (!res.ok()) {\n throw new Error(`DELETE ${path} failed: ${res.status()}`);\n }\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAmCA,MAAM,cAAc;AACpB,MAAM,iBAAiB;AAEvB,IAAI,YAAsC;AA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