playwright-opentelemetry 0.11.1 → 0.12.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-vP1SpMPF.mjs → config-Bv4dsPRO.mjs} +65 -23
- package/dist/{config-Dlhv7Jh9.cjs → config-BzW6-Ty7.cjs} +94 -22
- package/dist/{config-C_APEwdC.d.cts → config-D-3pnapc.d.cts} +1 -0
- package/dist/{config-C_APEwdC.d.mts → config-D-3pnapc.d.mts} +1 -0
- package/dist/fixture.cjs +6 -2
- package/dist/fixture.d.cts +1 -1
- package/dist/fixture.d.mts +1 -1
- package/dist/fixture.mjs +6 -2
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +1 -1
- package/dist/{reporter-SVZk1e4Y.cjs → reporter-BFqKJlKV.cjs} +22 -9
- package/dist/{reporter-CeXM-i19.mjs → reporter-DTduncL-.mjs} +22 -9
- package/dist/reporter.cjs +1 -1
- package/dist/reporter.mjs +1 -1
- package/package.json +1 -1
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
//#region package.json
|
|
2
|
-
var version = "0.
|
|
2
|
+
var version = "0.12.0";
|
|
3
|
+
const PLAYWRIGHT_TRACE_API_SOURCE_HEADER = "x-playwright-otel-source";
|
|
4
|
+
const PLAYWRIGHT_TRACE_API_SOURCE_REPORTER = "reporter";
|
|
5
|
+
function withPlaywrightTraceApiHeaders(headers) {
|
|
6
|
+
return {
|
|
7
|
+
...headers,
|
|
8
|
+
[PLAYWRIGHT_TRACE_API_SOURCE_HEADER]: PLAYWRIGHT_TRACE_API_SOURCE_REPORTER
|
|
9
|
+
};
|
|
10
|
+
}
|
|
3
11
|
/** Generate a random 32-character hex trace ID. */
|
|
4
12
|
function generateTraceId() {
|
|
5
13
|
return Array.from({ length: 32 }, () => Math.floor(Math.random() * 16).toString(16)).join("");
|
|
@@ -117,6 +125,11 @@ async function sendSpans(spans, options) {
|
|
|
117
125
|
}
|
|
118
126
|
}
|
|
119
127
|
//#endregion
|
|
128
|
+
//#region src/shared/destinations.ts
|
|
129
|
+
function filterRetainedDestinations(destinations, configTrace, shouldRetainTrace) {
|
|
130
|
+
return destinations.filter((destination) => destination.url && shouldRetainTrace(destination.trace ?? configTrace));
|
|
131
|
+
}
|
|
132
|
+
//#endregion
|
|
120
133
|
//#region src/shared/playwright-trace.ts
|
|
121
134
|
function shouldRetainPlaywrightTrace(trace, testInfo) {
|
|
122
135
|
const mode = normalizeTraceMode(trace);
|
|
@@ -132,6 +145,15 @@ function shouldRetainPlaywrightTrace(trace, testInfo) {
|
|
|
132
145
|
case "off": return false;
|
|
133
146
|
}
|
|
134
147
|
}
|
|
148
|
+
function couldRetainPlaywrightTrace(trace, testInfo) {
|
|
149
|
+
const expectedStatus = testInfo?.expectedStatus ?? "passed";
|
|
150
|
+
const failingStatus = expectedStatus === "passed" ? "failed" : "passed";
|
|
151
|
+
return shouldRetainPlaywrightTrace(trace, {
|
|
152
|
+
expectedStatus,
|
|
153
|
+
retry: testInfo?.retry,
|
|
154
|
+
status: failingStatus
|
|
155
|
+
});
|
|
156
|
+
}
|
|
135
157
|
function normalizeTraceMode(trace) {
|
|
136
158
|
const mode = typeof trace === "string" ? trace : trace?.mode ?? "off";
|
|
137
159
|
return mode === "retry-with-trace" ? "on-first-retry" : mode;
|
|
@@ -160,14 +182,37 @@ async function createTestTraceContext(testInfo) {
|
|
|
160
182
|
});
|
|
161
183
|
return traceContext;
|
|
162
184
|
}
|
|
185
|
+
async function registerExpectedTrace(traceContext, config, options) {
|
|
186
|
+
const couldRetainTrace = (trace) => couldRetainPlaywrightTrace(trace ?? options.trace, options.testInfo);
|
|
187
|
+
const destinations = filterRetainedDestinations(config.playwrightTraceApiDestinations, config.trace, couldRetainTrace);
|
|
188
|
+
if (destinations.length === 0) return;
|
|
189
|
+
const failures = await Promise.all(destinations.map(async (destination) => {
|
|
190
|
+
try {
|
|
191
|
+
const response = await fetch(`${destination.url}/playwright-otel-reporter/v1/expected-trace`, {
|
|
192
|
+
method: "PUT",
|
|
193
|
+
headers: withPlaywrightTraceApiHeaders({
|
|
194
|
+
...destination.headers,
|
|
195
|
+
"x-trace-id": traceContext.traceId
|
|
196
|
+
})
|
|
197
|
+
});
|
|
198
|
+
if (!response.ok) {
|
|
199
|
+
const error = await response.text();
|
|
200
|
+
return `${destination.url}: ${response.status} ${response.statusText}, ${error}`;
|
|
201
|
+
}
|
|
202
|
+
} catch (error) {
|
|
203
|
+
return `${destination.url}: ${error instanceof Error ? error.message : String(error)}`;
|
|
204
|
+
}
|
|
205
|
+
}));
|
|
206
|
+
for (const failure of failures) if (failure) console.warn(`Failed to register expected Playwright trace ${traceContext.traceId}: ${failure}`);
|
|
207
|
+
}
|
|
163
208
|
async function flushFixtureSpans(traceContext, config, options) {
|
|
164
209
|
if (traceContext.spans.length === 0) return;
|
|
165
|
-
|
|
166
|
-
if (config.storeTraceZip && options.testInfo) await options.testInfo.attach(FIXTURE_SPANS_ATTACHMENT_NAME, {
|
|
210
|
+
const shouldRetainTrace = (trace) => shouldRetainPlaywrightTrace(trace ?? options.trace, options.testInfo);
|
|
211
|
+
if (config.storeTraceZip && options.testInfo && shouldRetainTrace(config.trace)) await options.testInfo.attach(FIXTURE_SPANS_ATTACHMENT_NAME, {
|
|
167
212
|
body: JSON.stringify({ spans: traceContext.spans.map(serializeSpanForAttachment) }),
|
|
168
213
|
contentType: "application/json"
|
|
169
214
|
});
|
|
170
|
-
const destinations = fixtureSpanDestinations(config);
|
|
215
|
+
const destinations = fixtureSpanDestinations(config, shouldRetainTrace);
|
|
171
216
|
if (destinations.length === 0) return;
|
|
172
217
|
await Promise.all(destinations.map((destination) => sendSpans(traceContext.spans, {
|
|
173
218
|
tracesEndpoint: destination.tracesEndpoint,
|
|
@@ -187,22 +232,16 @@ function serializeSpanForAttachment(span) {
|
|
|
187
232
|
}))
|
|
188
233
|
};
|
|
189
234
|
}
|
|
190
|
-
function fixtureSpanDestinations(config) {
|
|
235
|
+
function fixtureSpanDestinations(config, shouldRetainTrace) {
|
|
191
236
|
const destinations = [];
|
|
192
|
-
for (const destination of config.playwrightTraceApiDestinations) {
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
if (!destination.url) continue;
|
|
201
|
-
destinations.push({
|
|
202
|
-
tracesEndpoint: destination.url,
|
|
203
|
-
headers: destination.headers
|
|
204
|
-
});
|
|
205
|
-
}
|
|
237
|
+
for (const destination of filterRetainedDestinations(config.playwrightTraceApiDestinations, config.trace, shouldRetainTrace)) destinations.push({
|
|
238
|
+
tracesEndpoint: `${destination.url}/v1/traces`,
|
|
239
|
+
headers: withPlaywrightTraceApiHeaders(destination.headers)
|
|
240
|
+
});
|
|
241
|
+
for (const destination of filterRetainedDestinations(config.otlpDestinations, config.trace, shouldRetainTrace)) destinations.push({
|
|
242
|
+
tracesEndpoint: destination.url,
|
|
243
|
+
headers: destination.headers
|
|
244
|
+
});
|
|
206
245
|
return destinations;
|
|
207
246
|
}
|
|
208
247
|
//#endregion
|
|
@@ -240,15 +279,18 @@ function resolveDestinationKind(options) {
|
|
|
240
279
|
let primaryDestination;
|
|
241
280
|
if (envEndpoint) primaryDestination = {
|
|
242
281
|
url: envEndpoint,
|
|
243
|
-
headers: parseOtlpHeaders(envHeaders)
|
|
282
|
+
headers: parseOtlpHeaders(envHeaders),
|
|
283
|
+
trace: null
|
|
244
284
|
};
|
|
245
285
|
else if (options.singular) primaryDestination = {
|
|
246
286
|
url: options.singular.url,
|
|
247
|
-
headers: { ...options.singular.headers }
|
|
287
|
+
headers: { ...options.singular.headers },
|
|
288
|
+
trace: options.singular.trace ?? null
|
|
248
289
|
};
|
|
249
290
|
const additionalDestinations = (options.plural ?? []).map((destination) => ({
|
|
250
291
|
url: destination.url,
|
|
251
|
-
headers: { ...destination.headers }
|
|
292
|
+
headers: { ...destination.headers },
|
|
293
|
+
trace: destination.trace ?? null
|
|
252
294
|
}));
|
|
253
295
|
return primaryDestination ? [primaryDestination, ...additionalDestinations] : additionalDestinations;
|
|
254
296
|
}
|
|
@@ -262,4 +304,4 @@ function getConfigurationErrorMessage() {
|
|
|
262
304
|
return "playwright-opentelemetry reporter requires an OTLP endpoint, trace API endpoint, or storeTraceZip to be configured.\n\nYou can configure it using environment variables:\n\n export OTEL_EXPORTER_OTLP_ENDPOINT=\"https://api.honeycomb.io\"\n export OTEL_EXPORTER_OTLP_HEADERS=\"x-honeycomb-team=YOUR_API_KEY\"\n\nOr via playwright.config.ts:\n\nimport { defineConfig } from '@playwright/test';\nimport type { PlaywrightOpentelemetryUseOptions } from 'playwright-opentelemetry/fixture';\n\nexport default defineConfig<PlaywrightOpentelemetryUseOptions>({\n use: {\n playwrightOpentelemetry: {\n otlpEndpoint: {\n url: 'http://localhost:4317/v1/traces',\n headers: {\n Authorization: 'Bearer YOUR_TOKEN',\n },\n },\n },\n },\n reporter: [['playwright-opentelemetry/reporter']],\n});\n\nNote: Environment variables take precedence over use.playwrightOpentelemetry options.\n";
|
|
263
305
|
}
|
|
264
306
|
//#endregion
|
|
265
|
-
export { createTestTraceContext as a,
|
|
307
|
+
export { createTestTraceContext as a, shouldRetainPlaywrightTrace as c, PLAYWRIGHT_TRACE_API_SOURCE_REPORTER as d, buildOtlpRequest as f, withPlaywrightTraceApiHeaders as g, sendSpans as h, TRACE_CONTEXT_ATTACHMENT_NAME as i, filterRetainedDestinations as l, generateTraceId as m, BROWSER_SERVICE_NAME as n, flushFixtureSpans as o, generateSpanId as p, FIXTURE_SPANS_ATTACHMENT_NAME as r, registerExpectedTrace as s, resolvePlaywrightOpentelemetryConfig as t, PLAYWRIGHT_TRACE_API_SOURCE_HEADER as u };
|
|
@@ -21,7 +21,15 @@ 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.12.0";
|
|
25
|
+
const PLAYWRIGHT_TRACE_API_SOURCE_HEADER = "x-playwright-otel-source";
|
|
26
|
+
const PLAYWRIGHT_TRACE_API_SOURCE_REPORTER = "reporter";
|
|
27
|
+
function withPlaywrightTraceApiHeaders(headers) {
|
|
28
|
+
return {
|
|
29
|
+
...headers,
|
|
30
|
+
[PLAYWRIGHT_TRACE_API_SOURCE_HEADER]: PLAYWRIGHT_TRACE_API_SOURCE_REPORTER
|
|
31
|
+
};
|
|
32
|
+
}
|
|
25
33
|
/** Generate a random 32-character hex trace ID. */
|
|
26
34
|
function generateTraceId() {
|
|
27
35
|
return Array.from({ length: 32 }, () => Math.floor(Math.random() * 16).toString(16)).join("");
|
|
@@ -139,6 +147,11 @@ async function sendSpans(spans, options) {
|
|
|
139
147
|
}
|
|
140
148
|
}
|
|
141
149
|
//#endregion
|
|
150
|
+
//#region src/shared/destinations.ts
|
|
151
|
+
function filterRetainedDestinations(destinations, configTrace, shouldRetainTrace) {
|
|
152
|
+
return destinations.filter((destination) => destination.url && shouldRetainTrace(destination.trace ?? configTrace));
|
|
153
|
+
}
|
|
154
|
+
//#endregion
|
|
142
155
|
//#region src/shared/playwright-trace.ts
|
|
143
156
|
function shouldRetainPlaywrightTrace(trace, testInfo) {
|
|
144
157
|
const mode = normalizeTraceMode(trace);
|
|
@@ -154,6 +167,15 @@ function shouldRetainPlaywrightTrace(trace, testInfo) {
|
|
|
154
167
|
case "off": return false;
|
|
155
168
|
}
|
|
156
169
|
}
|
|
170
|
+
function couldRetainPlaywrightTrace(trace, testInfo) {
|
|
171
|
+
const expectedStatus = testInfo?.expectedStatus ?? "passed";
|
|
172
|
+
const failingStatus = expectedStatus === "passed" ? "failed" : "passed";
|
|
173
|
+
return shouldRetainPlaywrightTrace(trace, {
|
|
174
|
+
expectedStatus,
|
|
175
|
+
retry: testInfo?.retry,
|
|
176
|
+
status: failingStatus
|
|
177
|
+
});
|
|
178
|
+
}
|
|
157
179
|
function normalizeTraceMode(trace) {
|
|
158
180
|
const mode = typeof trace === "string" ? trace : trace?.mode ?? "off";
|
|
159
181
|
return mode === "retry-with-trace" ? "on-first-retry" : mode;
|
|
@@ -182,14 +204,37 @@ async function createTestTraceContext(testInfo) {
|
|
|
182
204
|
});
|
|
183
205
|
return traceContext;
|
|
184
206
|
}
|
|
207
|
+
async function registerExpectedTrace(traceContext, config, options) {
|
|
208
|
+
const couldRetainTrace = (trace) => couldRetainPlaywrightTrace(trace ?? options.trace, options.testInfo);
|
|
209
|
+
const destinations = filterRetainedDestinations(config.playwrightTraceApiDestinations, config.trace, couldRetainTrace);
|
|
210
|
+
if (destinations.length === 0) return;
|
|
211
|
+
const failures = await Promise.all(destinations.map(async (destination) => {
|
|
212
|
+
try {
|
|
213
|
+
const response = await fetch(`${destination.url}/playwright-otel-reporter/v1/expected-trace`, {
|
|
214
|
+
method: "PUT",
|
|
215
|
+
headers: withPlaywrightTraceApiHeaders({
|
|
216
|
+
...destination.headers,
|
|
217
|
+
"x-trace-id": traceContext.traceId
|
|
218
|
+
})
|
|
219
|
+
});
|
|
220
|
+
if (!response.ok) {
|
|
221
|
+
const error = await response.text();
|
|
222
|
+
return `${destination.url}: ${response.status} ${response.statusText}, ${error}`;
|
|
223
|
+
}
|
|
224
|
+
} catch (error) {
|
|
225
|
+
return `${destination.url}: ${error instanceof Error ? error.message : String(error)}`;
|
|
226
|
+
}
|
|
227
|
+
}));
|
|
228
|
+
for (const failure of failures) if (failure) console.warn(`Failed to register expected Playwright trace ${traceContext.traceId}: ${failure}`);
|
|
229
|
+
}
|
|
185
230
|
async function flushFixtureSpans(traceContext, config, options) {
|
|
186
231
|
if (traceContext.spans.length === 0) return;
|
|
187
|
-
|
|
188
|
-
if (config.storeTraceZip && options.testInfo) await options.testInfo.attach(FIXTURE_SPANS_ATTACHMENT_NAME, {
|
|
232
|
+
const shouldRetainTrace = (trace) => shouldRetainPlaywrightTrace(trace ?? options.trace, options.testInfo);
|
|
233
|
+
if (config.storeTraceZip && options.testInfo && shouldRetainTrace(config.trace)) await options.testInfo.attach(FIXTURE_SPANS_ATTACHMENT_NAME, {
|
|
189
234
|
body: JSON.stringify({ spans: traceContext.spans.map(serializeSpanForAttachment) }),
|
|
190
235
|
contentType: "application/json"
|
|
191
236
|
});
|
|
192
|
-
const destinations = fixtureSpanDestinations(config);
|
|
237
|
+
const destinations = fixtureSpanDestinations(config, shouldRetainTrace);
|
|
193
238
|
if (destinations.length === 0) return;
|
|
194
239
|
await Promise.all(destinations.map((destination) => sendSpans(traceContext.spans, {
|
|
195
240
|
tracesEndpoint: destination.tracesEndpoint,
|
|
@@ -209,22 +254,16 @@ function serializeSpanForAttachment(span) {
|
|
|
209
254
|
}))
|
|
210
255
|
};
|
|
211
256
|
}
|
|
212
|
-
function fixtureSpanDestinations(config) {
|
|
257
|
+
function fixtureSpanDestinations(config, shouldRetainTrace) {
|
|
213
258
|
const destinations = [];
|
|
214
|
-
for (const destination of config.playwrightTraceApiDestinations) {
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
if (!destination.url) continue;
|
|
223
|
-
destinations.push({
|
|
224
|
-
tracesEndpoint: destination.url,
|
|
225
|
-
headers: destination.headers
|
|
226
|
-
});
|
|
227
|
-
}
|
|
259
|
+
for (const destination of filterRetainedDestinations(config.playwrightTraceApiDestinations, config.trace, shouldRetainTrace)) destinations.push({
|
|
260
|
+
tracesEndpoint: `${destination.url}/v1/traces`,
|
|
261
|
+
headers: withPlaywrightTraceApiHeaders(destination.headers)
|
|
262
|
+
});
|
|
263
|
+
for (const destination of filterRetainedDestinations(config.otlpDestinations, config.trace, shouldRetainTrace)) destinations.push({
|
|
264
|
+
tracesEndpoint: destination.url,
|
|
265
|
+
headers: destination.headers
|
|
266
|
+
});
|
|
228
267
|
return destinations;
|
|
229
268
|
}
|
|
230
269
|
//#endregion
|
|
@@ -262,15 +301,18 @@ function resolveDestinationKind(options) {
|
|
|
262
301
|
let primaryDestination;
|
|
263
302
|
if (envEndpoint) primaryDestination = {
|
|
264
303
|
url: envEndpoint,
|
|
265
|
-
headers: parseOtlpHeaders(envHeaders)
|
|
304
|
+
headers: parseOtlpHeaders(envHeaders),
|
|
305
|
+
trace: null
|
|
266
306
|
};
|
|
267
307
|
else if (options.singular) primaryDestination = {
|
|
268
308
|
url: options.singular.url,
|
|
269
|
-
headers: { ...options.singular.headers }
|
|
309
|
+
headers: { ...options.singular.headers },
|
|
310
|
+
trace: options.singular.trace ?? null
|
|
270
311
|
};
|
|
271
312
|
const additionalDestinations = (options.plural ?? []).map((destination) => ({
|
|
272
313
|
url: destination.url,
|
|
273
|
-
headers: { ...destination.headers }
|
|
314
|
+
headers: { ...destination.headers },
|
|
315
|
+
trace: destination.trace ?? null
|
|
274
316
|
}));
|
|
275
317
|
return primaryDestination ? [primaryDestination, ...additionalDestinations] : additionalDestinations;
|
|
276
318
|
}
|
|
@@ -296,6 +338,18 @@ Object.defineProperty(exports, "FIXTURE_SPANS_ATTACHMENT_NAME", {
|
|
|
296
338
|
return FIXTURE_SPANS_ATTACHMENT_NAME;
|
|
297
339
|
}
|
|
298
340
|
});
|
|
341
|
+
Object.defineProperty(exports, "PLAYWRIGHT_TRACE_API_SOURCE_HEADER", {
|
|
342
|
+
enumerable: true,
|
|
343
|
+
get: function() {
|
|
344
|
+
return PLAYWRIGHT_TRACE_API_SOURCE_HEADER;
|
|
345
|
+
}
|
|
346
|
+
});
|
|
347
|
+
Object.defineProperty(exports, "PLAYWRIGHT_TRACE_API_SOURCE_REPORTER", {
|
|
348
|
+
enumerable: true,
|
|
349
|
+
get: function() {
|
|
350
|
+
return PLAYWRIGHT_TRACE_API_SOURCE_REPORTER;
|
|
351
|
+
}
|
|
352
|
+
});
|
|
299
353
|
Object.defineProperty(exports, "TRACE_CONTEXT_ATTACHMENT_NAME", {
|
|
300
354
|
enumerable: true,
|
|
301
355
|
get: function() {
|
|
@@ -320,6 +374,12 @@ Object.defineProperty(exports, "createTestTraceContext", {
|
|
|
320
374
|
return createTestTraceContext;
|
|
321
375
|
}
|
|
322
376
|
});
|
|
377
|
+
Object.defineProperty(exports, "filterRetainedDestinations", {
|
|
378
|
+
enumerable: true,
|
|
379
|
+
get: function() {
|
|
380
|
+
return filterRetainedDestinations;
|
|
381
|
+
}
|
|
382
|
+
});
|
|
323
383
|
Object.defineProperty(exports, "flushFixtureSpans", {
|
|
324
384
|
enumerable: true,
|
|
325
385
|
get: function() {
|
|
@@ -338,6 +398,12 @@ Object.defineProperty(exports, "generateTraceId", {
|
|
|
338
398
|
return generateTraceId;
|
|
339
399
|
}
|
|
340
400
|
});
|
|
401
|
+
Object.defineProperty(exports, "registerExpectedTrace", {
|
|
402
|
+
enumerable: true,
|
|
403
|
+
get: function() {
|
|
404
|
+
return registerExpectedTrace;
|
|
405
|
+
}
|
|
406
|
+
});
|
|
341
407
|
Object.defineProperty(exports, "resolvePlaywrightOpentelemetryConfig", {
|
|
342
408
|
enumerable: true,
|
|
343
409
|
get: function() {
|
|
@@ -356,3 +422,9 @@ Object.defineProperty(exports, "shouldRetainPlaywrightTrace", {
|
|
|
356
422
|
return shouldRetainPlaywrightTrace;
|
|
357
423
|
}
|
|
358
424
|
});
|
|
425
|
+
Object.defineProperty(exports, "withPlaywrightTraceApiHeaders", {
|
|
426
|
+
enumerable: true,
|
|
427
|
+
get: function() {
|
|
428
|
+
return withPlaywrightTraceApiHeaders;
|
|
429
|
+
}
|
|
430
|
+
});
|
|
@@ -12,6 +12,7 @@ type PlaywrightTraceOption = PlaywrightTraceMode | "retry-with-trace" | {
|
|
|
12
12
|
type PlaywrightOpentelemetryDestination = {
|
|
13
13
|
url: string;
|
|
14
14
|
headers?: Record<string, string>;
|
|
15
|
+
trace?: PlaywrightTraceOption;
|
|
15
16
|
};
|
|
16
17
|
interface PlaywrightOpentelemetryConfig {
|
|
17
18
|
otlpEndpoint?: PlaywrightOpentelemetryDestination;
|
|
@@ -12,6 +12,7 @@ type PlaywrightTraceOption = PlaywrightTraceMode | "retry-with-trace" | {
|
|
|
12
12
|
type PlaywrightOpentelemetryDestination = {
|
|
13
13
|
url: string;
|
|
14
14
|
headers?: Record<string, string>;
|
|
15
|
+
trace?: PlaywrightTraceOption;
|
|
15
16
|
};
|
|
16
17
|
interface PlaywrightOpentelemetryConfig {
|
|
17
18
|
otlpEndpoint?: PlaywrightOpentelemetryDestination;
|
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-BzW6-Ty7.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");
|
|
@@ -530,9 +530,13 @@ function createPlaywrightOtelTest(testBase) {
|
|
|
530
530
|
testTraceContext: [async ({ playwrightOpentelemetry, trace }, use, testInfo) => {
|
|
531
531
|
const config = require_config.resolvePlaywrightOpentelemetryConfig(playwrightOpentelemetry);
|
|
532
532
|
const traceContext = await require_config.createTestTraceContext(testInfo);
|
|
533
|
+
await require_config.registerExpectedTrace(traceContext, config, {
|
|
534
|
+
trace,
|
|
535
|
+
testInfo
|
|
536
|
+
});
|
|
533
537
|
await runWithTestFetchCapture(traceContext, () => use(traceContext));
|
|
534
538
|
await require_config.flushFixtureSpans(traceContext, config, {
|
|
535
|
-
trace
|
|
539
|
+
trace,
|
|
536
540
|
testInfo
|
|
537
541
|
});
|
|
538
542
|
}, { auto: true }],
|
package/dist/fixture.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as PlaywrightTraceOption, n as PlaywrightOpentelemetryDestination, r as PlaywrightOpentelemetryUseOptions, t as PlaywrightOpentelemetryConfig } from "./config-
|
|
1
|
+
import { i as PlaywrightTraceOption, n as PlaywrightOpentelemetryDestination, r as PlaywrightOpentelemetryUseOptions, t as PlaywrightOpentelemetryConfig } from "./config-D-3pnapc.cjs";
|
|
2
2
|
import { n as SpanEvent, t as Span } from "./otel-D0ztpic2.cjs";
|
|
3
3
|
import { ConsoleMessage, Page, Request } from "@playwright/test";
|
|
4
4
|
export * from "@playwright/test";
|
package/dist/fixture.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as PlaywrightTraceOption, n as PlaywrightOpentelemetryDestination, r as PlaywrightOpentelemetryUseOptions, t as PlaywrightOpentelemetryConfig } from "./config-
|
|
1
|
+
import { i as PlaywrightTraceOption, n as PlaywrightOpentelemetryDestination, r as PlaywrightOpentelemetryUseOptions, t as PlaywrightOpentelemetryConfig } from "./config-D-3pnapc.mjs";
|
|
2
2
|
import { n as SpanEvent, t as Span } from "./otel-D0ztpic2.mjs";
|
|
3
3
|
import { ConsoleMessage, Page, Request } from "@playwright/test";
|
|
4
4
|
export * from "@playwright/test";
|
package/dist/fixture.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as createTestTraceContext,
|
|
1
|
+
import { a as createTestTraceContext, n as BROWSER_SERVICE_NAME, o as flushFixtureSpans, p as generateSpanId, s as registerExpectedTrace, t as resolvePlaywrightOpentelemetryConfig } from "./config-Bv4dsPRO.mjs";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { test as test$1 } from "@playwright/test";
|
|
4
4
|
export * from "@playwright/test";
|
|
@@ -529,9 +529,13 @@ function createPlaywrightOtelTest(testBase) {
|
|
|
529
529
|
testTraceContext: [async ({ playwrightOpentelemetry, trace }, use, testInfo) => {
|
|
530
530
|
const config = resolvePlaywrightOpentelemetryConfig(playwrightOpentelemetry);
|
|
531
531
|
const traceContext = await createTestTraceContext(testInfo);
|
|
532
|
+
await registerExpectedTrace(traceContext, config, {
|
|
533
|
+
trace,
|
|
534
|
+
testInfo
|
|
535
|
+
});
|
|
532
536
|
await runWithTestFetchCapture(traceContext, () => use(traceContext));
|
|
533
537
|
await flushFixtureSpans(traceContext, config, {
|
|
534
|
-
trace
|
|
538
|
+
trace,
|
|
535
539
|
testInfo
|
|
536
540
|
});
|
|
537
541
|
}, { auto: true }],
|
package/dist/index.cjs
CHANGED
package/dist/index.d.cts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { i as PlaywrightTraceOption, n as PlaywrightOpentelemetryDestination, r as PlaywrightOpentelemetryUseOptions, t as PlaywrightOpentelemetryConfig } from "./config-
|
|
1
|
+
import { i as PlaywrightTraceOption, n as PlaywrightOpentelemetryDestination, r as PlaywrightOpentelemetryUseOptions, t as PlaywrightOpentelemetryConfig } from "./config-D-3pnapc.cjs";
|
|
2
2
|
import { t as PlaywrightOpentelemetryReporter } from "./reporter-DaCojFom.cjs";
|
|
3
3
|
export { type PlaywrightOpentelemetryConfig, type PlaywrightOpentelemetryDestination, type PlaywrightOpentelemetryUseOptions, type PlaywrightTraceOption, PlaywrightOpentelemetryReporter as default };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { i as PlaywrightTraceOption, n as PlaywrightOpentelemetryDestination, r as PlaywrightOpentelemetryUseOptions, t as PlaywrightOpentelemetryConfig } from "./config-
|
|
1
|
+
import { i as PlaywrightTraceOption, n as PlaywrightOpentelemetryDestination, r as PlaywrightOpentelemetryUseOptions, t as PlaywrightOpentelemetryConfig } from "./config-D-3pnapc.mjs";
|
|
2
2
|
import { t as PlaywrightOpentelemetryReporter } from "./reporter-DaCojFom.mjs";
|
|
3
3
|
export { type PlaywrightOpentelemetryConfig, type PlaywrightOpentelemetryDestination, type PlaywrightOpentelemetryUseOptions, type PlaywrightTraceOption, PlaywrightOpentelemetryReporter as default };
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const require_config = require("./config-
|
|
1
|
+
const require_config = require("./config-BzW6-Ty7.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");
|
|
@@ -195,15 +195,24 @@ var PlaywrightOpentelemetryReporter = class {
|
|
|
195
195
|
onTestEnd(test, result) {
|
|
196
196
|
const config = getTestConfig(test);
|
|
197
197
|
const traceAttachment = result.attachments.find((attachment) => attachment.name === "trace" && attachment.contentType === "application/zip" && attachment.path);
|
|
198
|
-
|
|
198
|
+
const traceRetentionTestInfo = {
|
|
199
199
|
expectedStatus: test.expectedStatus,
|
|
200
200
|
retry: result.retry,
|
|
201
201
|
status: result.status
|
|
202
|
-
}
|
|
202
|
+
};
|
|
203
|
+
const shouldRetainTrace = (trace) => trace === null ? Boolean(traceAttachment) : require_config.shouldRetainPlaywrightTrace(trace, traceRetentionTestInfo);
|
|
204
|
+
const shouldStoreTraceZip = config.storeTraceZip && shouldRetainTrace(config.trace);
|
|
205
|
+
const retainedConfig = {
|
|
206
|
+
...config,
|
|
207
|
+
otlpDestinations: require_config.filterRetainedDestinations(config.otlpDestinations, config.trace, shouldRetainTrace),
|
|
208
|
+
playwrightTraceApiDestinations: require_config.filterRetainedDestinations(config.playwrightTraceApiDestinations, config.trace, shouldRetainTrace),
|
|
209
|
+
storeTraceZip: shouldStoreTraceZip
|
|
210
|
+
};
|
|
211
|
+
if (!hasPlaywrightOpentelemetryDestination(retainedConfig)) return;
|
|
203
212
|
const testId = test.id;
|
|
204
213
|
const outputDir = getTestOutputDir(test);
|
|
205
214
|
const { traceId, rootSpanId: testSpanId } = readTraceContextAttachment(result, testId);
|
|
206
|
-
const fixtureSpans =
|
|
215
|
+
const fixtureSpans = retainedConfig.storeTraceZip ? readFixtureSpansAttachment(result, testId) : [];
|
|
207
216
|
result.annotations.push({
|
|
208
217
|
type: "playwrightOpentelemetryTraceId",
|
|
209
218
|
description: traceId
|
|
@@ -243,16 +252,16 @@ var PlaywrightOpentelemetryReporter = class {
|
|
|
243
252
|
const testSpans = [span, ...stepSpans];
|
|
244
253
|
this.spanBatches.push({
|
|
245
254
|
spans: testSpans,
|
|
246
|
-
config
|
|
255
|
+
config: retainedConfig
|
|
247
256
|
});
|
|
248
|
-
if (
|
|
257
|
+
if (retainedConfig.storeTraceZip || hasTraceApiDestination(retainedConfig)) {
|
|
249
258
|
const prepared = this.prepareTraceArtifact({
|
|
250
259
|
test,
|
|
251
260
|
spans: testSpans,
|
|
252
261
|
fixtureSpans,
|
|
253
262
|
traceAttachmentPath: traceAttachment?.path,
|
|
254
263
|
traceId,
|
|
255
|
-
config,
|
|
264
|
+
config: retainedConfig,
|
|
256
265
|
playwrightVersion: this.playwrightVersion || "unknown"
|
|
257
266
|
}).catch((error) => ({ error }));
|
|
258
267
|
this.pendingTraceArtifacts.push({
|
|
@@ -283,7 +292,7 @@ var PlaywrightOpentelemetryReporter = class {
|
|
|
283
292
|
if (!destination.url) continue;
|
|
284
293
|
addDestinationSpans(destinations, batch.spans, {
|
|
285
294
|
tracesEndpoint: `${destination.url}/v1/traces`,
|
|
286
|
-
headers: destination.headers,
|
|
295
|
+
headers: require_config.withPlaywrightTraceApiHeaders(destination.headers),
|
|
287
296
|
playwrightVersion: this.playwrightVersion || "unknown",
|
|
288
297
|
debug: batch.config.debug
|
|
289
298
|
});
|
|
@@ -373,7 +382,8 @@ var PlaywrightOpentelemetryReporter = class {
|
|
|
373
382
|
headers: {
|
|
374
383
|
"content-type": "application/zip",
|
|
375
384
|
"x-trace-id": traceId,
|
|
376
|
-
...destination.headers
|
|
385
|
+
...destination.headers,
|
|
386
|
+
[require_config.PLAYWRIGHT_TRACE_API_SOURCE_HEADER]: require_config.PLAYWRIGHT_TRACE_API_SOURCE_REPORTER
|
|
377
387
|
},
|
|
378
388
|
body: screenshotsZip
|
|
379
389
|
});
|
|
@@ -409,6 +419,9 @@ function addDestinationSpans(destinations, spans, options) {
|
|
|
409
419
|
function hasTraceApiDestination(config) {
|
|
410
420
|
return config.playwrightTraceApiDestinations.some((destination) => destination.url);
|
|
411
421
|
}
|
|
422
|
+
function hasPlaywrightOpentelemetryDestination(config) {
|
|
423
|
+
return Boolean(config.storeTraceZip || config.otlpDestinations.some((destination) => destination.url) || config.playwrightTraceApiDestinations.some((destination) => destination.url));
|
|
424
|
+
}
|
|
412
425
|
function readTraceContextAttachment(result, testId) {
|
|
413
426
|
const attachment = result.attachments.find((attachment) => attachment.name === require_config.TRACE_CONTEXT_ATTACHMENT_NAME);
|
|
414
427
|
if (!attachment?.body) return {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { c as
|
|
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-Bv4dsPRO.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";
|
|
@@ -193,15 +193,24 @@ var PlaywrightOpentelemetryReporter = class {
|
|
|
193
193
|
onTestEnd(test, result) {
|
|
194
194
|
const config = getTestConfig(test);
|
|
195
195
|
const traceAttachment = result.attachments.find((attachment) => attachment.name === "trace" && attachment.contentType === "application/zip" && attachment.path);
|
|
196
|
-
|
|
196
|
+
const traceRetentionTestInfo = {
|
|
197
197
|
expectedStatus: test.expectedStatus,
|
|
198
198
|
retry: result.retry,
|
|
199
199
|
status: result.status
|
|
200
|
-
}
|
|
200
|
+
};
|
|
201
|
+
const shouldRetainTrace = (trace) => trace === null ? Boolean(traceAttachment) : shouldRetainPlaywrightTrace(trace, traceRetentionTestInfo);
|
|
202
|
+
const shouldStoreTraceZip = config.storeTraceZip && shouldRetainTrace(config.trace);
|
|
203
|
+
const retainedConfig = {
|
|
204
|
+
...config,
|
|
205
|
+
otlpDestinations: filterRetainedDestinations(config.otlpDestinations, config.trace, shouldRetainTrace),
|
|
206
|
+
playwrightTraceApiDestinations: filterRetainedDestinations(config.playwrightTraceApiDestinations, config.trace, shouldRetainTrace),
|
|
207
|
+
storeTraceZip: shouldStoreTraceZip
|
|
208
|
+
};
|
|
209
|
+
if (!hasPlaywrightOpentelemetryDestination(retainedConfig)) return;
|
|
201
210
|
const testId = test.id;
|
|
202
211
|
const outputDir = getTestOutputDir(test);
|
|
203
212
|
const { traceId, rootSpanId: testSpanId } = readTraceContextAttachment(result, testId);
|
|
204
|
-
const fixtureSpans =
|
|
213
|
+
const fixtureSpans = retainedConfig.storeTraceZip ? readFixtureSpansAttachment(result, testId) : [];
|
|
205
214
|
result.annotations.push({
|
|
206
215
|
type: "playwrightOpentelemetryTraceId",
|
|
207
216
|
description: traceId
|
|
@@ -241,16 +250,16 @@ var PlaywrightOpentelemetryReporter = class {
|
|
|
241
250
|
const testSpans = [span, ...stepSpans];
|
|
242
251
|
this.spanBatches.push({
|
|
243
252
|
spans: testSpans,
|
|
244
|
-
config
|
|
253
|
+
config: retainedConfig
|
|
245
254
|
});
|
|
246
|
-
if (
|
|
255
|
+
if (retainedConfig.storeTraceZip || hasTraceApiDestination(retainedConfig)) {
|
|
247
256
|
const prepared = this.prepareTraceArtifact({
|
|
248
257
|
test,
|
|
249
258
|
spans: testSpans,
|
|
250
259
|
fixtureSpans,
|
|
251
260
|
traceAttachmentPath: traceAttachment?.path,
|
|
252
261
|
traceId,
|
|
253
|
-
config,
|
|
262
|
+
config: retainedConfig,
|
|
254
263
|
playwrightVersion: this.playwrightVersion || "unknown"
|
|
255
264
|
}).catch((error) => ({ error }));
|
|
256
265
|
this.pendingTraceArtifacts.push({
|
|
@@ -281,7 +290,7 @@ var PlaywrightOpentelemetryReporter = class {
|
|
|
281
290
|
if (!destination.url) continue;
|
|
282
291
|
addDestinationSpans(destinations, batch.spans, {
|
|
283
292
|
tracesEndpoint: `${destination.url}/v1/traces`,
|
|
284
|
-
headers: destination.headers,
|
|
293
|
+
headers: withPlaywrightTraceApiHeaders(destination.headers),
|
|
285
294
|
playwrightVersion: this.playwrightVersion || "unknown",
|
|
286
295
|
debug: batch.config.debug
|
|
287
296
|
});
|
|
@@ -371,7 +380,8 @@ var PlaywrightOpentelemetryReporter = class {
|
|
|
371
380
|
headers: {
|
|
372
381
|
"content-type": "application/zip",
|
|
373
382
|
"x-trace-id": traceId,
|
|
374
|
-
...destination.headers
|
|
383
|
+
...destination.headers,
|
|
384
|
+
[PLAYWRIGHT_TRACE_API_SOURCE_HEADER]: PLAYWRIGHT_TRACE_API_SOURCE_REPORTER
|
|
375
385
|
},
|
|
376
386
|
body: screenshotsZip
|
|
377
387
|
});
|
|
@@ -407,6 +417,9 @@ function addDestinationSpans(destinations, spans, options) {
|
|
|
407
417
|
function hasTraceApiDestination(config) {
|
|
408
418
|
return config.playwrightTraceApiDestinations.some((destination) => destination.url);
|
|
409
419
|
}
|
|
420
|
+
function hasPlaywrightOpentelemetryDestination(config) {
|
|
421
|
+
return Boolean(config.storeTraceZip || config.otlpDestinations.some((destination) => destination.url) || config.playwrightTraceApiDestinations.some((destination) => destination.url));
|
|
422
|
+
}
|
|
410
423
|
function readTraceContextAttachment(result, testId) {
|
|
411
424
|
const attachment = result.attachments.find((attachment) => attachment.name === TRACE_CONTEXT_ATTACHMENT_NAME);
|
|
412
425
|
if (!attachment?.body) return {
|
package/dist/reporter.cjs
CHANGED
package/dist/reporter.mjs
CHANGED