playwright-opentelemetry 0.12.0 → 0.12.1
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/{config-BzW6-Ty7.cjs → config-CE5ph46B.cjs} +1 -1
- package/dist/{config-Bv4dsPRO.mjs → config-CoP8kphA.mjs} +1 -1
- package/dist/fixture.cjs +125 -3
- package/dist/fixture.mjs +125 -3
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +1 -1
- package/dist/{reporter-BFqKJlKV.cjs → reporter-C5uzPmZH.cjs} +17 -4
- package/dist/{reporter-DTduncL-.mjs → reporter-CeFtIXbG.mjs} +17 -4
- package/dist/reporter.cjs +1 -1
- package/dist/reporter.mjs +1 -1
- package/package.json +1 -1
|
@@ -21,7 +21,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
21
21
|
}) : target, mod));
|
|
22
22
|
//#endregion
|
|
23
23
|
//#region package.json
|
|
24
|
-
var version = "0.12.
|
|
24
|
+
var version = "0.12.1";
|
|
25
25
|
const PLAYWRIGHT_TRACE_API_SOURCE_HEADER = "x-playwright-otel-source";
|
|
26
26
|
const PLAYWRIGHT_TRACE_API_SOURCE_REPORTER = "reporter";
|
|
27
27
|
function withPlaywrightTraceApiHeaders(headers) {
|
package/dist/fixture.cjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_config = require("./config-
|
|
2
|
+
const require_config = require("./config-CE5ph46B.cjs");
|
|
3
3
|
let node_path = require("node:path");
|
|
4
4
|
node_path = require_config.__toESM(node_path, 1);
|
|
5
5
|
let _playwright_test = require("@playwright/test");
|
|
6
6
|
//#region src/fixture/browser-page-tracker.ts
|
|
7
7
|
const BROWSER_PAGE_SPAN_NAME = "browser.page";
|
|
8
8
|
const BROWSER_ROUTE_SPAN_NAME = "browser.route";
|
|
9
|
-
const SPAN_STATUS_CODE_UNSET$
|
|
9
|
+
const SPAN_STATUS_CODE_UNSET$3 = 0;
|
|
10
10
|
var BrowserPageTracker = class {
|
|
11
11
|
traceContext;
|
|
12
12
|
nextPageId = 1;
|
|
@@ -168,7 +168,7 @@ var BrowserPageTracker = class {
|
|
|
168
168
|
name,
|
|
169
169
|
startTime,
|
|
170
170
|
endTime: startTime,
|
|
171
|
-
status: { code: SPAN_STATUS_CODE_UNSET$
|
|
171
|
+
status: { code: SPAN_STATUS_CODE_UNSET$3 },
|
|
172
172
|
attributes: pageAttributes({
|
|
173
173
|
pageId,
|
|
174
174
|
url,
|
|
@@ -263,6 +263,125 @@ async function propagateRouteTraceHeaders({ route, request, traceId, spanId }) {
|
|
|
263
263
|
} });
|
|
264
264
|
}
|
|
265
265
|
//#endregion
|
|
266
|
+
//#region src/fixture/api-request-capture.ts
|
|
267
|
+
const SPAN_KIND_CLIENT$2 = 3;
|
|
268
|
+
const SPAN_STATUS_CODE_UNSET$2 = 0;
|
|
269
|
+
const SPAN_STATUS_CODE_ERROR$2 = 2;
|
|
270
|
+
const CAPTURED_METHODS = new Set([
|
|
271
|
+
"delete",
|
|
272
|
+
"fetch",
|
|
273
|
+
"get",
|
|
274
|
+
"head",
|
|
275
|
+
"patch",
|
|
276
|
+
"post",
|
|
277
|
+
"put"
|
|
278
|
+
]);
|
|
279
|
+
function createCapturedApiRequestContext(request, traceContext) {
|
|
280
|
+
return new Proxy(request, { get(target, property, receiver) {
|
|
281
|
+
const value = Reflect.get(target, property, receiver);
|
|
282
|
+
if (typeof property !== "string" || !CAPTURED_METHODS.has(property)) return value;
|
|
283
|
+
if (typeof value !== "function") return value;
|
|
284
|
+
return async (...args) => {
|
|
285
|
+
const startTime = /* @__PURE__ */ new Date();
|
|
286
|
+
try {
|
|
287
|
+
const response = await value.apply(target, args);
|
|
288
|
+
traceContext.addSpan(createApiRequestSpan({
|
|
289
|
+
methodName: property,
|
|
290
|
+
args,
|
|
291
|
+
traceContext,
|
|
292
|
+
startTime,
|
|
293
|
+
endTime: /* @__PURE__ */ new Date(),
|
|
294
|
+
statusCode: response.status()
|
|
295
|
+
}));
|
|
296
|
+
return response;
|
|
297
|
+
} catch (error) {
|
|
298
|
+
traceContext.addSpan(createApiRequestSpan({
|
|
299
|
+
methodName: property,
|
|
300
|
+
args,
|
|
301
|
+
traceContext,
|
|
302
|
+
startTime,
|
|
303
|
+
endTime: /* @__PURE__ */ new Date(),
|
|
304
|
+
error
|
|
305
|
+
}));
|
|
306
|
+
throw error;
|
|
307
|
+
}
|
|
308
|
+
};
|
|
309
|
+
} });
|
|
310
|
+
}
|
|
311
|
+
function createApiRequestSpan({ methodName, args, traceContext, startTime, endTime, statusCode, error }) {
|
|
312
|
+
const method = getRequestMethod(methodName, args);
|
|
313
|
+
const attributes = createHttpAttributes$1({
|
|
314
|
+
method,
|
|
315
|
+
url: getRequestUrl(args[0]),
|
|
316
|
+
statusCode,
|
|
317
|
+
error
|
|
318
|
+
});
|
|
319
|
+
const failed = error !== void 0 || statusCode !== void 0 && statusCode >= 400;
|
|
320
|
+
return {
|
|
321
|
+
traceId: traceContext.traceId,
|
|
322
|
+
spanId: require_config.generateSpanId(),
|
|
323
|
+
parentSpanId: traceContext.rootSpanId,
|
|
324
|
+
name: `HTTP ${method}`,
|
|
325
|
+
kind: SPAN_KIND_CLIENT$2,
|
|
326
|
+
startTime,
|
|
327
|
+
endTime,
|
|
328
|
+
status: failed ? {
|
|
329
|
+
code: SPAN_STATUS_CODE_ERROR$2,
|
|
330
|
+
message: errorMessage$1(error)
|
|
331
|
+
} : { code: SPAN_STATUS_CODE_UNSET$2 },
|
|
332
|
+
attributes,
|
|
333
|
+
events: []
|
|
334
|
+
};
|
|
335
|
+
}
|
|
336
|
+
function createHttpAttributes$1({ method, url, statusCode, error }) {
|
|
337
|
+
const attributes = {
|
|
338
|
+
"http.request.method": method,
|
|
339
|
+
"http.resource.type": "fetch",
|
|
340
|
+
"playwright.request.api": true,
|
|
341
|
+
"url.full": url
|
|
342
|
+
};
|
|
343
|
+
try {
|
|
344
|
+
const parsedUrl = new URL(url);
|
|
345
|
+
attributes["url.path"] = parsedUrl.pathname;
|
|
346
|
+
attributes["server.address"] = parsedUrl.hostname;
|
|
347
|
+
attributes["server.port"] = serverPort$1(parsedUrl);
|
|
348
|
+
if (parsedUrl.search) attributes["url.query"] = parsedUrl.search.slice(1);
|
|
349
|
+
} catch {}
|
|
350
|
+
if (statusCode !== void 0) {
|
|
351
|
+
attributes["http.response.status_code"] = statusCode;
|
|
352
|
+
if (statusCode >= 400) attributes["error.type"] = statusCode.toString();
|
|
353
|
+
} else if (error !== void 0) attributes["error.type"] = errorType$1(error);
|
|
354
|
+
return attributes;
|
|
355
|
+
}
|
|
356
|
+
function getRequestMethod(methodName, args) {
|
|
357
|
+
const options = getOptions(args[1]);
|
|
358
|
+
if (methodName === "fetch") {
|
|
359
|
+
const input = args[0];
|
|
360
|
+
return (options.method ?? (input instanceof Request ? input.method : void 0) ?? "GET").toUpperCase();
|
|
361
|
+
}
|
|
362
|
+
return methodName.toUpperCase();
|
|
363
|
+
}
|
|
364
|
+
function getRequestUrl(input) {
|
|
365
|
+
if (input instanceof Request) return input.url;
|
|
366
|
+
return String(input);
|
|
367
|
+
}
|
|
368
|
+
function getOptions(value) {
|
|
369
|
+
if (typeof value !== "object" || value === null || !("method" in value)) return {};
|
|
370
|
+
const method = value.method;
|
|
371
|
+
return typeof method === "string" ? { method } : {};
|
|
372
|
+
}
|
|
373
|
+
function serverPort$1(url) {
|
|
374
|
+
if (url.port) return Number.parseInt(url.port, 10);
|
|
375
|
+
return url.protocol === "https:" ? 443 : 80;
|
|
376
|
+
}
|
|
377
|
+
function errorType$1(error) {
|
|
378
|
+
if (error instanceof Error && error.name) return error.name;
|
|
379
|
+
return "Error";
|
|
380
|
+
}
|
|
381
|
+
function errorMessage$1(error) {
|
|
382
|
+
return error instanceof Error && error.message ? error.message : void 0;
|
|
383
|
+
}
|
|
384
|
+
//#endregion
|
|
266
385
|
//#region src/fixture/reporter-config.ts
|
|
267
386
|
const PLAYWRIGHT_OPENTELEMETRY_REPORTER_NAMES = new Set(["playwright-opentelemetry", "playwright-opentelemetry/reporter"]);
|
|
268
387
|
const PLAYWRIGHT_OPENTELEMETRY_REPORTER_PATHS = ["dist/reporter.mjs", "dist/reporter.cjs"];
|
|
@@ -545,6 +664,9 @@ function createPlaywrightOtelTest(testBase) {
|
|
|
545
664
|
await use(tracker);
|
|
546
665
|
tracker.finishAll();
|
|
547
666
|
}, { auto: true }],
|
|
667
|
+
request: async ({ request, testTraceContext }, use) => {
|
|
668
|
+
await use(createCapturedApiRequestContext(request, testTraceContext));
|
|
669
|
+
},
|
|
548
670
|
context: async ({ context, playwrightOpentelemetry, testTraceContext, browserPageTracker }, use) => {
|
|
549
671
|
const config = require_config.resolvePlaywrightOpentelemetryConfig(playwrightOpentelemetry);
|
|
550
672
|
context.route("**", async (route, request) => {
|
package/dist/fixture.mjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { a as createTestTraceContext, n as BROWSER_SERVICE_NAME, o as flushFixtureSpans, p as generateSpanId, s as registerExpectedTrace, t as resolvePlaywrightOpentelemetryConfig } from "./config-
|
|
1
|
+
import { a as createTestTraceContext, n as BROWSER_SERVICE_NAME, o as flushFixtureSpans, p as generateSpanId, s as registerExpectedTrace, t as resolvePlaywrightOpentelemetryConfig } from "./config-CoP8kphA.mjs";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { test as test$1 } from "@playwright/test";
|
|
4
4
|
export * from "@playwright/test";
|
|
5
5
|
//#region src/fixture/browser-page-tracker.ts
|
|
6
6
|
const BROWSER_PAGE_SPAN_NAME = "browser.page";
|
|
7
7
|
const BROWSER_ROUTE_SPAN_NAME = "browser.route";
|
|
8
|
-
const SPAN_STATUS_CODE_UNSET$
|
|
8
|
+
const SPAN_STATUS_CODE_UNSET$3 = 0;
|
|
9
9
|
var BrowserPageTracker = class {
|
|
10
10
|
traceContext;
|
|
11
11
|
nextPageId = 1;
|
|
@@ -167,7 +167,7 @@ var BrowserPageTracker = class {
|
|
|
167
167
|
name,
|
|
168
168
|
startTime,
|
|
169
169
|
endTime: startTime,
|
|
170
|
-
status: { code: SPAN_STATUS_CODE_UNSET$
|
|
170
|
+
status: { code: SPAN_STATUS_CODE_UNSET$3 },
|
|
171
171
|
attributes: pageAttributes({
|
|
172
172
|
pageId,
|
|
173
173
|
url,
|
|
@@ -262,6 +262,125 @@ async function propagateRouteTraceHeaders({ route, request, traceId, spanId }) {
|
|
|
262
262
|
} });
|
|
263
263
|
}
|
|
264
264
|
//#endregion
|
|
265
|
+
//#region src/fixture/api-request-capture.ts
|
|
266
|
+
const SPAN_KIND_CLIENT$2 = 3;
|
|
267
|
+
const SPAN_STATUS_CODE_UNSET$2 = 0;
|
|
268
|
+
const SPAN_STATUS_CODE_ERROR$2 = 2;
|
|
269
|
+
const CAPTURED_METHODS = new Set([
|
|
270
|
+
"delete",
|
|
271
|
+
"fetch",
|
|
272
|
+
"get",
|
|
273
|
+
"head",
|
|
274
|
+
"patch",
|
|
275
|
+
"post",
|
|
276
|
+
"put"
|
|
277
|
+
]);
|
|
278
|
+
function createCapturedApiRequestContext(request, traceContext) {
|
|
279
|
+
return new Proxy(request, { get(target, property, receiver) {
|
|
280
|
+
const value = Reflect.get(target, property, receiver);
|
|
281
|
+
if (typeof property !== "string" || !CAPTURED_METHODS.has(property)) return value;
|
|
282
|
+
if (typeof value !== "function") return value;
|
|
283
|
+
return async (...args) => {
|
|
284
|
+
const startTime = /* @__PURE__ */ new Date();
|
|
285
|
+
try {
|
|
286
|
+
const response = await value.apply(target, args);
|
|
287
|
+
traceContext.addSpan(createApiRequestSpan({
|
|
288
|
+
methodName: property,
|
|
289
|
+
args,
|
|
290
|
+
traceContext,
|
|
291
|
+
startTime,
|
|
292
|
+
endTime: /* @__PURE__ */ new Date(),
|
|
293
|
+
statusCode: response.status()
|
|
294
|
+
}));
|
|
295
|
+
return response;
|
|
296
|
+
} catch (error) {
|
|
297
|
+
traceContext.addSpan(createApiRequestSpan({
|
|
298
|
+
methodName: property,
|
|
299
|
+
args,
|
|
300
|
+
traceContext,
|
|
301
|
+
startTime,
|
|
302
|
+
endTime: /* @__PURE__ */ new Date(),
|
|
303
|
+
error
|
|
304
|
+
}));
|
|
305
|
+
throw error;
|
|
306
|
+
}
|
|
307
|
+
};
|
|
308
|
+
} });
|
|
309
|
+
}
|
|
310
|
+
function createApiRequestSpan({ methodName, args, traceContext, startTime, endTime, statusCode, error }) {
|
|
311
|
+
const method = getRequestMethod(methodName, args);
|
|
312
|
+
const attributes = createHttpAttributes$1({
|
|
313
|
+
method,
|
|
314
|
+
url: getRequestUrl(args[0]),
|
|
315
|
+
statusCode,
|
|
316
|
+
error
|
|
317
|
+
});
|
|
318
|
+
const failed = error !== void 0 || statusCode !== void 0 && statusCode >= 400;
|
|
319
|
+
return {
|
|
320
|
+
traceId: traceContext.traceId,
|
|
321
|
+
spanId: generateSpanId(),
|
|
322
|
+
parentSpanId: traceContext.rootSpanId,
|
|
323
|
+
name: `HTTP ${method}`,
|
|
324
|
+
kind: SPAN_KIND_CLIENT$2,
|
|
325
|
+
startTime,
|
|
326
|
+
endTime,
|
|
327
|
+
status: failed ? {
|
|
328
|
+
code: SPAN_STATUS_CODE_ERROR$2,
|
|
329
|
+
message: errorMessage$1(error)
|
|
330
|
+
} : { code: SPAN_STATUS_CODE_UNSET$2 },
|
|
331
|
+
attributes,
|
|
332
|
+
events: []
|
|
333
|
+
};
|
|
334
|
+
}
|
|
335
|
+
function createHttpAttributes$1({ method, url, statusCode, error }) {
|
|
336
|
+
const attributes = {
|
|
337
|
+
"http.request.method": method,
|
|
338
|
+
"http.resource.type": "fetch",
|
|
339
|
+
"playwright.request.api": true,
|
|
340
|
+
"url.full": url
|
|
341
|
+
};
|
|
342
|
+
try {
|
|
343
|
+
const parsedUrl = new URL(url);
|
|
344
|
+
attributes["url.path"] = parsedUrl.pathname;
|
|
345
|
+
attributes["server.address"] = parsedUrl.hostname;
|
|
346
|
+
attributes["server.port"] = serverPort$1(parsedUrl);
|
|
347
|
+
if (parsedUrl.search) attributes["url.query"] = parsedUrl.search.slice(1);
|
|
348
|
+
} catch {}
|
|
349
|
+
if (statusCode !== void 0) {
|
|
350
|
+
attributes["http.response.status_code"] = statusCode;
|
|
351
|
+
if (statusCode >= 400) attributes["error.type"] = statusCode.toString();
|
|
352
|
+
} else if (error !== void 0) attributes["error.type"] = errorType$1(error);
|
|
353
|
+
return attributes;
|
|
354
|
+
}
|
|
355
|
+
function getRequestMethod(methodName, args) {
|
|
356
|
+
const options = getOptions(args[1]);
|
|
357
|
+
if (methodName === "fetch") {
|
|
358
|
+
const input = args[0];
|
|
359
|
+
return (options.method ?? (input instanceof Request ? input.method : void 0) ?? "GET").toUpperCase();
|
|
360
|
+
}
|
|
361
|
+
return methodName.toUpperCase();
|
|
362
|
+
}
|
|
363
|
+
function getRequestUrl(input) {
|
|
364
|
+
if (input instanceof Request) return input.url;
|
|
365
|
+
return String(input);
|
|
366
|
+
}
|
|
367
|
+
function getOptions(value) {
|
|
368
|
+
if (typeof value !== "object" || value === null || !("method" in value)) return {};
|
|
369
|
+
const method = value.method;
|
|
370
|
+
return typeof method === "string" ? { method } : {};
|
|
371
|
+
}
|
|
372
|
+
function serverPort$1(url) {
|
|
373
|
+
if (url.port) return Number.parseInt(url.port, 10);
|
|
374
|
+
return url.protocol === "https:" ? 443 : 80;
|
|
375
|
+
}
|
|
376
|
+
function errorType$1(error) {
|
|
377
|
+
if (error instanceof Error && error.name) return error.name;
|
|
378
|
+
return "Error";
|
|
379
|
+
}
|
|
380
|
+
function errorMessage$1(error) {
|
|
381
|
+
return error instanceof Error && error.message ? error.message : void 0;
|
|
382
|
+
}
|
|
383
|
+
//#endregion
|
|
265
384
|
//#region src/fixture/reporter-config.ts
|
|
266
385
|
const PLAYWRIGHT_OPENTELEMETRY_REPORTER_NAMES = new Set(["playwright-opentelemetry", "playwright-opentelemetry/reporter"]);
|
|
267
386
|
const PLAYWRIGHT_OPENTELEMETRY_REPORTER_PATHS = ["dist/reporter.mjs", "dist/reporter.cjs"];
|
|
@@ -544,6 +663,9 @@ function createPlaywrightOtelTest(testBase) {
|
|
|
544
663
|
await use(tracker);
|
|
545
664
|
tracker.finishAll();
|
|
546
665
|
}, { auto: true }],
|
|
666
|
+
request: async ({ request, testTraceContext }, use) => {
|
|
667
|
+
await use(createCapturedApiRequestContext(request, testTraceContext));
|
|
668
|
+
},
|
|
547
669
|
context: async ({ context, playwrightOpentelemetry, testTraceContext, browserPageTracker }, use) => {
|
|
548
670
|
const config = resolvePlaywrightOpentelemetryConfig(playwrightOpentelemetry);
|
|
549
671
|
context.route("**", async (route, request) => {
|
package/dist/index.cjs
CHANGED
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const require_config = require("./config-
|
|
1
|
+
const require_config = require("./config-CE5ph46B.cjs");
|
|
2
2
|
let node_path = require("node:path");
|
|
3
3
|
node_path = require_config.__toESM(node_path, 1);
|
|
4
4
|
let node_fs_promises = require("node:fs/promises");
|
|
@@ -319,7 +319,7 @@ var PlaywrightOpentelemetryReporter = class {
|
|
|
319
319
|
}
|
|
320
320
|
processTestStep(test, step, parentSpanId, traceId, parentTitlePath, processedSteps, skippedStepIds) {
|
|
321
321
|
const stepId = getStepId(test, step);
|
|
322
|
-
if (isInternalFixtureStep(step)) {
|
|
322
|
+
if (isInternalFixtureStep(step) || isInternalApiRequestStep(step)) {
|
|
323
323
|
skippedStepIds.add(stepId);
|
|
324
324
|
processedSteps.delete(stepId);
|
|
325
325
|
if (step.steps && step.steps.length > 0) for (const childStep of step.steps) this.processTestStep(test, childStep, parentSpanId, traceId, parentTitlePath, processedSteps, skippedStepIds);
|
|
@@ -498,15 +498,28 @@ function cleanErrorMessage(message) {
|
|
|
498
498
|
}
|
|
499
499
|
function isInternalFixtureStep(step) {
|
|
500
500
|
if (step.category !== "fixture" || !step.location?.file) return false;
|
|
501
|
-
|
|
501
|
+
return isInternalFixtureFile(step.location.file);
|
|
502
|
+
}
|
|
503
|
+
function isInternalApiRequestStep(step) {
|
|
504
|
+
if (step.category !== "pw:api" || !step.location?.file) return false;
|
|
505
|
+
return isApiRequestStepTitle(step.title) && isInternalFixtureFile(step.location.file);
|
|
506
|
+
}
|
|
507
|
+
function isApiRequestStepTitle(title) {
|
|
508
|
+
return /^(?:DELETE|FETCH|GET|HEAD|PATCH|POST|PUT)\s+"/.test(title);
|
|
509
|
+
}
|
|
510
|
+
function isInternalFixtureFile(filePath) {
|
|
511
|
+
const file = filePath.replace(/\\/g, "/");
|
|
502
512
|
return INTERNAL_FIXTURE_FILE_PATTERNS.some((pattern) => pattern.test(file));
|
|
503
513
|
}
|
|
504
514
|
const INTERNAL_FIXTURE_FILE_PATTERNS = [
|
|
505
515
|
/(?:^|\/)dist\/playwright-opentelemetry-fixture-[^/]+\.(?:mjs|cjs|js)$/,
|
|
516
|
+
/(?:^|\/)dist\/fixture\.(?:mjs|cjs|js)$/,
|
|
506
517
|
/(?:^|\/)playwright-opentelemetry\/dist\/fixture\.(?:mjs|cjs|js)$/,
|
|
518
|
+
/(?:^|\/)playwright-opentelemetry\/reporter\/dist\/fixture\.(?:mjs|cjs|js)$/,
|
|
507
519
|
/(?:^|\/)playwright-opentelemetry\/dist\/playwright-opentelemetry-fixture-[^/]+\.(?:mjs|cjs|js)$/,
|
|
508
520
|
/(?:^|\/)playwright-opentelemetry\/dist\/fixture\/index\.(?:mjs|cjs|js)$/,
|
|
509
|
-
/(?:^|\/)playwright-opentelemetry\/(?:reporter\/)?src\/fixture\/playwright-opentelemetry-fixture\.ts
|
|
521
|
+
/(?:^|\/)playwright-opentelemetry\/(?:reporter\/)?src\/fixture\/playwright-opentelemetry-fixture\.ts$/,
|
|
522
|
+
/(?:^|\/)playwright-opentelemetry\/(?:reporter\/)?src\/fixture\/api-request-capture\.ts$/
|
|
510
523
|
];
|
|
511
524
|
function isSpanAttributes(value) {
|
|
512
525
|
if (!isRecord(value)) return false;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { c as shouldRetainPlaywrightTrace, d as PLAYWRIGHT_TRACE_API_SOURCE_REPORTER, f as buildOtlpRequest, g as withPlaywrightTraceApiHeaders, h as sendSpans, i as TRACE_CONTEXT_ATTACHMENT_NAME, l as filterRetainedDestinations, m as generateTraceId, p as generateSpanId, r as FIXTURE_SPANS_ATTACHMENT_NAME, t as resolvePlaywrightOpentelemetryConfig, u as PLAYWRIGHT_TRACE_API_SOURCE_HEADER } from "./config-
|
|
1
|
+
import { c as shouldRetainPlaywrightTrace, d as PLAYWRIGHT_TRACE_API_SOURCE_REPORTER, f as buildOtlpRequest, g as withPlaywrightTraceApiHeaders, h as sendSpans, i as TRACE_CONTEXT_ATTACHMENT_NAME, l as filterRetainedDestinations, m as generateTraceId, p as generateSpanId, r as FIXTURE_SPANS_ATTACHMENT_NAME, t as resolvePlaywrightOpentelemetryConfig, u as PLAYWRIGHT_TRACE_API_SOURCE_HEADER } from "./config-CoP8kphA.mjs";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import fs from "node:fs/promises";
|
|
4
4
|
import { BlobReader, BlobWriter, TextWriter, ZipReader, ZipWriter } from "@zip.js/zip.js";
|
|
@@ -317,7 +317,7 @@ var PlaywrightOpentelemetryReporter = class {
|
|
|
317
317
|
}
|
|
318
318
|
processTestStep(test, step, parentSpanId, traceId, parentTitlePath, processedSteps, skippedStepIds) {
|
|
319
319
|
const stepId = getStepId(test, step);
|
|
320
|
-
if (isInternalFixtureStep(step)) {
|
|
320
|
+
if (isInternalFixtureStep(step) || isInternalApiRequestStep(step)) {
|
|
321
321
|
skippedStepIds.add(stepId);
|
|
322
322
|
processedSteps.delete(stepId);
|
|
323
323
|
if (step.steps && step.steps.length > 0) for (const childStep of step.steps) this.processTestStep(test, childStep, parentSpanId, traceId, parentTitlePath, processedSteps, skippedStepIds);
|
|
@@ -496,15 +496,28 @@ function cleanErrorMessage(message) {
|
|
|
496
496
|
}
|
|
497
497
|
function isInternalFixtureStep(step) {
|
|
498
498
|
if (step.category !== "fixture" || !step.location?.file) return false;
|
|
499
|
-
|
|
499
|
+
return isInternalFixtureFile(step.location.file);
|
|
500
|
+
}
|
|
501
|
+
function isInternalApiRequestStep(step) {
|
|
502
|
+
if (step.category !== "pw:api" || !step.location?.file) return false;
|
|
503
|
+
return isApiRequestStepTitle(step.title) && isInternalFixtureFile(step.location.file);
|
|
504
|
+
}
|
|
505
|
+
function isApiRequestStepTitle(title) {
|
|
506
|
+
return /^(?:DELETE|FETCH|GET|HEAD|PATCH|POST|PUT)\s+"/.test(title);
|
|
507
|
+
}
|
|
508
|
+
function isInternalFixtureFile(filePath) {
|
|
509
|
+
const file = filePath.replace(/\\/g, "/");
|
|
500
510
|
return INTERNAL_FIXTURE_FILE_PATTERNS.some((pattern) => pattern.test(file));
|
|
501
511
|
}
|
|
502
512
|
const INTERNAL_FIXTURE_FILE_PATTERNS = [
|
|
503
513
|
/(?:^|\/)dist\/playwright-opentelemetry-fixture-[^/]+\.(?:mjs|cjs|js)$/,
|
|
514
|
+
/(?:^|\/)dist\/fixture\.(?:mjs|cjs|js)$/,
|
|
504
515
|
/(?:^|\/)playwright-opentelemetry\/dist\/fixture\.(?:mjs|cjs|js)$/,
|
|
516
|
+
/(?:^|\/)playwright-opentelemetry\/reporter\/dist\/fixture\.(?:mjs|cjs|js)$/,
|
|
505
517
|
/(?:^|\/)playwright-opentelemetry\/dist\/playwright-opentelemetry-fixture-[^/]+\.(?:mjs|cjs|js)$/,
|
|
506
518
|
/(?:^|\/)playwright-opentelemetry\/dist\/fixture\/index\.(?:mjs|cjs|js)$/,
|
|
507
|
-
/(?:^|\/)playwright-opentelemetry\/(?:reporter\/)?src\/fixture\/playwright-opentelemetry-fixture\.ts
|
|
519
|
+
/(?:^|\/)playwright-opentelemetry\/(?:reporter\/)?src\/fixture\/playwright-opentelemetry-fixture\.ts$/,
|
|
520
|
+
/(?:^|\/)playwright-opentelemetry\/(?:reporter\/)?src\/fixture\/api-request-capture\.ts$/
|
|
508
521
|
];
|
|
509
522
|
function isSpanAttributes(value) {
|
|
510
523
|
if (!isRecord(value)) return false;
|
package/dist/reporter.cjs
CHANGED
package/dist/reporter.mjs
CHANGED