playwright-opentelemetry 0.8.1 → 0.9.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.
@@ -1,489 +0,0 @@
1
- const require_config = require("./config-Z0Hqjd_6.cjs");
2
- let node_path = require("node:path");
3
- node_path = require_config.__toESM(node_path, 1);
4
- //#region src/fixture/browser-page-tracker.ts
5
- const BROWSER_PAGE_SPAN_NAME = "browser.page";
6
- const BROWSER_ROUTE_SPAN_NAME = "browser.route";
7
- const BROWSER_SERVICE_NAME = "playwright-browser";
8
- const SPAN_STATUS_CODE_UNSET$1 = 0;
9
- var BrowserPageTracker = class {
10
- traceContext;
11
- nextPageId = 1;
12
- pageStates = /* @__PURE__ */ new WeakMap();
13
- pages = /* @__PURE__ */ new Set();
14
- constructor(traceContext) {
15
- this.traceContext = traceContext;
16
- }
17
- registerPage(page) {
18
- this.stateFor(page);
19
- this.pages.add(page);
20
- }
21
- unregisterPage(page, endTime = /* @__PURE__ */ new Date()) {
22
- this.finishPageSpans(page, endTime);
23
- this.pages.delete(page);
24
- }
25
- finishAll(endTime = /* @__PURE__ */ new Date()) {
26
- for (const page of this.pages) this.finishPageSpans(page, endTime);
27
- this.pages.clear();
28
- }
29
- startDocumentNavigation(request) {
30
- if (!isMainFrameNavigationRequest(request)) return;
31
- const page = pageForRequest(request);
32
- if (!page) return;
33
- this.startDocumentPageSpan(page, request.url(), /* @__PURE__ */ new Date());
34
- }
35
- handleFrameNavigated(page, url) {
36
- const state = this.stateFor(page);
37
- const previousUrl = state.lastUrl;
38
- state.lastUrl = url;
39
- if (!previousUrl || previousUrl === "about:blank") return;
40
- if (!shouldCreateSameDocumentPageSpan(previousUrl, url, state.activeRouteSpan?.url)) return;
41
- this.startRouteSpan(page, url, previousUrl, /* @__PURE__ */ new Date());
42
- }
43
- getNetworkParent(request) {
44
- const page = pageForRequest(request);
45
- if (!page) return {
46
- spanId: this.traceContext.rootSpanId,
47
- routeAssociation: "root"
48
- };
49
- const state = this.stateFor(page);
50
- if (state.activeRouteSpan) return {
51
- spanId: state.activeRouteSpan.span.spanId,
52
- routeAssociation: "active-route"
53
- };
54
- if (state.activeDocumentSpan) return {
55
- spanId: state.activeDocumentSpan.span.spanId,
56
- routeAssociation: "active-page"
57
- };
58
- return {
59
- spanId: this.traceContext.rootSpanId,
60
- routeAssociation: "root"
61
- };
62
- }
63
- recordConsoleMessage(page, message, time = /* @__PURE__ */ new Date()) {
64
- const activeSpan = this.getActiveBrowserSpan(page);
65
- if (!activeSpan) return;
66
- const type = message.type();
67
- const attributes = {
68
- message: message.text(),
69
- "browser.console.type": type,
70
- "severity.text": consoleSeverityText(type)
71
- };
72
- const location = message.location();
73
- if (location.url) attributes["code.file.path"] = location.url;
74
- const line = consoleLocationLine(location);
75
- if (line !== void 0) attributes["code.line.number"] = line + 1;
76
- activeSpan.events.push({
77
- name: "log",
78
- time,
79
- attributes
80
- });
81
- }
82
- recordPageError(page, error, time = /* @__PURE__ */ new Date()) {
83
- const activeSpan = this.getActiveBrowserSpan(page);
84
- if (!activeSpan) return;
85
- const attributes = {};
86
- if (error.name) attributes["exception.type"] = error.name;
87
- if (error.message) attributes["exception.message"] = error.message;
88
- if (error.stack) attributes["exception.stacktrace"] = error.stack;
89
- activeSpan.events.push({
90
- name: "exception",
91
- time,
92
- attributes
93
- });
94
- }
95
- startDocumentPageSpan(page, url, startTime) {
96
- const state = this.stateFor(page);
97
- this.finishPageSpans(page, startTime);
98
- const span = this.createBrowserSpan({
99
- pageId: state.pageId,
100
- name: BROWSER_PAGE_SPAN_NAME,
101
- url,
102
- navigationType: "document",
103
- parentSpanId: this.traceContext.rootSpanId,
104
- startTime
105
- });
106
- state.activeDocumentSpan = {
107
- span,
108
- url
109
- };
110
- state.documentUrl = url;
111
- state.lastUrl = url;
112
- this.traceContext.addSpan(span);
113
- }
114
- startRouteSpan(page, url, previousUrl, startTime) {
115
- const state = this.stateFor(page);
116
- this.finishRouteSpan(state, startTime);
117
- const span = this.createBrowserSpan({
118
- pageId: state.pageId,
119
- name: BROWSER_ROUTE_SPAN_NAME,
120
- url,
121
- navigationType: "same-document",
122
- parentSpanId: state.activeDocumentSpan?.span.spanId ?? this.traceContext.rootSpanId,
123
- startTime,
124
- previousUrl,
125
- documentUrl: state.documentUrl
126
- });
127
- state.activeRouteSpan = {
128
- span,
129
- url
130
- };
131
- this.traceContext.addSpan(span);
132
- }
133
- finishPageSpans(page, endTime) {
134
- const state = this.pageStates.get(page);
135
- if (!state) return;
136
- this.finishRouteSpan(state, endTime);
137
- if (state.activeDocumentSpan) {
138
- state.activeDocumentSpan.span.endTime = endTime;
139
- state.activeDocumentSpan = void 0;
140
- }
141
- }
142
- finishRouteSpan(state, endTime) {
143
- if (state.activeRouteSpan) {
144
- state.activeRouteSpan.span.endTime = endTime;
145
- state.activeRouteSpan = void 0;
146
- }
147
- }
148
- getActiveBrowserSpan(page) {
149
- const state = this.pageStates.get(page);
150
- return state?.activeRouteSpan?.span ?? state?.activeDocumentSpan?.span;
151
- }
152
- stateFor(page) {
153
- const existing = this.pageStates.get(page);
154
- if (existing) return existing;
155
- const state = {
156
- pageId: `page-${this.nextPageId++}`,
157
- lastUrl: page.url()
158
- };
159
- this.pageStates.set(page, state);
160
- return state;
161
- }
162
- createBrowserSpan({ pageId, name, url, navigationType, parentSpanId, startTime, previousUrl, documentUrl }) {
163
- return {
164
- traceId: this.traceContext.traceId,
165
- spanId: require_config.generateSpanId(),
166
- parentSpanId,
167
- name,
168
- startTime,
169
- endTime: startTime,
170
- status: { code: SPAN_STATUS_CODE_UNSET$1 },
171
- attributes: pageAttributes({
172
- pageId,
173
- url,
174
- navigationType,
175
- previousUrl,
176
- documentUrl
177
- }),
178
- events: [],
179
- serviceName: BROWSER_SERVICE_NAME
180
- };
181
- }
182
- };
183
- function consoleSeverityText(type) {
184
- switch (type) {
185
- case "debug": return "DEBUG";
186
- case "warning": return "WARN";
187
- case "error":
188
- case "assert": return "ERROR";
189
- case "trace": return "TRACE";
190
- default: return "INFO";
191
- }
192
- }
193
- function consoleLocationLine(location) {
194
- return location.line ?? location.lineNumber;
195
- }
196
- function pageAttributes({ pageId, url, navigationType, previousUrl, documentUrl }) {
197
- const attributes = {
198
- "browser.resource.type": navigationType === "document" ? "page" : "route",
199
- "browser.page.id": pageId,
200
- "browser.page.navigation.type": navigationType,
201
- "url.full": url
202
- };
203
- try {
204
- const parsedUrl = new URL(url);
205
- attributes["url.path"] = parsedUrl.pathname;
206
- if (parsedUrl.search) attributes["url.query"] = parsedUrl.search.slice(1);
207
- } catch {}
208
- if (previousUrl) attributes["browser.route.previous_url"] = previousUrl;
209
- if (documentUrl) attributes["browser.document.url"] = documentUrl;
210
- return attributes;
211
- }
212
- function isMainFrameNavigationRequest(request) {
213
- if (!request.isNavigationRequest()) return false;
214
- try {
215
- const frame = request.frame();
216
- return frame === frame.page().mainFrame();
217
- } catch {
218
- return false;
219
- }
220
- }
221
- function pageForRequest(request) {
222
- try {
223
- return request.frame().page();
224
- } catch {
225
- return;
226
- }
227
- }
228
- function stripHash(url) {
229
- try {
230
- const parsed = new URL(url);
231
- parsed.hash = "";
232
- return parsed.toString();
233
- } catch {
234
- return url.split("#")[0] ?? url;
235
- }
236
- }
237
- function shouldCreateSameDocumentPageSpan(previousUrl, nextUrl, activePageUrl) {
238
- if (activePageUrl && stripHash(activePageUrl) === stripHash(nextUrl)) return false;
239
- return stripHash(previousUrl) !== stripHash(nextUrl);
240
- }
241
- //#endregion
242
- //#region src/fixture/network-propagator.ts
243
- function storeRequestTraceContext({ request, traceContext, parentSpanId, routeAssociation }) {
244
- const spanId = require_config.generateSpanId();
245
- traceContext.requestContexts.set(request, {
246
- traceId: traceContext.traceId,
247
- spanId,
248
- parentSpanId,
249
- routeAssociation
250
- });
251
- return spanId;
252
- }
253
- /**
254
- * Intercepts network requests to propagate trace context via traceparent header.
255
- * @param options - The propagator options
256
- */
257
- async function propagateRouteTraceHeaders({ route, request, traceId, spanId }) {
258
- const traceHeader = `00-${traceId}-${spanId}-01`;
259
- await route.fallback({ headers: {
260
- ...request.headers(),
261
- traceparent: traceHeader
262
- } });
263
- }
264
- //#endregion
265
- //#region src/fixture/reporter-config.ts
266
- const PLAYWRIGHT_OPENTELEMETRY_REPORTER_NAMES = new Set(["playwright-opentelemetry", "playwright-opentelemetry/reporter"]);
267
- const PLAYWRIGHT_OPENTELEMETRY_REPORTER_PATHS = ["dist/reporter.mjs", "dist/reporter.cjs"];
268
- const MISSING_PLAYWRIGHT_OPENTELEMETRY_REPORTER_ERROR = `playwright-opentelemetry fixture is enabled, but the reporter is missing.
269
-
270
- Add it to playwright.config.ts:
271
-
272
- reporter: [["playwright-opentelemetry/reporter"]]`;
273
- function hasPlaywrightOpentelemetryReporter(reporter) {
274
- return reporter.some(([reporterName]) => isPlaywrightOpentelemetryReporterName(reporterName));
275
- }
276
- function isPlaywrightOpentelemetryReporterName(reporterName) {
277
- if (PLAYWRIGHT_OPENTELEMETRY_REPORTER_NAMES.has(reporterName)) return true;
278
- const normalizedReporterName = reporterName.replace(/\\/g, "/");
279
- return PLAYWRIGHT_OPENTELEMETRY_REPORTER_PATHS.some((reporterPath) => normalizedReporterName === reporterPath || normalizedReporterName.endsWith(`/${reporterPath}`));
280
- }
281
- //#endregion
282
- //#region src/fixture/request-response-capture.ts
283
- /**
284
- * Detects the resource type based on Content-Type header with URL extension fallback.
285
- * This categorization mirrors Chrome DevTools Network tab behavior.
286
- *
287
- * @param contentType - The Content-Type response header value (may be null)
288
- * @param url - The request URL (used as fallback)
289
- * @returns The detected resource type
290
- */
291
- function detectResourceType(contentType, url) {
292
- if (contentType) {
293
- const mimeType = contentType.split(";")[0].trim().toLowerCase();
294
- if (mimeType !== "application/octet-stream") {
295
- if (mimeType === "text/html" || mimeType === "application/xhtml+xml") return "document";
296
- if (mimeType === "application/javascript" || mimeType === "text/javascript" || mimeType === "application/x-javascript" || mimeType === "application/ecmascript" || mimeType === "text/ecmascript" || mimeType === "module" || mimeType === "application/wasm") return "script";
297
- if (mimeType === "text/css") return "stylesheet";
298
- if (mimeType.startsWith("image/")) return "image";
299
- if (mimeType.startsWith("font/") || mimeType === "application/font-woff" || mimeType === "application/font-woff2" || mimeType === "application/x-font-ttf" || mimeType === "application/x-font-opentype") return "font";
300
- if (mimeType.startsWith("video/") || mimeType.startsWith("audio/")) return "media";
301
- if (mimeType === "application/json" || mimeType === "text/plain" || mimeType === "application/xml" || mimeType === "text/xml" || mimeType.endsWith("+json") || mimeType.endsWith("+xml")) return "fetch";
302
- }
303
- }
304
- const resourceType = detectResourceTypeFromUrl(url);
305
- if (resourceType) return resourceType;
306
- return "other";
307
- }
308
- /**
309
- * Detects resource type from URL file extension.
310
- * Used as fallback when Content-Type header is missing or generic.
311
- */
312
- function detectResourceTypeFromUrl(url) {
313
- try {
314
- const lastSegment = new URL(url).pathname.toLowerCase().split("/").pop() || "";
315
- const dotIndex = lastSegment.lastIndexOf(".");
316
- if (dotIndex === -1) return null;
317
- const extension = lastSegment.slice(dotIndex + 1);
318
- if (extension === "html" || extension === "htm" || extension === "xhtml") return "document";
319
- if (extension === "js" || extension === "mjs" || extension === "cjs" || extension === "jsx" || extension === "ts" || extension === "tsx" || extension === "wasm") return "script";
320
- if (extension === "css") return "stylesheet";
321
- if (extension === "png" || extension === "jpg" || extension === "jpeg" || extension === "gif" || extension === "svg" || extension === "webp" || extension === "ico" || extension === "bmp" || extension === "avif") return "image";
322
- if (extension === "woff" || extension === "woff2" || extension === "ttf" || extension === "otf" || extension === "eot") return "font";
323
- if (extension === "mp4" || extension === "webm" || extension === "ogg" || extension === "mp3" || extension === "wav" || extension === "m4a" || extension === "aac" || extension === "flac" || extension === "avi" || extension === "mov") return "media";
324
- if (extension === "json" || extension === "xml") return "fetch";
325
- return null;
326
- } catch {
327
- return null;
328
- }
329
- }
330
- /**
331
- * OpenTelemetry SpanKind values
332
- * @see https://opentelemetry.io/docs/specs/otel/trace/api/#spankind
333
- */
334
- const SPAN_KIND_CLIENT = 3;
335
- /**
336
- * OpenTelemetry SpanStatusCode values
337
- * @see https://opentelemetry.io/docs/specs/otel/trace/api/#set-status
338
- */
339
- const SPAN_STATUS_CODE_UNSET = 0;
340
- const SPAN_STATUS_CODE_ERROR = 2;
341
- /**
342
- * Captures request/response data and stores the complete network span in the
343
- * current test trace context. Called after the request has completed.
344
- *
345
- * @param options - The capture options
346
- */
347
- async function fixtureCaptureRequestResponse({ request, response, traceContext }) {
348
- const url = request.url();
349
- const method = request.method();
350
- const statusCode = response.status();
351
- const requestTraceContext = traceContext.requestContexts.get(request);
352
- if (!requestTraceContext) return;
353
- const timing = request.timing();
354
- const startTime = new Date(timing.startTime);
355
- const endTime = timing.responseEnd >= 0 ? new Date(timing.startTime + timing.responseEnd) : new Date(timing.startTime);
356
- const parsedUrl = new URL(url);
357
- const serverAddress = parsedUrl.hostname;
358
- const serverPort = parsedUrl.port !== "" ? Number.parseInt(parsedUrl.port, 10) : parsedUrl.protocol === "https:" ? 443 : 80;
359
- let statusCodeValue = SPAN_STATUS_CODE_UNSET;
360
- if (statusCode >= 400) statusCodeValue = SPAN_STATUS_CODE_ERROR;
361
- const resourceType = detectResourceType(await getResponseHeaderValue(response, "content-type"), url);
362
- const attributes = {
363
- "http.request.method": method,
364
- "url.full": url,
365
- "url.path": parsedUrl.pathname,
366
- "server.address": serverAddress,
367
- "server.port": serverPort,
368
- "http.response.status_code": statusCode,
369
- "http.resource.type": resourceType,
370
- "browser.request.route_association": requestTraceContext.routeAssociation
371
- };
372
- if (parsedUrl.search) attributes["url.query"] = parsedUrl.search.slice(1);
373
- if (statusCodeValue === SPAN_STATUS_CODE_ERROR) attributes["error.type"] = statusCode.toString();
374
- const networkSpan = {
375
- traceId: requestTraceContext.traceId,
376
- spanId: requestTraceContext.spanId,
377
- parentSpanId: requestTraceContext.parentSpanId,
378
- name: `HTTP ${method}`,
379
- kind: SPAN_KIND_CLIENT,
380
- startTime,
381
- endTime,
382
- status: { code: statusCodeValue },
383
- attributes,
384
- events: [],
385
- serviceName: "playwright-browser"
386
- };
387
- traceContext.addSpan(networkSpan);
388
- }
389
- async function getResponseHeaderValue(response, name) {
390
- try {
391
- return await response.headerValue(name);
392
- } catch {
393
- return null;
394
- }
395
- }
396
- //#endregion
397
- //#region src/fixture/playwright-opentelemetry-fixture.ts
398
- function createPlaywrightOtelTest(testBase) {
399
- return testBase.extend({
400
- playwrightOpentelemetry: [void 0, { option: true }],
401
- _playwrightOpentelemetryReporterCheck: [async ({}, use, workerInfo) => {
402
- if (!hasPlaywrightOpentelemetryReporter(workerInfo.config.reporter)) throw new Error(MISSING_PLAYWRIGHT_OPENTELEMETRY_REPORTER_ERROR);
403
- await use();
404
- }, {
405
- scope: "worker",
406
- auto: true
407
- }],
408
- testTraceInfo: [async ({ playwright }, use, testInfo) => {
409
- const outputDir = node_path.default.dirname(testInfo.outputDir);
410
- await use({
411
- testId: testInfo.testId,
412
- outputDir
413
- });
414
- }, { auto: true }],
415
- testTraceContext: [async ({ playwrightOpentelemetry, trace }, use, testInfo) => {
416
- const config = require_config.resolvePlaywrightOpentelemetryConfig(playwrightOpentelemetry);
417
- const traceContext = await require_config.createTestTraceContext(testInfo);
418
- await use(traceContext);
419
- await require_config.flushFixtureSpans(traceContext, config, {
420
- trace: config.trace ?? trace,
421
- testInfo
422
- });
423
- }, { auto: true }],
424
- browserPageTracker: [async ({ testTraceContext }, use) => {
425
- const tracker = new BrowserPageTracker(testTraceContext);
426
- await use(tracker);
427
- tracker.finishAll();
428
- }, { auto: true }],
429
- context: async ({ context, playwrightOpentelemetry, testTraceContext, browserPageTracker }, use) => {
430
- const config = require_config.resolvePlaywrightOpentelemetryConfig(playwrightOpentelemetry);
431
- context.route("**", async (route, request) => {
432
- browserPageTracker.startDocumentNavigation(request);
433
- const networkParent = browserPageTracker.getNetworkParent(request);
434
- const spanId = storeRequestTraceContext({
435
- request,
436
- traceContext: testTraceContext,
437
- parentSpanId: networkParent.spanId,
438
- routeAssociation: networkParent.routeAssociation
439
- });
440
- if (config.propagateTraceHeaders) {
441
- await propagateRouteTraceHeaders({
442
- route,
443
- request,
444
- traceId: testTraceContext.traceId,
445
- spanId
446
- });
447
- return;
448
- }
449
- await route.fallback();
450
- });
451
- await use(context);
452
- },
453
- page: async ({ page, testTraceContext, browserPageTracker }, use) => {
454
- browserPageTracker.registerPage(page);
455
- page.on("close", () => browserPageTracker.unregisterPage(page));
456
- page.on("console", (message) => {
457
- browserPageTracker.recordConsoleMessage(page, message);
458
- });
459
- page.on("pageerror", (error) => {
460
- browserPageTracker.recordPageError(page, error);
461
- });
462
- page.on("framenavigated", (frame) => {
463
- if (frame === page.mainFrame()) browserPageTracker.handleFrameNavigated(page, frame.url());
464
- });
465
- const pendingRequests = /* @__PURE__ */ new Map();
466
- page.on("response", (response) => {
467
- pendingRequests.set(response.request(), response);
468
- });
469
- page.on("requestfinished", async (request) => {
470
- const response = pendingRequests.get(request);
471
- pendingRequests.delete(request);
472
- if (!response) return;
473
- await fixtureCaptureRequestResponse({
474
- request,
475
- response,
476
- traceContext: testTraceContext
477
- });
478
- });
479
- await use(page);
480
- }
481
- });
482
- }
483
- //#endregion
484
- Object.defineProperty(exports, "createPlaywrightOtelTest", {
485
- enumerable: true,
486
- get: function() {
487
- return createPlaywrightOtelTest;
488
- }
489
- });
@@ -1,67 +0,0 @@
1
- import { n as PlaywrightOpentelemetryUseOptions } from "./config-Db932l_s.cjs";
2
- import { n as SpanEvent, t as Span } from "./otel-D0ztpic2.cjs";
3
- import { ConsoleMessage, Page, Request, test } from "@playwright/test";
4
-
5
- //#region src/fixture/trace-context.d.ts
6
- interface PlaywrightOtelTraceContextAttachment {
7
- traceId: string;
8
- rootSpanId: string;
9
- }
10
- type FixtureSpan = Omit<Span, "events"> & {
11
- events: SpanEvent[];
12
- };
13
- interface NetworkRequestTraceContext {
14
- traceId: string;
15
- spanId: string;
16
- parentSpanId: string;
17
- routeAssociation: "active-route" | "active-page" | "root";
18
- }
19
- interface TestTraceContext extends PlaywrightOtelTraceContextAttachment {
20
- spans: FixtureSpan[];
21
- requestContexts: WeakMap<object, NetworkRequestTraceContext>;
22
- addSpan(span: FixtureSpan): void;
23
- }
24
- //#endregion
25
- //#region src/fixture/browser-page-tracker.d.ts
26
- declare class BrowserPageTracker {
27
- private readonly traceContext;
28
- private nextPageId;
29
- private pageStates;
30
- private pages;
31
- constructor(traceContext: TestTraceContext);
32
- registerPage(page: Page): void;
33
- unregisterPage(page: Page, endTime?: Date): void;
34
- finishAll(endTime?: Date): void;
35
- startDocumentNavigation(request: Request): void;
36
- handleFrameNavigated(page: Page, url: string): void;
37
- getNetworkParent(request: Request): {
38
- spanId: string;
39
- routeAssociation: "active-route" | "active-page" | "root";
40
- };
41
- recordConsoleMessage(page: Page, message: ConsoleMessage, time?: Date): void;
42
- recordPageError(page: Page, error: Error, time?: Date): void;
43
- private startDocumentPageSpan;
44
- private startRouteSpan;
45
- private finishPageSpans;
46
- private finishRouteSpan;
47
- private getActiveBrowserSpan;
48
- private stateFor;
49
- private createBrowserSpan;
50
- }
51
- //#endregion
52
- //#region src/fixture/playwright-opentelemetry-fixture.d.ts
53
- type TestTraceInfo = {
54
- testId: string;
55
- outputDir: string;
56
- };
57
- type PlaywrightOpentelemetryFixtures = {
58
- testTraceInfo: TestTraceInfo;
59
- testTraceContext: TestTraceContext;
60
- browserPageTracker: BrowserPageTracker;
61
- };
62
- type PlaywrightOpentelemetryWorkerFixtures = {
63
- _playwrightOpentelemetryReporterCheck: void;
64
- };
65
- declare function createPlaywrightOtelTest<T extends typeof test>(testBase: T): import("@playwright/test").TestType<import("@playwright/test").PlaywrightTestArgs & import("@playwright/test").PlaywrightTestOptions & PlaywrightOpentelemetryUseOptions & PlaywrightOpentelemetryFixtures, import("@playwright/test").PlaywrightWorkerArgs & import("@playwright/test").PlaywrightWorkerOptions & PlaywrightOpentelemetryWorkerFixtures>;
66
- //#endregion
67
- export { BrowserPageTracker as n, TestTraceContext as r, createPlaywrightOtelTest as t };
@@ -1,67 +0,0 @@
1
- import { n as PlaywrightOpentelemetryUseOptions } from "./config-Db932l_s.mjs";
2
- import { n as SpanEvent, t as Span } from "./otel-D0ztpic2.mjs";
3
- import { ConsoleMessage, Page, Request, test } from "@playwright/test";
4
-
5
- //#region src/fixture/trace-context.d.ts
6
- interface PlaywrightOtelTraceContextAttachment {
7
- traceId: string;
8
- rootSpanId: string;
9
- }
10
- type FixtureSpan = Omit<Span, "events"> & {
11
- events: SpanEvent[];
12
- };
13
- interface NetworkRequestTraceContext {
14
- traceId: string;
15
- spanId: string;
16
- parentSpanId: string;
17
- routeAssociation: "active-route" | "active-page" | "root";
18
- }
19
- interface TestTraceContext extends PlaywrightOtelTraceContextAttachment {
20
- spans: FixtureSpan[];
21
- requestContexts: WeakMap<object, NetworkRequestTraceContext>;
22
- addSpan(span: FixtureSpan): void;
23
- }
24
- //#endregion
25
- //#region src/fixture/browser-page-tracker.d.ts
26
- declare class BrowserPageTracker {
27
- private readonly traceContext;
28
- private nextPageId;
29
- private pageStates;
30
- private pages;
31
- constructor(traceContext: TestTraceContext);
32
- registerPage(page: Page): void;
33
- unregisterPage(page: Page, endTime?: Date): void;
34
- finishAll(endTime?: Date): void;
35
- startDocumentNavigation(request: Request): void;
36
- handleFrameNavigated(page: Page, url: string): void;
37
- getNetworkParent(request: Request): {
38
- spanId: string;
39
- routeAssociation: "active-route" | "active-page" | "root";
40
- };
41
- recordConsoleMessage(page: Page, message: ConsoleMessage, time?: Date): void;
42
- recordPageError(page: Page, error: Error, time?: Date): void;
43
- private startDocumentPageSpan;
44
- private startRouteSpan;
45
- private finishPageSpans;
46
- private finishRouteSpan;
47
- private getActiveBrowserSpan;
48
- private stateFor;
49
- private createBrowserSpan;
50
- }
51
- //#endregion
52
- //#region src/fixture/playwright-opentelemetry-fixture.d.ts
53
- type TestTraceInfo = {
54
- testId: string;
55
- outputDir: string;
56
- };
57
- type PlaywrightOpentelemetryFixtures = {
58
- testTraceInfo: TestTraceInfo;
59
- testTraceContext: TestTraceContext;
60
- browserPageTracker: BrowserPageTracker;
61
- };
62
- type PlaywrightOpentelemetryWorkerFixtures = {
63
- _playwrightOpentelemetryReporterCheck: void;
64
- };
65
- declare function createPlaywrightOtelTest<T extends typeof test>(testBase: T): import("@playwright/test").TestType<import("@playwright/test").PlaywrightTestArgs & import("@playwright/test").PlaywrightTestOptions & PlaywrightOpentelemetryUseOptions & PlaywrightOpentelemetryFixtures, import("@playwright/test").PlaywrightWorkerArgs & import("@playwright/test").PlaywrightWorkerOptions & PlaywrightOpentelemetryWorkerFixtures>;
66
- //#endregion
67
- export { BrowserPageTracker as n, TestTraceContext as r, createPlaywrightOtelTest as t };