playwright-opentelemetry 0.12.2 → 0.13.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/dist/{config-DamCC4Fv.mjs → config-ChGo0Y1S.mjs} +1 -1
- package/dist/{config-B4WTFCIw.cjs → config-DTMVyy76.cjs} +1 -1
- package/dist/fixture.cjs +1 -1
- package/dist/fixture.mjs +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +1 -1
- package/dist/{reporter-BWjx2-ui.cjs → reporter--8bw74PI.cjs} +36 -29
- package/dist/{reporter-DGix718W.mjs → reporter-CgzB0Kq8.mjs} +36 -29
- package/dist/reporter.cjs +1 -1
- package/dist/reporter.mjs +1 -1
- package/package.json +1 -2
|
@@ -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.
|
|
24
|
+
var version = "0.13.0";
|
|
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,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_config = require("./config-
|
|
2
|
+
const require_config = require("./config-DTMVyy76.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");
|
package/dist/fixture.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
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-ChGo0Y1S.mjs";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { test as test$1 } from "@playwright/test";
|
|
4
4
|
export * from "@playwright/test";
|
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-DTMVyy76.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");
|
|
@@ -29,6 +29,7 @@ function getZipFilename(test, testId) {
|
|
|
29
29
|
return `${testId}-pw-otel.zip`;
|
|
30
30
|
}
|
|
31
31
|
const PLAYWRIGHT_TRACE_RESOURCES_DIR = "resources/";
|
|
32
|
+
const PLAYWRIGHT_TRACE_SCREENCAST_DIR = "screencast/";
|
|
32
33
|
/**
|
|
33
34
|
* Pattern to match Playwright screenshot filenames: {name}@{hex-hash}-{timestamp}.jpeg
|
|
34
35
|
* Examples: page@f06f11f7c14d6ce1060d47d79f05c154-1766833384425.jpeg
|
|
@@ -36,11 +37,12 @@ const PLAYWRIGHT_TRACE_RESOURCES_DIR = "resources/";
|
|
|
36
37
|
const PLAYWRIGHT_SCREENSHOT_PATTERN = /^.+@[a-f0-9]+-\d+\.jpe?g$/i;
|
|
37
38
|
/**
|
|
38
39
|
* Extract screenshots from a Playwright trace ZIP file.
|
|
39
|
-
*
|
|
40
|
-
*
|
|
40
|
+
* Screencast frames are named {pageGuid}-{timestamp}.jpeg
|
|
41
|
+
* (e.g., page@abc123-1766929201038.jpeg) and live in resources/ for
|
|
42
|
+
* Playwright <= 1.62 or screencast/ for Playwright >= 1.63.
|
|
41
43
|
*
|
|
42
44
|
* @param traceZipPath - Path to the Playwright trace.zip file
|
|
43
|
-
* @returns Map of filename (without
|
|
45
|
+
* @returns Map of filename (without directory prefix) to screenshot resources
|
|
44
46
|
*/
|
|
45
47
|
async function extractScreenshotsFromPlaywrightTrace(traceZipPath) {
|
|
46
48
|
const screenshots = /* @__PURE__ */ new Map();
|
|
@@ -48,23 +50,23 @@ async function extractScreenshotsFromPlaywrightTrace(traceZipPath) {
|
|
|
48
50
|
const zipBuffer = await node_fs_promises.default.readFile(traceZipPath);
|
|
49
51
|
const zipReader = new _zip_js_zip_js.ZipReader(new _zip_js_zip_js.BlobReader(new Blob([zipBuffer])));
|
|
50
52
|
const entries = await zipReader.getEntries();
|
|
51
|
-
const
|
|
52
|
-
|
|
53
|
-
if (!isFileEntry(entry)) return
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
53
|
+
const pageIdByPath = await extractScreencastPageIds(entries);
|
|
54
|
+
const screenshotEntries = entries.flatMap((entry) => {
|
|
55
|
+
if (!isFileEntry(entry)) return [];
|
|
56
|
+
const filename = screenshotResourceName(entry.filename);
|
|
57
|
+
return filename ? [{
|
|
58
|
+
entry,
|
|
59
|
+
filename
|
|
60
|
+
}] : [];
|
|
61
|
+
});
|
|
62
|
+
await Promise.all(screenshotEntries.map(async ({ entry, filename }) => {
|
|
59
63
|
const blob = await entry.getData(new _zip_js_zip_js.BlobWriter("image/jpeg"));
|
|
60
|
-
const metadata = screenshotMetadata.get(filename);
|
|
61
64
|
screenshots.set(filename, {
|
|
62
65
|
blob,
|
|
63
66
|
file: filename,
|
|
64
67
|
timestamp: extractTimestampFromFilename(filename),
|
|
65
68
|
contentType: getMimeType(filename),
|
|
66
|
-
|
|
67
|
-
pageId: metadata?.pageId ?? extractResourceIdFromFilename(filename)
|
|
69
|
+
pageId: pageIdByPath.get(entry.filename) ?? extractResourceIdFromFilename(filename)
|
|
68
70
|
});
|
|
69
71
|
}));
|
|
70
72
|
await zipReader.close();
|
|
@@ -104,38 +106,37 @@ async function addScreenshotsToZip(zipWriter, screenshots) {
|
|
|
104
106
|
}
|
|
105
107
|
function createScreenshotManifest(screenshots) {
|
|
106
108
|
return {
|
|
107
|
-
version:
|
|
109
|
+
version: 3,
|
|
108
110
|
screenshots: Array.from(screenshots.values()).map((screenshot) => ({
|
|
109
111
|
timestamp: screenshot.timestamp,
|
|
110
112
|
file: screenshot.file,
|
|
111
113
|
path: `screenshots/${screenshot.file}`,
|
|
112
114
|
contentType: screenshot.contentType,
|
|
113
|
-
contextId: screenshot.contextId,
|
|
114
115
|
pageId: screenshot.pageId
|
|
115
116
|
})).sort((a, b) => a.timestamp - b.timestamp)
|
|
116
117
|
};
|
|
117
118
|
}
|
|
118
|
-
|
|
119
|
-
|
|
119
|
+
/**
|
|
120
|
+
* Map screencast frame zip paths to the page that produced them.
|
|
121
|
+
* Playwright <= 1.62 (trace v8) references frames via `sha1` relative to
|
|
122
|
+
* resources/; Playwright >= 1.63 (trace v9+) uses a zip-relative `file` path.
|
|
123
|
+
*/
|
|
124
|
+
async function extractScreencastPageIds(entries) {
|
|
125
|
+
const pageIdByPath = /* @__PURE__ */ new Map();
|
|
120
126
|
const traceEntries = entries.filter((entry) => isFileEntry(entry) && isPlaywrightTraceEntry(entry.filename));
|
|
121
127
|
await Promise.all(traceEntries.map(async (entry) => {
|
|
122
128
|
const text = await entry.getData(new _zip_js_zip_js.TextWriter());
|
|
123
|
-
let contextId = "unknown-context";
|
|
124
129
|
for (const line of text.split("\n")) {
|
|
125
130
|
if (!line.trim()) continue;
|
|
126
131
|
const event = parseTraceEvent(line);
|
|
127
132
|
if (!event) continue;
|
|
128
|
-
if (event.type
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
if (event.type === "screencast-frame" && typeof event.sha1 === "string" && typeof event.pageId === "string") metadata.set(event.sha1, {
|
|
133
|
-
contextId,
|
|
134
|
-
pageId: event.pageId
|
|
135
|
-
});
|
|
133
|
+
if (event.type !== "screencast-frame") continue;
|
|
134
|
+
if (typeof event.pageId !== "string") continue;
|
|
135
|
+
const screenshotPath = typeof event.file === "string" ? event.file : typeof event.sha1 === "string" ? `${PLAYWRIGHT_TRACE_RESOURCES_DIR}${event.sha1}` : null;
|
|
136
|
+
if (screenshotPath) pageIdByPath.set(screenshotPath, event.pageId);
|
|
136
137
|
}
|
|
137
138
|
}));
|
|
138
|
-
return
|
|
139
|
+
return pageIdByPath;
|
|
139
140
|
}
|
|
140
141
|
function isPlaywrightTraceEntry(filename) {
|
|
141
142
|
return filename === "trace.trace" || filename.endsWith("-trace.trace");
|
|
@@ -171,6 +172,12 @@ function getMimeType(filename) {
|
|
|
171
172
|
function isFileEntry(entry) {
|
|
172
173
|
return !entry.directory;
|
|
173
174
|
}
|
|
175
|
+
function screenshotResourceName(filename) {
|
|
176
|
+
const prefix = [PLAYWRIGHT_TRACE_RESOURCES_DIR, PLAYWRIGHT_TRACE_SCREENCAST_DIR].find((directory) => filename.startsWith(directory));
|
|
177
|
+
if (!prefix) return null;
|
|
178
|
+
const name = filename.slice(prefix.length);
|
|
179
|
+
return PLAYWRIGHT_SCREENSHOT_PATTERN.test(name) ? name : null;
|
|
180
|
+
}
|
|
174
181
|
//#endregion
|
|
175
182
|
//#region src/reporter/reporter.ts
|
|
176
183
|
var PlaywrightOpentelemetryReporter = class {
|
|
@@ -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-ChGo0Y1S.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";
|
|
@@ -27,6 +27,7 @@ function getZipFilename(test, testId) {
|
|
|
27
27
|
return `${testId}-pw-otel.zip`;
|
|
28
28
|
}
|
|
29
29
|
const PLAYWRIGHT_TRACE_RESOURCES_DIR = "resources/";
|
|
30
|
+
const PLAYWRIGHT_TRACE_SCREENCAST_DIR = "screencast/";
|
|
30
31
|
/**
|
|
31
32
|
* Pattern to match Playwright screenshot filenames: {name}@{hex-hash}-{timestamp}.jpeg
|
|
32
33
|
* Examples: page@f06f11f7c14d6ce1060d47d79f05c154-1766833384425.jpeg
|
|
@@ -34,11 +35,12 @@ const PLAYWRIGHT_TRACE_RESOURCES_DIR = "resources/";
|
|
|
34
35
|
const PLAYWRIGHT_SCREENSHOT_PATTERN = /^.+@[a-f0-9]+-\d+\.jpe?g$/i;
|
|
35
36
|
/**
|
|
36
37
|
* Extract screenshots from a Playwright trace ZIP file.
|
|
37
|
-
*
|
|
38
|
-
*
|
|
38
|
+
* Screencast frames are named {pageGuid}-{timestamp}.jpeg
|
|
39
|
+
* (e.g., page@abc123-1766929201038.jpeg) and live in resources/ for
|
|
40
|
+
* Playwright <= 1.62 or screencast/ for Playwright >= 1.63.
|
|
39
41
|
*
|
|
40
42
|
* @param traceZipPath - Path to the Playwright trace.zip file
|
|
41
|
-
* @returns Map of filename (without
|
|
43
|
+
* @returns Map of filename (without directory prefix) to screenshot resources
|
|
42
44
|
*/
|
|
43
45
|
async function extractScreenshotsFromPlaywrightTrace(traceZipPath) {
|
|
44
46
|
const screenshots = /* @__PURE__ */ new Map();
|
|
@@ -46,23 +48,23 @@ async function extractScreenshotsFromPlaywrightTrace(traceZipPath) {
|
|
|
46
48
|
const zipBuffer = await fs.readFile(traceZipPath);
|
|
47
49
|
const zipReader = new ZipReader(new BlobReader(new Blob([zipBuffer])));
|
|
48
50
|
const entries = await zipReader.getEntries();
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
if (!isFileEntry(entry)) return
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
51
|
+
const pageIdByPath = await extractScreencastPageIds(entries);
|
|
52
|
+
const screenshotEntries = entries.flatMap((entry) => {
|
|
53
|
+
if (!isFileEntry(entry)) return [];
|
|
54
|
+
const filename = screenshotResourceName(entry.filename);
|
|
55
|
+
return filename ? [{
|
|
56
|
+
entry,
|
|
57
|
+
filename
|
|
58
|
+
}] : [];
|
|
59
|
+
});
|
|
60
|
+
await Promise.all(screenshotEntries.map(async ({ entry, filename }) => {
|
|
57
61
|
const blob = await entry.getData(new BlobWriter("image/jpeg"));
|
|
58
|
-
const metadata = screenshotMetadata.get(filename);
|
|
59
62
|
screenshots.set(filename, {
|
|
60
63
|
blob,
|
|
61
64
|
file: filename,
|
|
62
65
|
timestamp: extractTimestampFromFilename(filename),
|
|
63
66
|
contentType: getMimeType(filename),
|
|
64
|
-
|
|
65
|
-
pageId: metadata?.pageId ?? extractResourceIdFromFilename(filename)
|
|
67
|
+
pageId: pageIdByPath.get(entry.filename) ?? extractResourceIdFromFilename(filename)
|
|
66
68
|
});
|
|
67
69
|
}));
|
|
68
70
|
await zipReader.close();
|
|
@@ -102,38 +104,37 @@ async function addScreenshotsToZip(zipWriter, screenshots) {
|
|
|
102
104
|
}
|
|
103
105
|
function createScreenshotManifest(screenshots) {
|
|
104
106
|
return {
|
|
105
|
-
version:
|
|
107
|
+
version: 3,
|
|
106
108
|
screenshots: Array.from(screenshots.values()).map((screenshot) => ({
|
|
107
109
|
timestamp: screenshot.timestamp,
|
|
108
110
|
file: screenshot.file,
|
|
109
111
|
path: `screenshots/${screenshot.file}`,
|
|
110
112
|
contentType: screenshot.contentType,
|
|
111
|
-
contextId: screenshot.contextId,
|
|
112
113
|
pageId: screenshot.pageId
|
|
113
114
|
})).sort((a, b) => a.timestamp - b.timestamp)
|
|
114
115
|
};
|
|
115
116
|
}
|
|
116
|
-
|
|
117
|
-
|
|
117
|
+
/**
|
|
118
|
+
* Map screencast frame zip paths to the page that produced them.
|
|
119
|
+
* Playwright <= 1.62 (trace v8) references frames via `sha1` relative to
|
|
120
|
+
* resources/; Playwright >= 1.63 (trace v9+) uses a zip-relative `file` path.
|
|
121
|
+
*/
|
|
122
|
+
async function extractScreencastPageIds(entries) {
|
|
123
|
+
const pageIdByPath = /* @__PURE__ */ new Map();
|
|
118
124
|
const traceEntries = entries.filter((entry) => isFileEntry(entry) && isPlaywrightTraceEntry(entry.filename));
|
|
119
125
|
await Promise.all(traceEntries.map(async (entry) => {
|
|
120
126
|
const text = await entry.getData(new TextWriter());
|
|
121
|
-
let contextId = "unknown-context";
|
|
122
127
|
for (const line of text.split("\n")) {
|
|
123
128
|
if (!line.trim()) continue;
|
|
124
129
|
const event = parseTraceEvent(line);
|
|
125
130
|
if (!event) continue;
|
|
126
|
-
if (event.type
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
if (event.type === "screencast-frame" && typeof event.sha1 === "string" && typeof event.pageId === "string") metadata.set(event.sha1, {
|
|
131
|
-
contextId,
|
|
132
|
-
pageId: event.pageId
|
|
133
|
-
});
|
|
131
|
+
if (event.type !== "screencast-frame") continue;
|
|
132
|
+
if (typeof event.pageId !== "string") continue;
|
|
133
|
+
const screenshotPath = typeof event.file === "string" ? event.file : typeof event.sha1 === "string" ? `${PLAYWRIGHT_TRACE_RESOURCES_DIR}${event.sha1}` : null;
|
|
134
|
+
if (screenshotPath) pageIdByPath.set(screenshotPath, event.pageId);
|
|
134
135
|
}
|
|
135
136
|
}));
|
|
136
|
-
return
|
|
137
|
+
return pageIdByPath;
|
|
137
138
|
}
|
|
138
139
|
function isPlaywrightTraceEntry(filename) {
|
|
139
140
|
return filename === "trace.trace" || filename.endsWith("-trace.trace");
|
|
@@ -169,6 +170,12 @@ function getMimeType(filename) {
|
|
|
169
170
|
function isFileEntry(entry) {
|
|
170
171
|
return !entry.directory;
|
|
171
172
|
}
|
|
173
|
+
function screenshotResourceName(filename) {
|
|
174
|
+
const prefix = [PLAYWRIGHT_TRACE_RESOURCES_DIR, PLAYWRIGHT_TRACE_SCREENCAST_DIR].find((directory) => filename.startsWith(directory));
|
|
175
|
+
if (!prefix) return null;
|
|
176
|
+
const name = filename.slice(prefix.length);
|
|
177
|
+
return PLAYWRIGHT_SCREENSHOT_PATTERN.test(name) ? name : null;
|
|
178
|
+
}
|
|
172
179
|
//#endregion
|
|
173
180
|
//#region src/reporter/reporter.ts
|
|
174
181
|
var PlaywrightOpentelemetryReporter = class {
|
package/dist/reporter.cjs
CHANGED
package/dist/reporter.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "playwright-opentelemetry",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.0",
|
|
4
4
|
"description": "A reporter for Playwright that can export traces and spans in opentelemetry format.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -55,7 +55,6 @@
|
|
|
55
55
|
"@zip.js/zip.js": "^2.8.26"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
|
-
"@biomejs/biome": "2.4.16",
|
|
59
58
|
"@playwright/test": "1.61.0",
|
|
60
59
|
"@types/bun": "^1.3.14",
|
|
61
60
|
"@types/node": "^25.9.1",
|