playwright-opentelemetry 0.18.1 → 0.19.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 CHANGED
@@ -19,7 +19,7 @@ Playwright test
19
19
  ```
20
20
 
21
21
  - The **reporter** turns each retained test attempt into a root `playwright.test` span, with steps, hooks, fixtures, and actions as child `playwright.test.step` spans.
22
- - The **fixture** records page navigations, browser requests, `request` fixture activity, worker `fetch` activity, console messages, and uncaught page errors under a `playwright-browser` service, and injects the `traceparent` header that makes backend spans children of the test.
22
+ - The **fixture** records page navigations, browser requests, worker `fetch` activity, console messages, and uncaught page errors under a `playwright-browser` service, adds the response of each `request`, `page.request` or other `APIRequestContext` call to the step of that call, and injects into all of those requests the `traceparent` header that makes backend spans children of the test.
23
23
 
24
24
  ## Quick start
25
25
 
package/dist/fixture.cjs CHANGED
@@ -1,16 +1,19 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_screenshots_zip = require("./screenshots-zip-Cy2Wivw7.cjs");
2
+ const require_screenshots_zip = require("./screenshots-zip-pitrmbIG.cjs");
3
3
  let node_fs_promises = require("node:fs/promises");
4
4
  node_fs_promises = require_screenshots_zip.__toESM(node_fs_promises, 1);
5
5
  let node_path = require("node:path");
6
6
  node_path = require_screenshots_zip.__toESM(node_path, 1);
7
7
  let _playwright_test = require("@playwright/test");
8
+ let node_url = require("node:url");
9
+ let node_vm = require("node:vm");
10
+ node_vm = require_screenshots_zip.__toESM(node_vm, 1);
8
11
  let node_os = require("node:os");
9
12
  node_os = require_screenshots_zip.__toESM(node_os, 1);
10
13
  //#region src/fixture/browser-page-tracker.ts
11
14
  const BROWSER_PAGE_SPAN_NAME = "browser.page";
12
15
  const BROWSER_ROUTE_SPAN_NAME = "browser.route";
13
- const SPAN_STATUS_CODE_UNSET$3 = 0;
16
+ const SPAN_STATUS_CODE_UNSET$2 = 0;
14
17
  var BrowserPageTracker = class {
15
18
  traceContext;
16
19
  nextPageId = 0;
@@ -182,7 +185,7 @@ var BrowserPageTracker = class {
182
185
  name,
183
186
  startTime,
184
187
  endTime: startTime,
185
- status: { code: SPAN_STATUS_CODE_UNSET$3 },
188
+ status: { code: SPAN_STATUS_CODE_UNSET$2 },
186
189
  attributes: pageAttributes({
187
190
  pageId,
188
191
  documentIndex,
@@ -274,18 +277,14 @@ function storeRequestTraceContext({ request, traceContext, parentSpanId, routeAs
274
277
  * @param options - The propagator options
275
278
  */
276
279
  async function propagateRouteTraceHeaders({ route, request, traceId, spanId }) {
277
- const traceHeader = `00-${traceId}-${spanId}-01`;
278
280
  await route.fallback({ headers: {
279
281
  ...request.headers(),
280
- traceparent: traceHeader
282
+ traceparent: require_screenshots_zip.traceparentHeader(traceId, spanId)
281
283
  } });
282
284
  }
283
285
  //#endregion
284
286
  //#region src/fixture/api-request-capture.ts
285
- const SPAN_KIND_CLIENT$2 = 3;
286
- const SPAN_STATUS_CODE_UNSET$2 = 0;
287
- const SPAN_STATUS_CODE_ERROR$2 = 2;
288
- const CAPTURED_METHODS = new Set([
287
+ const CAPTURED_METHODS = [
289
288
  "delete",
290
289
  "fetch",
291
290
  "get",
@@ -293,117 +292,219 @@ const CAPTURED_METHODS = new Set([
293
292
  "patch",
294
293
  "post",
295
294
  "put"
296
- ]);
297
- function createCapturedApiRequestContext(request, traceContext) {
298
- return new Proxy(request, { get(target, property, receiver) {
299
- const value = Reflect.get(target, property, receiver);
300
- if (typeof property !== "string" || !CAPTURED_METHODS.has(property)) return value;
301
- if (typeof value !== "function") return value;
302
- return async (...args) => {
303
- const startTime = /* @__PURE__ */ new Date();
304
- try {
305
- const response = await value.apply(target, args);
306
- traceContext.addSpan(createApiRequestSpan({
307
- methodName: property,
308
- args,
309
- traceContext,
310
- startTime,
311
- endTime: /* @__PURE__ */ new Date(),
312
- statusCode: response.status(),
313
- responseHeaders: response.headers()
314
- }));
315
- return response;
316
- } catch (error) {
317
- traceContext.addSpan(createApiRequestSpan({
318
- methodName: property,
319
- args,
320
- traceContext,
321
- startTime,
322
- endTime: /* @__PURE__ */ new Date(),
323
- error
324
- }));
325
- throw error;
326
- }
295
+ ];
296
+ const STATE_KEY = Symbol.for("playwright-opentelemetry.api-request-capture");
297
+ const WRAPPED = Symbol.for("playwright-opentelemetry.api-request-wrapper");
298
+ const state = globalThis[STATE_KEY] ??= { depth: 0 };
299
+ /**
300
+ * Wraps a Playwright method without changing where Playwright says the call
301
+ * came from. A step's location is the first stack frame outside Playwright,
302
+ * so a wrapper written in this file would become the location of every step
303
+ * it wraps. Playwright skips the frames of Node's own modules, and this
304
+ * wrapper is compiled with such a file name. `begin` and `end` are not on the
305
+ * stack while `original` runs.
306
+ */
307
+ const createWrapper = node_vm.default.compileFunction(`return function (...args) {
308
+ const call = begin(args);
309
+ let result;
310
+ try {
311
+ result = Reflect.apply(original, this, args);
312
+ } catch (error) {
313
+ end(call, undefined);
314
+ throw error;
315
+ }
316
+ return end(call, result);
317
+ };`, [
318
+ "original",
319
+ "begin",
320
+ "end"
321
+ ], { filename: require_screenshots_zip.API_REQUEST_WRAPPER_FILE });
322
+ /**
323
+ * Records the calls made on every `APIRequestContext` of this process, by
324
+ * wrapping the methods of the class they share. The test still gets
325
+ * Playwright's own objects. Does nothing while no recording is active.
326
+ */
327
+ function captureApiRequests(requestContext) {
328
+ try {
329
+ wrapRequestMethods(requestContext);
330
+ } catch {}
331
+ }
332
+ function wrapRequestMethods(requestContext) {
333
+ const prototype = Object.getPrototypeOf(requestContext);
334
+ if (!prototype || prototype === Object.prototype) return;
335
+ for (const methodName of CAPTURED_METHODS) {
336
+ const original = prototype[methodName];
337
+ if (typeof original !== "function" || isWrapped(original)) continue;
338
+ prototype[methodName] = markWrapped(createWrapper(original, (args) => beginCall(methodName, args), endCall));
339
+ }
340
+ }
341
+ /**
342
+ * The class of `APIRequestContext` can only be reached through an instance:
343
+ * finds it when `playwright.request.newContext()` creates the first one, which
344
+ * is also how Playwright creates the `request` fixture.
345
+ */
346
+ function captureNewApiRequestContexts(apiRequest) {
347
+ const target = apiRequest;
348
+ const original = target.newContext;
349
+ if (typeof original !== "function" || isWrapped(original)) return;
350
+ target.newContext = markWrapped(createWrapper(original, () => void 0, (_call, result) => {
351
+ if (!isPromiseLike(result)) return result;
352
+ return result.then((requestContext) => {
353
+ captureApiRequests(requestContext);
354
+ return requestContext;
355
+ });
356
+ }));
357
+ }
358
+ function startApiRequestRecording(options) {
359
+ const recording = {
360
+ ...options,
361
+ requests: []
362
+ };
363
+ const previous = state.recording;
364
+ state.recording = recording;
365
+ return { stop() {
366
+ if (state.recording === recording) state.recording = previous;
367
+ return recording.requests;
368
+ } };
369
+ }
370
+ function beginCall(methodName, args) {
371
+ state.depth++;
372
+ const recording = state.recording;
373
+ if (state.depth > 1 || !recording) return;
374
+ try {
375
+ const call = {
376
+ method: requestMethod(methodName, args),
377
+ url: requestUrl(args[0]),
378
+ startTime: (/* @__PURE__ */ new Date()).toISOString(),
379
+ location: callSite(recording.rootDir)
327
380
  };
328
- } });
381
+ if (recording.traceId) {
382
+ const spanId = require_screenshots_zip.generateSpanId();
383
+ if (addTraceparent(args, require_screenshots_zip.traceparentHeader(recording.traceId, spanId))) call.spanId = spanId;
384
+ }
385
+ recording.requests.push(call);
386
+ return call;
387
+ } catch {
388
+ return;
389
+ }
329
390
  }
330
- function createApiRequestSpan({ methodName, args, traceContext, startTime, endTime, statusCode, responseHeaders, error }) {
331
- const method = getRequestMethod(methodName, args);
332
- const attributes = createHttpAttributes$1({
333
- method,
334
- url: getRequestUrl(args[0]),
335
- statusCode,
336
- responseHeaders,
337
- error
391
+ function endCall(call, result) {
392
+ state.depth--;
393
+ if (!call || !isPromiseLike(result)) return result;
394
+ return result.then((response) => {
395
+ recordResponse(call, response);
396
+ return response;
397
+ }, (error) => {
398
+ call.endTime = (/* @__PURE__ */ new Date()).toISOString();
399
+ call.errorType = error instanceof Error && error.name ? error.name : "Error";
400
+ throw error;
338
401
  });
339
- const failed = error !== void 0 || statusCode !== void 0 && statusCode >= 400;
340
- return {
341
- traceId: traceContext.traceId,
342
- spanId: require_screenshots_zip.generateSpanId(),
343
- parentSpanId: traceContext.rootSpanId,
344
- name: `HTTP ${method}`,
345
- kind: SPAN_KIND_CLIENT$2,
346
- startTime,
347
- endTime,
348
- status: failed ? {
349
- code: SPAN_STATUS_CODE_ERROR$2,
350
- message: errorMessage$1(error)
351
- } : { code: SPAN_STATUS_CODE_UNSET$2 },
352
- attributes,
353
- events: []
354
- };
355
402
  }
356
- function createHttpAttributes$1({ method, url, statusCode, responseHeaders, error }) {
357
- const attributes = {
358
- "http.request.method": method,
359
- "http.resource.type": "fetch",
360
- "playwright.request.api": true,
361
- "url.full": url
362
- };
403
+ function recordResponse(call, response) {
404
+ call.endTime = (/* @__PURE__ */ new Date()).toISOString();
363
405
  try {
364
- const parsedUrl = new URL(url);
365
- attributes["url.path"] = parsedUrl.pathname;
366
- attributes["server.address"] = parsedUrl.hostname;
367
- attributes["server.port"] = serverPort$1(parsedUrl);
368
- if (parsedUrl.search) attributes["url.query"] = parsedUrl.search.slice(1);
406
+ call.statusCode = response.status();
407
+ call.responseUrl = response.url();
408
+ const headers = response.headers();
409
+ const recorded = {};
410
+ for (const name of require_screenshots_zip.RECORDED_RESPONSE_HEADERS) if (typeof headers[name] === "string") recorded[name] = headers[name];
411
+ call.responseHeaders = recorded;
369
412
  } catch {}
370
- if (statusCode !== void 0) {
371
- attributes["http.response.status_code"] = statusCode;
372
- if (statusCode >= 400) attributes["error.type"] = statusCode.toString();
373
- } else if (error !== void 0) attributes["error.type"] = errorType$1(error);
374
- const contentType = responseHeaders?.["content-type"];
375
- const cacheControl = responseHeaders?.["cache-control"];
376
- if (contentType) attributes["http.response.header.content-type"] = [contentType];
377
- if (cacheControl) attributes["http.response.header.cache-control"] = [cacheControl];
378
- return attributes;
379
413
  }
380
- function getRequestMethod(methodName, args) {
381
- const options = getOptions(args[1]);
382
- if (methodName === "fetch") {
383
- const input = args[0];
384
- return (options.method ?? (input instanceof Request ? input.method : void 0) ?? "GET").toUpperCase();
385
- }
386
- return methodName.toUpperCase();
414
+ /**
415
+ * Adds the header to the call's options, which `args` holds and Playwright is
416
+ * about to be called with. Leaves a `traceparent` the test set itself alone.
417
+ */
418
+ function addTraceparent(args, traceparent) {
419
+ const options = args[1];
420
+ if (options !== void 0 && (typeof options !== "object" || !options)) return false;
421
+ const headers = options?.headers ?? (typeof args[0] === "string" ? {} : requestHeaders(args[0]));
422
+ if (typeof headers !== "object" || headers === null || Object.keys(headers).some((name) => name.toLowerCase() === "traceparent")) return false;
423
+ args[1] = {
424
+ ...options,
425
+ headers: {
426
+ ...headers,
427
+ traceparent
428
+ }
429
+ };
430
+ return true;
387
431
  }
388
- function getRequestUrl(input) {
389
- if (input instanceof Request) return input.url;
390
- return String(input);
432
+ function requestHeaders(input) {
433
+ const headers = input?.headers;
434
+ return typeof headers === "function" ? headers.call(input) : void 0;
391
435
  }
392
- function getOptions(value) {
393
- if (typeof value !== "object" || value === null || !("method" in value)) return {};
394
- const method = value.method;
395
- return typeof method === "string" ? { method } : {};
436
+ function requestMethod(methodName, args) {
437
+ if (methodName !== "fetch") return methodName.toUpperCase();
438
+ const options = args[1];
439
+ return (typeof options?.method === "string" ? options.method : callIfFunction(args[0], "method") ?? "GET").toUpperCase();
396
440
  }
397
- function serverPort$1(url) {
398
- if (url.port) return Number.parseInt(url.port, 10);
399
- return url.protocol === "https:" ? 443 : 80;
441
+ /** `fetch()` also takes a Playwright `Request`. */
442
+ function requestUrl(input) {
443
+ return typeof input === "string" ? input : callIfFunction(input, "url") ?? String(input);
400
444
  }
401
- function errorType$1(error) {
402
- if (error instanceof Error && error.name) return error.name;
403
- return "Error";
445
+ function callIfFunction(target, name) {
446
+ const member = target?.[name];
447
+ if (typeof member !== "function") return;
448
+ const value = member.call(target);
449
+ return typeof value === "string" ? value : void 0;
404
450
  }
405
- function errorMessage$1(error) {
406
- return error instanceof Error && error.message ? error.message : void 0;
451
+ const STACK_FRAME_LOCATION = /^\s*at (?:.*? \()?(.+?):(\d+):(\d+)\)?$/;
452
+ const PLAYWRIGHT_PACKAGE_FILE = /[/\\]node_modules[/\\](?:playwright|playwright-core|@playwright[/\\]test)[/\\]/;
453
+ /**
454
+ * Where the wrapped method was called from: the first frame below the wrapper
455
+ * that Playwright would also take as the step's location.
456
+ */
457
+ function callSite(rootDir) {
458
+ const stackTraceLimit = Error.stackTraceLimit;
459
+ Error.stackTraceLimit = Math.max(stackTraceLimit, 20);
460
+ const stack = (/* @__PURE__ */ new Error()).stack?.split("\n") ?? [];
461
+ Error.stackTraceLimit = stackTraceLimit;
462
+ const wrapperIndex = stack.findIndex((line) => line.includes(require_screenshots_zip.API_REQUEST_WRAPPER_FILE));
463
+ if (wrapperIndex === -1) return;
464
+ for (const line of stack.slice(wrapperIndex + 1)) {
465
+ const match = STACK_FRAME_LOCATION.exec(line);
466
+ if (!match) continue;
467
+ const file = match[1].startsWith("file://") ? (0, node_url.fileURLToPath)(match[1]) : match[1];
468
+ if (!node_path.default.isAbsolute(file) || PLAYWRIGHT_PACKAGE_FILE.test(file)) continue;
469
+ return {
470
+ file: node_path.default.relative(rootDir, file),
471
+ line: Number(match[2]),
472
+ column: Number(match[3])
473
+ };
474
+ }
475
+ }
476
+ /**
477
+ * Hands the recorded calls to the reporter, if anything keeps this test.
478
+ * Never rejects: a test must not fail because its requests couldn't be
479
+ * stored.
480
+ */
481
+ async function handOffApiRequests(requests, config, options) {
482
+ try {
483
+ const retainsTrace = (trace) => require_screenshots_zip.shouldRetainPlaywrightTrace(trace ?? options.trace, options.testInfo);
484
+ const retained = config.storeTraceZip && retainsTrace(config.trace) || [config.otlpDestinations, config.playwrightTraceApiDestinations].some((destinations) => require_screenshots_zip.filterRetainedDestinations(destinations, config.trace, retainsTrace).length > 0);
485
+ if (requests.length === 0 || !retained) return;
486
+ const body = JSON.stringify({ requests });
487
+ if (config.attachFixtureData) {
488
+ await options.testInfo.attach(require_screenshots_zip.API_REQUESTS_ATTACHMENT_NAME, {
489
+ body,
490
+ contentType: "application/json"
491
+ });
492
+ return;
493
+ }
494
+ await require_screenshots_zip.writeFixtureHandoffFile(options.testInfo, require_screenshots_zip.API_REQUESTS_HANDOFF_FILE, body);
495
+ } catch (error) {
496
+ console.warn(`Failed to store API requests: ${error instanceof Error ? error.message : String(error)}`);
497
+ }
498
+ }
499
+ function isPromiseLike(value) {
500
+ return typeof value === "object" && value !== null && typeof value.then === "function";
501
+ }
502
+ function isWrapped(method) {
503
+ return method[WRAPPED] === true;
504
+ }
505
+ function markWrapped(wrapper) {
506
+ wrapper[WRAPPED] = true;
507
+ return wrapper;
407
508
  }
408
509
  //#endregion
409
510
  //#region src/fixture/reporter-config.ts
@@ -920,15 +1021,20 @@ const SPAN_STATUS_CODE_UNSET = 0;
920
1021
  const SPAN_STATUS_CODE_ERROR = 2;
921
1022
  let originalFetch;
922
1023
  let activeTraceContext;
923
- function runWithTestFetchCapture(traceContext, callback) {
1024
+ let propagateTraceHeaders = false;
1025
+ function runWithTestFetchCapture(traceContext, callback, options = {}) {
924
1026
  ensureFetchPatched();
925
- const previousTraceContext = activeTraceContext;
1027
+ const previous = {
1028
+ activeTraceContext,
1029
+ propagateTraceHeaders
1030
+ };
926
1031
  activeTraceContext = traceContext;
1032
+ propagateTraceHeaders = options.propagateTraceHeaders === true;
927
1033
  return (async () => {
928
1034
  try {
929
1035
  return await callback();
930
1036
  } finally {
931
- activeTraceContext = previousTraceContext;
1037
+ ({activeTraceContext, propagateTraceHeaders} = previous);
932
1038
  }
933
1039
  })();
934
1040
  }
@@ -941,10 +1047,13 @@ const patchedFetch = async (input, init) => {
941
1047
  const traceContext = activeTraceContext;
942
1048
  if (!traceContext) return originalFetch ? originalFetch(input, init) : globalThis.fetch(input, init);
943
1049
  if (!originalFetch) return globalThis.fetch(input, init);
1050
+ const spanId = require_screenshots_zip.generateSpanId();
1051
+ const sentInit = propagateTraceHeaders ? withTraceparent(input, init, require_screenshots_zip.traceparentHeader(traceContext.traceId, spanId)) : init;
944
1052
  const startTime = /* @__PURE__ */ new Date();
945
1053
  try {
946
- const response = await originalFetch(input, init);
1054
+ const response = await originalFetch(input, sentInit);
947
1055
  traceContext.addSpan(createFetchSpan({
1056
+ spanId,
948
1057
  input,
949
1058
  init,
950
1059
  traceContext,
@@ -957,6 +1066,7 @@ const patchedFetch = async (input, init) => {
957
1066
  return response;
958
1067
  } catch (error) {
959
1068
  traceContext.addSpan(createFetchSpan({
1069
+ spanId,
960
1070
  input,
961
1071
  init,
962
1072
  traceContext,
@@ -967,7 +1077,28 @@ const patchedFetch = async (input, init) => {
967
1077
  throw error;
968
1078
  }
969
1079
  };
970
- function createFetchSpan({ input, init, traceContext, startTime, endTime, statusCode, contentType, cacheControl, error }) {
1080
+ /**
1081
+ * Keeps the kind of headers the test passed. Leaves a `traceparent` the test
1082
+ * set itself alone.
1083
+ */
1084
+ function withTraceparent(input, init, traceparent) {
1085
+ const existing = init?.headers ?? (input instanceof Request ? input.headers : void 0);
1086
+ if (new Headers(existing).has("traceparent")) return init;
1087
+ let headers;
1088
+ if (existing instanceof Headers) {
1089
+ headers = new Headers(existing);
1090
+ headers.set("traceparent", traceparent);
1091
+ } else if (Array.isArray(existing)) headers = [...existing, ["traceparent", traceparent]];
1092
+ else headers = {
1093
+ ...existing,
1094
+ traceparent
1095
+ };
1096
+ return {
1097
+ ...init,
1098
+ headers
1099
+ };
1100
+ }
1101
+ function createFetchSpan({ spanId, input, init, traceContext, startTime, endTime, statusCode, contentType, cacheControl, error }) {
971
1102
  const method = getFetchMethod(input, init);
972
1103
  const attributes = createHttpAttributes({
973
1104
  method,
@@ -980,7 +1111,7 @@ function createFetchSpan({ input, init, traceContext, startTime, endTime, status
980
1111
  const failed = error !== void 0 || statusCode !== void 0 && statusCode >= 400;
981
1112
  return {
982
1113
  traceId: traceContext.traceId,
983
- spanId: require_screenshots_zip.generateSpanId(),
1114
+ spanId,
984
1115
  parentSpanId: traceContext.rootSpanId,
985
1116
  name: `HTTP ${method}`,
986
1117
  kind: SPAN_KIND_CLIENT,
@@ -1045,11 +1176,19 @@ function createPlaywrightOtelTest(testBase) {
1045
1176
  scope: "worker",
1046
1177
  auto: true
1047
1178
  }],
1179
+ _playwrightOpentelemetryApiRequests: [async ({ playwright }, use) => {
1180
+ captureNewApiRequestContexts(playwright.request);
1181
+ await use();
1182
+ }, {
1183
+ scope: "worker",
1184
+ auto: true
1185
+ }],
1048
1186
  _playwrightOpentelemetryNewContexts: [async ({}, use) => {
1049
1187
  await use(/* @__PURE__ */ new Set());
1050
1188
  }, { scope: "worker" }],
1051
1189
  browser: [async ({ browser, _playwrightOpentelemetryNewContexts }, use) => {
1052
1190
  const onContext = (context) => {
1191
+ captureApiRequests(context.request);
1053
1192
  for (const listener of _playwrightOpentelemetryNewContexts) listener(context);
1054
1193
  };
1055
1194
  browser.on("context", onContext);
@@ -1066,16 +1205,29 @@ function createPlaywrightOtelTest(testBase) {
1066
1205
  testTraceContext: [async ({ playwrightOpentelemetry, trace }, use, testInfo) => {
1067
1206
  const config = require_screenshots_zip.resolvePlaywrightOpentelemetryConfig(playwrightOpentelemetry);
1068
1207
  const traceContext = await require_screenshots_zip.createTestTraceContext(testInfo, config);
1208
+ const apiRequests = startApiRequestRecording({
1209
+ rootDir: testInfo.config.rootDir,
1210
+ traceId: config.propagateTraceHeaders ? traceContext.traceId : void 0
1211
+ });
1069
1212
  const registration = require_screenshots_zip.registerExpectedTrace(traceContext, config, {
1070
1213
  trace,
1071
1214
  testInfo
1072
1215
  });
1073
- await runWithTestFetchCapture(traceContext, () => use(traceContext));
1216
+ let requests;
1217
+ try {
1218
+ await runWithTestFetchCapture(traceContext, () => use(traceContext), { propagateTraceHeaders: config.propagateTraceHeaders });
1219
+ } finally {
1220
+ requests = apiRequests.stop();
1221
+ }
1074
1222
  await registration;
1075
1223
  await require_screenshots_zip.flushFixtureSpans(traceContext, config, {
1076
1224
  trace,
1077
1225
  testInfo
1078
1226
  });
1227
+ await handOffApiRequests(requests, config, {
1228
+ trace,
1229
+ testInfo
1230
+ });
1079
1231
  }, { auto: true }],
1080
1232
  browserPageTracker: [async ({ testTraceContext }, use) => {
1081
1233
  const tracker = new BrowserPageTracker(testTraceContext);
@@ -1114,12 +1266,10 @@ function createPlaywrightOtelTest(testBase) {
1114
1266
  testInfo
1115
1267
  });
1116
1268
  }, { auto: true }],
1117
- request: async ({ request, testTraceContext }, use) => {
1118
- await use(createCapturedApiRequestContext(request, testTraceContext));
1119
- },
1120
1269
  context: async ({ context, playwrightOpentelemetry, testTraceContext, browserPageTracker, screencastCapture }, use) => {
1121
1270
  const config = require_screenshots_zip.resolvePlaywrightOpentelemetryConfig(playwrightOpentelemetry);
1122
1271
  screencastCapture?.addContext(context);
1272
+ captureApiRequests(context.request);
1123
1273
  const captureRequest = (request) => {
1124
1274
  browserPageTracker.startDocumentNavigation(request);
1125
1275
  const networkParent = browserPageTracker.getNetworkParent(request);
@@ -1,5 +1,5 @@
1
- import { i as PlaywrightTraceOption, n as PlaywrightOpentelemetryDestination, r as PlaywrightOpentelemetryUseOptions, t as PlaywrightOpentelemetryConfig } from "./config-g9K4ZUC_.cjs";
2
- import { n as SpanEvent, t as Span } from "./otel-D0ztpic2.cjs";
1
+ import { n as Span, r as SpanEvent } from "./reporter-Ttd0SnXX.cjs";
2
+ import { i as PlaywrightTraceOption, n as PlaywrightOpentelemetryDestination, r as PlaywrightOpentelemetryUseOptions, t as PlaywrightOpentelemetryConfig } from "./index-48srAaol.cjs";
3
3
  import { BrowserContext, ConsoleMessage, Page, Request } from "@playwright/test";
4
4
  export * from "@playwright/test";
5
5
 
@@ -108,6 +108,7 @@ declare const test: import("@playwright/test").TestType<import("@playwright/test
108
108
  screencastCapture: ScreencastCapture | undefined;
109
109
  }, import("@playwright/test").PlaywrightWorkerArgs & import("@playwright/test").PlaywrightWorkerOptions & {
110
110
  _playwrightOpentelemetryReporterCheck: void;
111
+ _playwrightOpentelemetryApiRequests: void;
111
112
  _playwrightOpentelemetryNewContexts: Set<(context: import("@playwright/test").BrowserContext) => void>;
112
113
  }>;
113
114
  //#endregion
@@ -1,5 +1,5 @@
1
- import { i as PlaywrightTraceOption, n as PlaywrightOpentelemetryDestination, r as PlaywrightOpentelemetryUseOptions, t as PlaywrightOpentelemetryConfig } from "./config-g9K4ZUC_.mjs";
2
- import { n as SpanEvent, t as Span } from "./otel-D0ztpic2.mjs";
1
+ import { n as Span, r as SpanEvent } from "./reporter-Ttd0SnXX.mjs";
2
+ import { i as PlaywrightTraceOption, n as PlaywrightOpentelemetryDestination, r as PlaywrightOpentelemetryUseOptions, t as PlaywrightOpentelemetryConfig } from "./index-48srAaol.mjs";
3
3
  import { BrowserContext, ConsoleMessage, Page, Request } from "@playwright/test";
4
4
  export * from "@playwright/test";
5
5
 
@@ -108,6 +108,7 @@ declare const test: import("@playwright/test").TestType<import("@playwright/test
108
108
  screencastCapture: ScreencastCapture | undefined;
109
109
  }, import("@playwright/test").PlaywrightWorkerArgs & import("@playwright/test").PlaywrightWorkerOptions & {
110
110
  _playwrightOpentelemetryReporterCheck: void;
111
+ _playwrightOpentelemetryApiRequests: void;
111
112
  _playwrightOpentelemetryNewContexts: Set<(context: import("@playwright/test").BrowserContext) => void>;
112
113
  }>;
113
114
  //#endregion