playwright-opentelemetry 0.10.0 → 0.11.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-DKm2ymJf.mjs → config-B0-IOZF-.mjs} +52 -23
- package/dist/{config-CSm32mXS.d.cts → config-C_APEwdC.d.cts} +9 -5
- package/dist/{config-CSm32mXS.d.mts → config-C_APEwdC.d.mts} +9 -5
- package/dist/{config-DiOttOMJ.cjs → config-Csi-apHL.cjs} +52 -23
- package/dist/fixture.cjs +1 -1
- package/dist/fixture.d.cts +2 -2
- package/dist/fixture.d.mts +2 -2
- package/dist/fixture.mjs +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +1 -1
- package/dist/{reporter-BGDFTuxD.mjs → reporter-BGMoVKC7.mjs} +30 -21
- package/dist/{reporter-yOZUJcsx.cjs → reporter-DszuIYsI.cjs} +30 -21
- package/dist/reporter.cjs +1 -1
- package/dist/reporter.mjs +1 -1
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
//#region package.json
|
|
2
|
-
var version = "0.
|
|
2
|
+
var version = "0.11.0";
|
|
3
3
|
/** Generate a random 32-character hex trace ID. */
|
|
4
4
|
function generateTraceId() {
|
|
5
5
|
return Array.from({ length: 32 }, () => Math.floor(Math.random() * 16).toString(16)).join("");
|
|
@@ -189,33 +189,39 @@ function serializeSpanForAttachment(span) {
|
|
|
189
189
|
}
|
|
190
190
|
function fixtureSpanDestinations(config) {
|
|
191
191
|
const destinations = [];
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
192
|
+
for (const destination of config.playwrightTraceApiDestinations) {
|
|
193
|
+
if (!destination.url) continue;
|
|
194
|
+
destinations.push({
|
|
195
|
+
tracesEndpoint: `${destination.url}/v1/traces`,
|
|
196
|
+
headers: destination.headers
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
for (const destination of config.otlpDestinations) {
|
|
200
|
+
if (!destination.url) continue;
|
|
201
|
+
destinations.push({
|
|
202
|
+
tracesEndpoint: destination.url,
|
|
203
|
+
headers: destination.headers
|
|
204
|
+
});
|
|
205
|
+
}
|
|
200
206
|
return destinations;
|
|
201
207
|
}
|
|
202
208
|
//#endregion
|
|
203
209
|
//#region src/shared/config.ts
|
|
204
210
|
function resolvePlaywrightOpentelemetryConfig(config, options = {}) {
|
|
205
|
-
const envOtlpHeaders = parseOtlpHeaders(process.env.OTEL_EXPORTER_OTLP_HEADERS);
|
|
206
|
-
const envTraceApiHeaders = parseOtlpHeaders(process.env.PLAYWRIGHT_TRACE_API_HEADERS);
|
|
207
211
|
const debugEnv = process.env.PLAYWRIGHT_OPENTELEMETRY_DEBUG;
|
|
208
212
|
const resolvedConfig = {
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
213
|
+
otlpDestinations: resolveDestinationKind({
|
|
214
|
+
envEndpointName: "OTEL_EXPORTER_OTLP_ENDPOINT",
|
|
215
|
+
envHeadersName: "OTEL_EXPORTER_OTLP_HEADERS",
|
|
216
|
+
singular: resolveLegacyDestinationConfig(config?.otlpEndpoint, config?.otlpHeaders),
|
|
217
|
+
plural: config?.otlpEndpoints
|
|
218
|
+
}),
|
|
219
|
+
playwrightTraceApiDestinations: resolveDestinationKind({
|
|
220
|
+
envEndpointName: "PLAYWRIGHT_TRACE_API_ENDPOINT",
|
|
221
|
+
envHeadersName: "PLAYWRIGHT_TRACE_API_HEADERS",
|
|
222
|
+
singular: resolveLegacyDestinationConfig(config?.playwrightTraceApiEndpoint, config?.playwrightTraceApiHeaders),
|
|
223
|
+
plural: config?.playwrightTraceApiEndpoints
|
|
224
|
+
}),
|
|
219
225
|
storeTraceZip: config?.storeTraceZip === true,
|
|
220
226
|
trace: config?.trace ?? null,
|
|
221
227
|
propagateTraceHeaders: config?.propagateTraceHeaders ?? true,
|
|
@@ -225,10 +231,33 @@ function resolvePlaywrightOpentelemetryConfig(config, options = {}) {
|
|
|
225
231
|
return resolvedConfig;
|
|
226
232
|
}
|
|
227
233
|
function hasPlaywrightOpentelemetryDestination(config) {
|
|
228
|
-
return Boolean(config.
|
|
234
|
+
return Boolean(config.otlpDestinations.some((destination) => destination.url) || config.playwrightTraceApiDestinations.some((destination) => destination.url) || config.storeTraceZip);
|
|
235
|
+
}
|
|
236
|
+
function resolveDestinationKind(options) {
|
|
237
|
+
const envEndpoint = process.env[options.envEndpointName];
|
|
238
|
+
const envHeaders = process.env[options.envHeadersName];
|
|
239
|
+
if (envHeaders && !envEndpoint) throw new Error(`${options.envHeadersName} is set but ${options.envEndpointName} is not set.`);
|
|
240
|
+
if (envEndpoint) return [{
|
|
241
|
+
url: envEndpoint,
|
|
242
|
+
headers: parseOtlpHeaders(envHeaders)
|
|
243
|
+
}];
|
|
244
|
+
if (options.singular) return [{
|
|
245
|
+
url: options.singular.url,
|
|
246
|
+
headers: { ...options.singular.headers }
|
|
247
|
+
}];
|
|
248
|
+
return (options.plural ?? []).map((destination) => ({
|
|
249
|
+
url: destination.url,
|
|
250
|
+
headers: { ...destination.headers }
|
|
251
|
+
}));
|
|
252
|
+
}
|
|
253
|
+
function resolveLegacyDestinationConfig(destination, headers) {
|
|
254
|
+
return typeof destination === "string" ? {
|
|
255
|
+
url: destination,
|
|
256
|
+
headers
|
|
257
|
+
} : destination;
|
|
229
258
|
}
|
|
230
259
|
function getConfigurationErrorMessage() {
|
|
231
|
-
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: 'http://localhost:4317/v1/traces',\n
|
|
260
|
+
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";
|
|
232
261
|
}
|
|
233
262
|
//#endregion
|
|
234
263
|
export { createTestTraceContext as a, buildOtlpRequest as c, sendSpans as d, TRACE_CONTEXT_ATTACHMENT_NAME as i, generateSpanId as l, BROWSER_SERVICE_NAME as n, flushFixtureSpans as o, FIXTURE_SPANS_ATTACHMENT_NAME as r, shouldRetainPlaywrightTrace as s, resolvePlaywrightOpentelemetryConfig as t, generateTraceId as u };
|
|
@@ -9,11 +9,15 @@ type PlaywrightTraceOption = PlaywrightTraceMode | "retry-with-trace" | {
|
|
|
9
9
|
};
|
|
10
10
|
//#endregion
|
|
11
11
|
//#region src/shared/config.d.ts
|
|
12
|
+
type PlaywrightOpentelemetryDestination = {
|
|
13
|
+
url: string;
|
|
14
|
+
headers?: Record<string, string>;
|
|
15
|
+
};
|
|
12
16
|
interface PlaywrightOpentelemetryConfig {
|
|
13
|
-
otlpEndpoint?:
|
|
14
|
-
|
|
15
|
-
playwrightTraceApiEndpoint?:
|
|
16
|
-
|
|
17
|
+
otlpEndpoint?: PlaywrightOpentelemetryDestination;
|
|
18
|
+
otlpEndpoints?: PlaywrightOpentelemetryDestination[];
|
|
19
|
+
playwrightTraceApiEndpoint?: PlaywrightOpentelemetryDestination;
|
|
20
|
+
playwrightTraceApiEndpoints?: PlaywrightOpentelemetryDestination[];
|
|
17
21
|
storeTraceZip?: boolean;
|
|
18
22
|
trace?: PlaywrightTraceOption;
|
|
19
23
|
propagateTraceHeaders?: boolean;
|
|
@@ -23,4 +27,4 @@ interface PlaywrightOpentelemetryUseOptions {
|
|
|
23
27
|
playwrightOpentelemetry?: PlaywrightOpentelemetryConfig;
|
|
24
28
|
}
|
|
25
29
|
//#endregion
|
|
26
|
-
export {
|
|
30
|
+
export { PlaywrightTraceOption as i, PlaywrightOpentelemetryDestination as n, PlaywrightOpentelemetryUseOptions as r, PlaywrightOpentelemetryConfig as t };
|
|
@@ -9,11 +9,15 @@ type PlaywrightTraceOption = PlaywrightTraceMode | "retry-with-trace" | {
|
|
|
9
9
|
};
|
|
10
10
|
//#endregion
|
|
11
11
|
//#region src/shared/config.d.ts
|
|
12
|
+
type PlaywrightOpentelemetryDestination = {
|
|
13
|
+
url: string;
|
|
14
|
+
headers?: Record<string, string>;
|
|
15
|
+
};
|
|
12
16
|
interface PlaywrightOpentelemetryConfig {
|
|
13
|
-
otlpEndpoint?:
|
|
14
|
-
|
|
15
|
-
playwrightTraceApiEndpoint?:
|
|
16
|
-
|
|
17
|
+
otlpEndpoint?: PlaywrightOpentelemetryDestination;
|
|
18
|
+
otlpEndpoints?: PlaywrightOpentelemetryDestination[];
|
|
19
|
+
playwrightTraceApiEndpoint?: PlaywrightOpentelemetryDestination;
|
|
20
|
+
playwrightTraceApiEndpoints?: PlaywrightOpentelemetryDestination[];
|
|
17
21
|
storeTraceZip?: boolean;
|
|
18
22
|
trace?: PlaywrightTraceOption;
|
|
19
23
|
propagateTraceHeaders?: boolean;
|
|
@@ -23,4 +27,4 @@ interface PlaywrightOpentelemetryUseOptions {
|
|
|
23
27
|
playwrightOpentelemetry?: PlaywrightOpentelemetryConfig;
|
|
24
28
|
}
|
|
25
29
|
//#endregion
|
|
26
|
-
export {
|
|
30
|
+
export { PlaywrightTraceOption as i, PlaywrightOpentelemetryDestination as n, PlaywrightOpentelemetryUseOptions as r, PlaywrightOpentelemetryConfig as t };
|
|
@@ -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.11.0";
|
|
25
25
|
/** Generate a random 32-character hex trace ID. */
|
|
26
26
|
function generateTraceId() {
|
|
27
27
|
return Array.from({ length: 32 }, () => Math.floor(Math.random() * 16).toString(16)).join("");
|
|
@@ -211,33 +211,39 @@ function serializeSpanForAttachment(span) {
|
|
|
211
211
|
}
|
|
212
212
|
function fixtureSpanDestinations(config) {
|
|
213
213
|
const destinations = [];
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
214
|
+
for (const destination of config.playwrightTraceApiDestinations) {
|
|
215
|
+
if (!destination.url) continue;
|
|
216
|
+
destinations.push({
|
|
217
|
+
tracesEndpoint: `${destination.url}/v1/traces`,
|
|
218
|
+
headers: destination.headers
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
for (const destination of config.otlpDestinations) {
|
|
222
|
+
if (!destination.url) continue;
|
|
223
|
+
destinations.push({
|
|
224
|
+
tracesEndpoint: destination.url,
|
|
225
|
+
headers: destination.headers
|
|
226
|
+
});
|
|
227
|
+
}
|
|
222
228
|
return destinations;
|
|
223
229
|
}
|
|
224
230
|
//#endregion
|
|
225
231
|
//#region src/shared/config.ts
|
|
226
232
|
function resolvePlaywrightOpentelemetryConfig(config, options = {}) {
|
|
227
|
-
const envOtlpHeaders = parseOtlpHeaders(process.env.OTEL_EXPORTER_OTLP_HEADERS);
|
|
228
|
-
const envTraceApiHeaders = parseOtlpHeaders(process.env.PLAYWRIGHT_TRACE_API_HEADERS);
|
|
229
233
|
const debugEnv = process.env.PLAYWRIGHT_OPENTELEMETRY_DEBUG;
|
|
230
234
|
const resolvedConfig = {
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
235
|
+
otlpDestinations: resolveDestinationKind({
|
|
236
|
+
envEndpointName: "OTEL_EXPORTER_OTLP_ENDPOINT",
|
|
237
|
+
envHeadersName: "OTEL_EXPORTER_OTLP_HEADERS",
|
|
238
|
+
singular: resolveLegacyDestinationConfig(config?.otlpEndpoint, config?.otlpHeaders),
|
|
239
|
+
plural: config?.otlpEndpoints
|
|
240
|
+
}),
|
|
241
|
+
playwrightTraceApiDestinations: resolveDestinationKind({
|
|
242
|
+
envEndpointName: "PLAYWRIGHT_TRACE_API_ENDPOINT",
|
|
243
|
+
envHeadersName: "PLAYWRIGHT_TRACE_API_HEADERS",
|
|
244
|
+
singular: resolveLegacyDestinationConfig(config?.playwrightTraceApiEndpoint, config?.playwrightTraceApiHeaders),
|
|
245
|
+
plural: config?.playwrightTraceApiEndpoints
|
|
246
|
+
}),
|
|
241
247
|
storeTraceZip: config?.storeTraceZip === true,
|
|
242
248
|
trace: config?.trace ?? null,
|
|
243
249
|
propagateTraceHeaders: config?.propagateTraceHeaders ?? true,
|
|
@@ -247,10 +253,33 @@ function resolvePlaywrightOpentelemetryConfig(config, options = {}) {
|
|
|
247
253
|
return resolvedConfig;
|
|
248
254
|
}
|
|
249
255
|
function hasPlaywrightOpentelemetryDestination(config) {
|
|
250
|
-
return Boolean(config.
|
|
256
|
+
return Boolean(config.otlpDestinations.some((destination) => destination.url) || config.playwrightTraceApiDestinations.some((destination) => destination.url) || config.storeTraceZip);
|
|
257
|
+
}
|
|
258
|
+
function resolveDestinationKind(options) {
|
|
259
|
+
const envEndpoint = process.env[options.envEndpointName];
|
|
260
|
+
const envHeaders = process.env[options.envHeadersName];
|
|
261
|
+
if (envHeaders && !envEndpoint) throw new Error(`${options.envHeadersName} is set but ${options.envEndpointName} is not set.`);
|
|
262
|
+
if (envEndpoint) return [{
|
|
263
|
+
url: envEndpoint,
|
|
264
|
+
headers: parseOtlpHeaders(envHeaders)
|
|
265
|
+
}];
|
|
266
|
+
if (options.singular) return [{
|
|
267
|
+
url: options.singular.url,
|
|
268
|
+
headers: { ...options.singular.headers }
|
|
269
|
+
}];
|
|
270
|
+
return (options.plural ?? []).map((destination) => ({
|
|
271
|
+
url: destination.url,
|
|
272
|
+
headers: { ...destination.headers }
|
|
273
|
+
}));
|
|
274
|
+
}
|
|
275
|
+
function resolveLegacyDestinationConfig(destination, headers) {
|
|
276
|
+
return typeof destination === "string" ? {
|
|
277
|
+
url: destination,
|
|
278
|
+
headers
|
|
279
|
+
} : destination;
|
|
251
280
|
}
|
|
252
281
|
function getConfigurationErrorMessage() {
|
|
253
|
-
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: 'http://localhost:4317/v1/traces',\n
|
|
282
|
+
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";
|
|
254
283
|
}
|
|
255
284
|
//#endregion
|
|
256
285
|
Object.defineProperty(exports, "BROWSER_SERVICE_NAME", {
|
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-Csi-apHL.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.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as
|
|
1
|
+
import { i as PlaywrightTraceOption, n as PlaywrightOpentelemetryDestination, r as PlaywrightOpentelemetryUseOptions, t as PlaywrightOpentelemetryConfig } from "./config-C_APEwdC.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";
|
|
@@ -62,4 +62,4 @@ declare const test: import("@playwright/test").TestType<import("@playwright/test
|
|
|
62
62
|
_playwrightOpentelemetryReporterCheck: void;
|
|
63
63
|
}>;
|
|
64
64
|
//#endregion
|
|
65
|
-
export { type PlaywrightOpentelemetryConfig, type PlaywrightOpentelemetryUseOptions, type PlaywrightTraceOption, test };
|
|
65
|
+
export { type PlaywrightOpentelemetryConfig, type PlaywrightOpentelemetryDestination, type PlaywrightOpentelemetryUseOptions, type PlaywrightTraceOption, test };
|
package/dist/fixture.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as
|
|
1
|
+
import { i as PlaywrightTraceOption, n as PlaywrightOpentelemetryDestination, r as PlaywrightOpentelemetryUseOptions, t as PlaywrightOpentelemetryConfig } from "./config-C_APEwdC.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";
|
|
@@ -62,4 +62,4 @@ declare const test: import("@playwright/test").TestType<import("@playwright/test
|
|
|
62
62
|
_playwrightOpentelemetryReporterCheck: void;
|
|
63
63
|
}>;
|
|
64
64
|
//#endregion
|
|
65
|
-
export { type PlaywrightOpentelemetryConfig, type PlaywrightOpentelemetryUseOptions, type PlaywrightTraceOption, test };
|
|
65
|
+
export { type PlaywrightOpentelemetryConfig, type PlaywrightOpentelemetryDestination, type PlaywrightOpentelemetryUseOptions, type PlaywrightTraceOption, test };
|
package/dist/fixture.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as createTestTraceContext, l as generateSpanId, n as BROWSER_SERVICE_NAME, o as flushFixtureSpans, t as resolvePlaywrightOpentelemetryConfig } from "./config-
|
|
1
|
+
import { a as createTestTraceContext, l as generateSpanId, n as BROWSER_SERVICE_NAME, o as flushFixtureSpans, t as resolvePlaywrightOpentelemetryConfig } from "./config-B0-IOZF-.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.d.cts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { n as
|
|
1
|
+
import { i as PlaywrightTraceOption, n as PlaywrightOpentelemetryDestination, r as PlaywrightOpentelemetryUseOptions, t as PlaywrightOpentelemetryConfig } from "./config-C_APEwdC.cjs";
|
|
2
2
|
import { t as PlaywrightOpentelemetryReporter } from "./reporter-DaCojFom.cjs";
|
|
3
|
-
export { type PlaywrightOpentelemetryConfig, type PlaywrightOpentelemetryUseOptions, type PlaywrightTraceOption, PlaywrightOpentelemetryReporter as default };
|
|
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 { n as
|
|
1
|
+
import { i as PlaywrightTraceOption, n as PlaywrightOpentelemetryDestination, r as PlaywrightOpentelemetryUseOptions, t as PlaywrightOpentelemetryConfig } from "./config-C_APEwdC.mjs";
|
|
2
2
|
import { t as PlaywrightOpentelemetryReporter } from "./reporter-DaCojFom.mjs";
|
|
3
|
-
export { type PlaywrightOpentelemetryConfig, type PlaywrightOpentelemetryUseOptions, type PlaywrightTraceOption, PlaywrightOpentelemetryReporter as default };
|
|
3
|
+
export { type PlaywrightOpentelemetryConfig, type PlaywrightOpentelemetryDestination, type PlaywrightOpentelemetryUseOptions, type PlaywrightTraceOption, PlaywrightOpentelemetryReporter as default };
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { c as buildOtlpRequest, d as sendSpans, i as TRACE_CONTEXT_ATTACHMENT_NAME, l as generateSpanId, r as FIXTURE_SPANS_ATTACHMENT_NAME, s as shouldRetainPlaywrightTrace, t as resolvePlaywrightOpentelemetryConfig, u as generateTraceId } from "./config-
|
|
1
|
+
import { c as buildOtlpRequest, d as sendSpans, i as TRACE_CONTEXT_ATTACHMENT_NAME, l as generateSpanId, r as FIXTURE_SPANS_ATTACHMENT_NAME, s as shouldRetainPlaywrightTrace, t as resolvePlaywrightOpentelemetryConfig, u as generateTraceId } from "./config-B0-IOZF-.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";
|
|
@@ -243,7 +243,7 @@ var PlaywrightOpentelemetryReporter = class {
|
|
|
243
243
|
spans: testSpans,
|
|
244
244
|
config
|
|
245
245
|
});
|
|
246
|
-
if (config.storeTraceZip || config
|
|
246
|
+
if (config.storeTraceZip || hasTraceApiDestination(config)) {
|
|
247
247
|
const prepared = this.prepareTraceArtifact({
|
|
248
248
|
test,
|
|
249
249
|
spans: testSpans,
|
|
@@ -268,18 +268,24 @@ var PlaywrightOpentelemetryReporter = class {
|
|
|
268
268
|
}
|
|
269
269
|
const destinations = /* @__PURE__ */ new Map();
|
|
270
270
|
for (const batch of this.spanBatches) {
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
271
|
+
for (const destination of batch.config.otlpDestinations) {
|
|
272
|
+
if (!destination.url) continue;
|
|
273
|
+
addDestinationSpans(destinations, batch.spans, {
|
|
274
|
+
tracesEndpoint: destination.url,
|
|
275
|
+
headers: destination.headers,
|
|
276
|
+
playwrightVersion: this.playwrightVersion || "unknown",
|
|
277
|
+
debug: batch.config.debug
|
|
278
|
+
});
|
|
279
|
+
}
|
|
280
|
+
for (const destination of batch.config.playwrightTraceApiDestinations) {
|
|
281
|
+
if (!destination.url) continue;
|
|
282
|
+
addDestinationSpans(destinations, batch.spans, {
|
|
283
|
+
tracesEndpoint: `${destination.url}/v1/traces`,
|
|
284
|
+
headers: destination.headers,
|
|
285
|
+
playwrightVersion: this.playwrightVersion || "unknown",
|
|
286
|
+
debug: batch.config.debug
|
|
287
|
+
});
|
|
288
|
+
}
|
|
283
289
|
}
|
|
284
290
|
for (const destination of destinations.values()) await sendSpans(destination.spans, destination.options);
|
|
285
291
|
}
|
|
@@ -292,12 +298,12 @@ var PlaywrightOpentelemetryReporter = class {
|
|
|
292
298
|
playwrightVersion: options.playwrightVersion,
|
|
293
299
|
screenshots
|
|
294
300
|
}) : void 0;
|
|
295
|
-
const
|
|
301
|
+
const uploadPromises = options.config.playwrightTraceApiDestinations.filter((destination) => destination.url).map((destination) => this.sendScreenshotsZipToTraceApi({
|
|
296
302
|
traceId: options.traceId,
|
|
297
303
|
screenshots,
|
|
298
|
-
|
|
299
|
-
})
|
|
300
|
-
const [traceZipBlob] = await Promise.all([traceZipBlobPromise,
|
|
304
|
+
destination
|
|
305
|
+
}));
|
|
306
|
+
const [traceZipBlob] = await Promise.all([traceZipBlobPromise, ...uploadPromises]);
|
|
301
307
|
return { traceZipBlob };
|
|
302
308
|
}
|
|
303
309
|
processTestStep(test, step, parentSpanId, traceId, parentTitlePath, processedSteps, skippedStepIds) {
|
|
@@ -357,15 +363,15 @@ var PlaywrightOpentelemetryReporter = class {
|
|
|
357
363
|
return this.debug;
|
|
358
364
|
}
|
|
359
365
|
async sendScreenshotsZipToTraceApi(params) {
|
|
360
|
-
const { traceId, screenshots,
|
|
366
|
+
const { traceId, screenshots, destination } = params;
|
|
361
367
|
const screenshotsZip = await createScreenshotsZip(screenshots);
|
|
362
|
-
const screenshotUrl = `${
|
|
368
|
+
const screenshotUrl = `${destination.url}/playwright-otel-reporter/v1/screenshots.zip`;
|
|
363
369
|
const response = await fetch(screenshotUrl, {
|
|
364
370
|
method: "PUT",
|
|
365
371
|
headers: {
|
|
366
372
|
"content-type": "application/zip",
|
|
367
373
|
"x-trace-id": traceId,
|
|
368
|
-
...
|
|
374
|
+
...destination.headers
|
|
369
375
|
},
|
|
370
376
|
body: screenshotsZip
|
|
371
377
|
});
|
|
@@ -398,6 +404,9 @@ function addDestinationSpans(destinations, spans, options) {
|
|
|
398
404
|
options
|
|
399
405
|
});
|
|
400
406
|
}
|
|
407
|
+
function hasTraceApiDestination(config) {
|
|
408
|
+
return config.playwrightTraceApiDestinations.some((destination) => destination.url);
|
|
409
|
+
}
|
|
401
410
|
function readTraceContextAttachment(result, testId) {
|
|
402
411
|
const attachment = result.attachments.find((attachment) => attachment.name === TRACE_CONTEXT_ATTACHMENT_NAME);
|
|
403
412
|
if (!attachment?.body) return {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const require_config = require("./config-
|
|
1
|
+
const require_config = require("./config-Csi-apHL.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");
|
|
@@ -245,7 +245,7 @@ var PlaywrightOpentelemetryReporter = class {
|
|
|
245
245
|
spans: testSpans,
|
|
246
246
|
config
|
|
247
247
|
});
|
|
248
|
-
if (config.storeTraceZip || config
|
|
248
|
+
if (config.storeTraceZip || hasTraceApiDestination(config)) {
|
|
249
249
|
const prepared = this.prepareTraceArtifact({
|
|
250
250
|
test,
|
|
251
251
|
spans: testSpans,
|
|
@@ -270,18 +270,24 @@ var PlaywrightOpentelemetryReporter = class {
|
|
|
270
270
|
}
|
|
271
271
|
const destinations = /* @__PURE__ */ new Map();
|
|
272
272
|
for (const batch of this.spanBatches) {
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
273
|
+
for (const destination of batch.config.otlpDestinations) {
|
|
274
|
+
if (!destination.url) continue;
|
|
275
|
+
addDestinationSpans(destinations, batch.spans, {
|
|
276
|
+
tracesEndpoint: destination.url,
|
|
277
|
+
headers: destination.headers,
|
|
278
|
+
playwrightVersion: this.playwrightVersion || "unknown",
|
|
279
|
+
debug: batch.config.debug
|
|
280
|
+
});
|
|
281
|
+
}
|
|
282
|
+
for (const destination of batch.config.playwrightTraceApiDestinations) {
|
|
283
|
+
if (!destination.url) continue;
|
|
284
|
+
addDestinationSpans(destinations, batch.spans, {
|
|
285
|
+
tracesEndpoint: `${destination.url}/v1/traces`,
|
|
286
|
+
headers: destination.headers,
|
|
287
|
+
playwrightVersion: this.playwrightVersion || "unknown",
|
|
288
|
+
debug: batch.config.debug
|
|
289
|
+
});
|
|
290
|
+
}
|
|
285
291
|
}
|
|
286
292
|
for (const destination of destinations.values()) await require_config.sendSpans(destination.spans, destination.options);
|
|
287
293
|
}
|
|
@@ -294,12 +300,12 @@ var PlaywrightOpentelemetryReporter = class {
|
|
|
294
300
|
playwrightVersion: options.playwrightVersion,
|
|
295
301
|
screenshots
|
|
296
302
|
}) : void 0;
|
|
297
|
-
const
|
|
303
|
+
const uploadPromises = options.config.playwrightTraceApiDestinations.filter((destination) => destination.url).map((destination) => this.sendScreenshotsZipToTraceApi({
|
|
298
304
|
traceId: options.traceId,
|
|
299
305
|
screenshots,
|
|
300
|
-
|
|
301
|
-
})
|
|
302
|
-
const [traceZipBlob] = await Promise.all([traceZipBlobPromise,
|
|
306
|
+
destination
|
|
307
|
+
}));
|
|
308
|
+
const [traceZipBlob] = await Promise.all([traceZipBlobPromise, ...uploadPromises]);
|
|
303
309
|
return { traceZipBlob };
|
|
304
310
|
}
|
|
305
311
|
processTestStep(test, step, parentSpanId, traceId, parentTitlePath, processedSteps, skippedStepIds) {
|
|
@@ -359,15 +365,15 @@ var PlaywrightOpentelemetryReporter = class {
|
|
|
359
365
|
return this.debug;
|
|
360
366
|
}
|
|
361
367
|
async sendScreenshotsZipToTraceApi(params) {
|
|
362
|
-
const { traceId, screenshots,
|
|
368
|
+
const { traceId, screenshots, destination } = params;
|
|
363
369
|
const screenshotsZip = await createScreenshotsZip(screenshots);
|
|
364
|
-
const screenshotUrl = `${
|
|
370
|
+
const screenshotUrl = `${destination.url}/playwright-otel-reporter/v1/screenshots.zip`;
|
|
365
371
|
const response = await fetch(screenshotUrl, {
|
|
366
372
|
method: "PUT",
|
|
367
373
|
headers: {
|
|
368
374
|
"content-type": "application/zip",
|
|
369
375
|
"x-trace-id": traceId,
|
|
370
|
-
...
|
|
376
|
+
...destination.headers
|
|
371
377
|
},
|
|
372
378
|
body: screenshotsZip
|
|
373
379
|
});
|
|
@@ -400,6 +406,9 @@ function addDestinationSpans(destinations, spans, options) {
|
|
|
400
406
|
options
|
|
401
407
|
});
|
|
402
408
|
}
|
|
409
|
+
function hasTraceApiDestination(config) {
|
|
410
|
+
return config.playwrightTraceApiDestinations.some((destination) => destination.url);
|
|
411
|
+
}
|
|
403
412
|
function readTraceContextAttachment(result, testId) {
|
|
404
413
|
const attachment = result.attachments.find((attachment) => attachment.name === require_config.TRACE_CONTEXT_ATTACHMENT_NAME);
|
|
405
414
|
if (!attachment?.body) return {
|
package/dist/reporter.cjs
CHANGED
package/dist/reporter.mjs
CHANGED