playwright-opentelemetry 0.15.0 → 0.16.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/fixture.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_screenshots_zip = require("./screenshots-zip-C3N3xvp7.cjs");
2
+ const require_screenshots_zip = require("./screenshots-zip-B6_DJ3oU.cjs");
3
3
  let node_fs_promises = require("node:fs/promises");
4
4
  node_fs_promises = require_screenshots_zip.__toESM(node_fs_promises, 1);
5
5
  let node_path = require("node:path");
@@ -1,5 +1,5 @@
1
- import { n as Span, r as SpanEvent } from "./reporter-CLzdtg6G.cjs";
2
- import { i as PlaywrightTraceOption, n as PlaywrightOpentelemetryDestination, r as PlaywrightOpentelemetryUseOptions, t as PlaywrightOpentelemetryConfig } from "./index-DFY22ysa.cjs";
1
+ import { i as PlaywrightTraceOption, n as PlaywrightOpentelemetryDestination, r as PlaywrightOpentelemetryUseOptions, t as PlaywrightOpentelemetryConfig } from "./config-DFY22ysa.cjs";
2
+ import { n as SpanEvent, t as Span } from "./otel-D0ztpic2.cjs";
3
3
  import { BrowserContext, ConsoleMessage, Page, Request } from "@playwright/test";
4
4
  export * from "@playwright/test";
5
5
 
@@ -1,5 +1,5 @@
1
- import { n as Span, r as SpanEvent } from "./reporter-CLzdtg6G.mjs";
2
- import { i as PlaywrightTraceOption, n as PlaywrightOpentelemetryDestination, r as PlaywrightOpentelemetryUseOptions, t as PlaywrightOpentelemetryConfig } from "./index-DFY22ysa.mjs";
1
+ import { i as PlaywrightTraceOption, n as PlaywrightOpentelemetryDestination, r as PlaywrightOpentelemetryUseOptions, t as PlaywrightOpentelemetryConfig } from "./config-DFY22ysa.mjs";
2
+ import { n as SpanEvent, t as Span } from "./otel-D0ztpic2.mjs";
3
3
  import { BrowserContext, ConsoleMessage, Page, Request } from "@playwright/test";
4
4
  export * from "@playwright/test";
5
5
 
package/dist/fixture.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { a as supportsScreencastScreenshots, d as flushFixtureSpans, f as registerExpectedTrace, h as filterRetainedDestinations, m as shouldRetainPlaywrightTrace, o as resolvePlaywrightOpentelemetryConfig, p as couldRetainPlaywrightTrace, r as createScreenshotsZip, s as BROWSER_SERVICE_NAME, t as SCREENSHOTS_ATTACHMENT_NAME, u as createTestTraceContext, y as generateSpanId } from "./screenshots-zip-BzI9Jpan.mjs";
1
+ import { a as supportsScreencastScreenshots, d as flushFixtureSpans, f as registerExpectedTrace, h as filterRetainedDestinations, m as shouldRetainPlaywrightTrace, o as resolvePlaywrightOpentelemetryConfig, p as couldRetainPlaywrightTrace, r as createScreenshotsZip, s as BROWSER_SERVICE_NAME, t as SCREENSHOTS_ATTACHMENT_NAME, u as createTestTraceContext, y as generateSpanId } from "./screenshots-zip-Cp3l4YRU.mjs";
2
2
  import fs from "node:fs/promises";
3
3
  import path from "node:path";
4
4
  import { test as test$1 } from "@playwright/test";
package/dist/index.cjs CHANGED
@@ -1,4 +1,4 @@
1
1
  //#region src/index.ts
2
- var src_default = require("./reporter-Dnqohjyo.cjs").PlaywrightOpentelemetryReporter;
2
+ var src_default = require("./reporter-Z2WIipcT.cjs").PlaywrightOpentelemetryReporter;
3
3
  //#endregion
4
4
  module.exports = src_default;
package/dist/index.d.cts CHANGED
@@ -1,3 +1,3 @@
1
- import { t as PlaywrightOpentelemetryReporter } from "./reporter-CLzdtg6G.cjs";
2
- import { i as PlaywrightTraceOption, n as PlaywrightOpentelemetryDestination, r as PlaywrightOpentelemetryUseOptions, t as PlaywrightOpentelemetryConfig } from "./index-DFY22ysa.cjs";
1
+ import { i as PlaywrightTraceOption, n as PlaywrightOpentelemetryDestination, r as PlaywrightOpentelemetryUseOptions, t as PlaywrightOpentelemetryConfig } from "./config-DFY22ysa.cjs";
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 { t as PlaywrightOpentelemetryReporter } from "./reporter-CLzdtg6G.mjs";
2
- import { i as PlaywrightTraceOption, n as PlaywrightOpentelemetryDestination, r as PlaywrightOpentelemetryUseOptions, t as PlaywrightOpentelemetryConfig } from "./index-DFY22ysa.mjs";
1
+ import { i as PlaywrightTraceOption, n as PlaywrightOpentelemetryDestination, r as PlaywrightOpentelemetryUseOptions, t as PlaywrightOpentelemetryConfig } from "./config-DFY22ysa.mjs";
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
- import { t as PlaywrightOpentelemetryReporter } from "./reporter-CMGLSTHi.mjs";
1
+ import { t as PlaywrightOpentelemetryReporter } from "./reporter-Owv9goRm.mjs";
2
2
  //#region src/index.ts
3
3
  var src_default = PlaywrightOpentelemetryReporter;
4
4
  //#endregion
@@ -0,0 +1,25 @@
1
+ //#region src/shared/otel.d.ts
2
+ type SpanAttributeValue = string | number | boolean | string[];
3
+ type SpanEvent = {
4
+ name: string;
5
+ time: Date;
6
+ attributes?: Record<string, SpanAttributeValue>;
7
+ };
8
+ type Span = {
9
+ traceId: string;
10
+ spanId: string;
11
+ parentSpanId?: string;
12
+ name: string;
13
+ startTime: Date;
14
+ endTime: Date;
15
+ attributes: Record<string, SpanAttributeValue>;
16
+ events?: SpanEvent[];
17
+ status?: {
18
+ code: number;
19
+ message?: string;
20
+ };
21
+ kind?: number; /** Service name for this span (if different from default). */
22
+ serviceName?: string;
23
+ };
24
+ //#endregion
25
+ export { SpanEvent as n, Span as t };
@@ -0,0 +1,25 @@
1
+ //#region src/shared/otel.d.ts
2
+ type SpanAttributeValue = string | number | boolean | string[];
3
+ type SpanEvent = {
4
+ name: string;
5
+ time: Date;
6
+ attributes?: Record<string, SpanAttributeValue>;
7
+ };
8
+ type Span = {
9
+ traceId: string;
10
+ spanId: string;
11
+ parentSpanId?: string;
12
+ name: string;
13
+ startTime: Date;
14
+ endTime: Date;
15
+ attributes: Record<string, SpanAttributeValue>;
16
+ events?: SpanEvent[];
17
+ status?: {
18
+ code: number;
19
+ message?: string;
20
+ };
21
+ kind?: number; /** Service name for this span (if different from default). */
22
+ serviceName?: string;
23
+ };
24
+ //#endregion
25
+ export { SpanEvent as n, Span as t };
@@ -1,29 +1,5 @@
1
1
  import { FullConfig, FullResult, Reporter, Suite, TestCase, TestResult, TestStep } from "@playwright/test/reporter";
2
2
 
3
- //#region src/shared/otel.d.ts
4
- type SpanAttributeValue = string | number | boolean | string[];
5
- type SpanEvent = {
6
- name: string;
7
- time: Date;
8
- attributes?: Record<string, SpanAttributeValue>;
9
- };
10
- type Span = {
11
- traceId: string;
12
- spanId: string;
13
- parentSpanId?: string;
14
- name: string;
15
- startTime: Date;
16
- endTime: Date;
17
- attributes: Record<string, SpanAttributeValue>;
18
- events?: SpanEvent[];
19
- status?: {
20
- code: number;
21
- message?: string;
22
- };
23
- kind?: number; /** Service name for this span (if different from default). */
24
- serviceName?: string;
25
- };
26
- //#endregion
27
3
  //#region src/reporter/reporter.d.ts
28
4
  declare class PlaywrightOpentelemetryReporter implements Reporter {
29
5
  private spanBatches;
@@ -46,4 +22,4 @@ declare class PlaywrightOpentelemetryReporter implements Reporter {
46
22
  private sendScreenshotsZipToTraceApi;
47
23
  }
48
24
  //#endregion
49
- export { Span as n, SpanEvent as r, PlaywrightOpentelemetryReporter as t };
25
+ export { PlaywrightOpentelemetryReporter as t };
@@ -1,29 +1,5 @@
1
1
  import { FullConfig, FullResult, Reporter, Suite, TestCase, TestResult, TestStep } from "@playwright/test/reporter";
2
2
 
3
- //#region src/shared/otel.d.ts
4
- type SpanAttributeValue = string | number | boolean | string[];
5
- type SpanEvent = {
6
- name: string;
7
- time: Date;
8
- attributes?: Record<string, SpanAttributeValue>;
9
- };
10
- type Span = {
11
- traceId: string;
12
- spanId: string;
13
- parentSpanId?: string;
14
- name: string;
15
- startTime: Date;
16
- endTime: Date;
17
- attributes: Record<string, SpanAttributeValue>;
18
- events?: SpanEvent[];
19
- status?: {
20
- code: number;
21
- message?: string;
22
- };
23
- kind?: number; /** Service name for this span (if different from default). */
24
- serviceName?: string;
25
- };
26
- //#endregion
27
3
  //#region src/reporter/reporter.d.ts
28
4
  declare class PlaywrightOpentelemetryReporter implements Reporter {
29
5
  private spanBatches;
@@ -46,4 +22,4 @@ declare class PlaywrightOpentelemetryReporter implements Reporter {
46
22
  private sendScreenshotsZipToTraceApi;
47
23
  }
48
24
  //#endregion
49
- export { Span as n, SpanEvent as r, PlaywrightOpentelemetryReporter as t };
25
+ export { PlaywrightOpentelemetryReporter as t };
@@ -1,4 +1,4 @@
1
- import { S as withPlaywrightTraceApiHeaders, _ as PLAYWRIGHT_TRACE_API_SOURCE_REPORTER, a as supportsScreencastScreenshots, b as generateTraceId, c as FIXTURE_SPANS_ATTACHMENT_NAME, g as PLAYWRIGHT_TRACE_API_SOURCE_HEADER, h as filterRetainedDestinations, i as readScreenshotsZip, l as TRACE_CONTEXT_ATTACHMENT_NAME, m as shouldRetainPlaywrightTrace, n as addScreenshotsToZip, o as resolvePlaywrightOpentelemetryConfig, r as createScreenshotsZip, v as buildOtlpRequest, x as sendSpans, y as generateSpanId } from "./screenshots-zip-BzI9Jpan.mjs";
1
+ import { S as withPlaywrightTraceApiHeaders, _ as PLAYWRIGHT_TRACE_API_SOURCE_REPORTER, a as supportsScreencastScreenshots, b as generateTraceId, c as FIXTURE_SPANS_ATTACHMENT_NAME, g as PLAYWRIGHT_TRACE_API_SOURCE_HEADER, h as filterRetainedDestinations, i as readScreenshotsZip, l as TRACE_CONTEXT_ATTACHMENT_NAME, m as shouldRetainPlaywrightTrace, n as addScreenshotsToZip, o as resolvePlaywrightOpentelemetryConfig, r as createScreenshotsZip, v as buildOtlpRequest, x as sendSpans, y as generateSpanId } from "./screenshots-zip-Cp3l4YRU.mjs";
2
2
  import fs from "node:fs/promises";
3
3
  import path from "node:path";
4
4
  import { BlobReader, BlobWriter, TextWriter, ZipReader, ZipWriter } from "@zip.js/zip.js";
@@ -270,16 +270,11 @@ var PlaywrightOpentelemetryReporter = class {
270
270
  }
271
271
  }
272
272
  async onEnd(_result) {
273
- for (const artifact of this.pendingTraceArtifacts) {
274
- const prepared = await artifact.prepared;
275
- if ("error" in prepared) throw prepared.error;
276
- if (prepared.traceZipBlob) await writeTraceZip(artifact.outputDir, artifact.test, prepared.traceZipBlob);
277
- }
278
273
  const destinations = /* @__PURE__ */ new Map();
279
274
  for (const batch of this.spanBatches) {
280
275
  for (const destination of batch.config.otlpDestinations) {
281
276
  if (!destination.url) continue;
282
- addDestinationSpans(destinations, batch.spans, {
277
+ addDestinationSpans(destinations, batch.spans, "otlp", {
283
278
  tracesEndpoint: destination.url,
284
279
  headers: destination.headers,
285
280
  playwrightVersion: this.playwrightVersion || "unknown",
@@ -288,7 +283,7 @@ var PlaywrightOpentelemetryReporter = class {
288
283
  }
289
284
  for (const destination of batch.config.playwrightTraceApiDestinations) {
290
285
  if (!destination.url) continue;
291
- addDestinationSpans(destinations, batch.spans, {
286
+ addDestinationSpans(destinations, batch.spans, "trace-api", {
292
287
  tracesEndpoint: `${destination.url}/v1/traces`,
293
288
  headers: withPlaywrightTraceApiHeaders(destination.headers),
294
289
  playwrightVersion: this.playwrightVersion || "unknown",
@@ -296,7 +291,25 @@ var PlaywrightOpentelemetryReporter = class {
296
291
  });
297
292
  }
298
293
  }
299
- for (const destination of destinations.values()) await sendSpans(destination.spans, destination.options);
294
+ const sendFailures = (await Promise.all([...destinations.values()].map(async (destination) => {
295
+ try {
296
+ await sendSpans(destination.spans, destination.options);
297
+ return [];
298
+ } catch (error) {
299
+ return [{
300
+ destination,
301
+ error
302
+ }];
303
+ }
304
+ }))).flat();
305
+ for (const failure of sendFailures) console.warn(`Failed to send spans to ${failure.destination.options.tracesEndpoint}: ${errorMessage(failure.error)}`);
306
+ for (const artifact of this.pendingTraceArtifacts) {
307
+ const prepared = await artifact.prepared;
308
+ if ("error" in prepared) throw prepared.error;
309
+ if (prepared.traceZipBlob) await writeTraceZip(artifact.outputDir, artifact.test, prepared.traceZipBlob);
310
+ }
311
+ const traceApiFailure = sendFailures.find((failure) => failure.destination.kind === "trace-api");
312
+ if (traceApiFailure) throw traceApiFailure.error;
300
313
  }
301
314
  async prepareTraceArtifact(options) {
302
315
  const screenshots = await readTestScreenshots(options);
@@ -414,7 +427,11 @@ function getTestOutputDir(test) {
414
427
  if (!outputDir) throw new Error(`No outputDir found for test "${test.id}"`);
415
428
  return outputDir;
416
429
  }
417
- function addDestinationSpans(destinations, spans, options) {
430
+ function errorMessage(error) {
431
+ if (error instanceof Error) return error.message;
432
+ return String(error);
433
+ }
434
+ function addDestinationSpans(destinations, spans, kind, options) {
418
435
  const key = JSON.stringify(options);
419
436
  const destination = destinations.get(key);
420
437
  if (destination) {
@@ -422,6 +439,7 @@ function addDestinationSpans(destinations, spans, options) {
422
439
  return;
423
440
  }
424
441
  destinations.set(key, {
442
+ kind,
425
443
  spans: [...spans],
426
444
  options
427
445
  });
@@ -1,4 +1,4 @@
1
- const require_screenshots_zip = require("./screenshots-zip-C3N3xvp7.cjs");
1
+ const require_screenshots_zip = require("./screenshots-zip-B6_DJ3oU.cjs");
2
2
  let node_fs_promises = require("node:fs/promises");
3
3
  node_fs_promises = require_screenshots_zip.__toESM(node_fs_promises, 1);
4
4
  let node_path = require("node:path");
@@ -272,16 +272,11 @@ var PlaywrightOpentelemetryReporter = class {
272
272
  }
273
273
  }
274
274
  async onEnd(_result) {
275
- for (const artifact of this.pendingTraceArtifacts) {
276
- const prepared = await artifact.prepared;
277
- if ("error" in prepared) throw prepared.error;
278
- if (prepared.traceZipBlob) await writeTraceZip(artifact.outputDir, artifact.test, prepared.traceZipBlob);
279
- }
280
275
  const destinations = /* @__PURE__ */ new Map();
281
276
  for (const batch of this.spanBatches) {
282
277
  for (const destination of batch.config.otlpDestinations) {
283
278
  if (!destination.url) continue;
284
- addDestinationSpans(destinations, batch.spans, {
279
+ addDestinationSpans(destinations, batch.spans, "otlp", {
285
280
  tracesEndpoint: destination.url,
286
281
  headers: destination.headers,
287
282
  playwrightVersion: this.playwrightVersion || "unknown",
@@ -290,7 +285,7 @@ var PlaywrightOpentelemetryReporter = class {
290
285
  }
291
286
  for (const destination of batch.config.playwrightTraceApiDestinations) {
292
287
  if (!destination.url) continue;
293
- addDestinationSpans(destinations, batch.spans, {
288
+ addDestinationSpans(destinations, batch.spans, "trace-api", {
294
289
  tracesEndpoint: `${destination.url}/v1/traces`,
295
290
  headers: require_screenshots_zip.withPlaywrightTraceApiHeaders(destination.headers),
296
291
  playwrightVersion: this.playwrightVersion || "unknown",
@@ -298,7 +293,25 @@ var PlaywrightOpentelemetryReporter = class {
298
293
  });
299
294
  }
300
295
  }
301
- for (const destination of destinations.values()) await require_screenshots_zip.sendSpans(destination.spans, destination.options);
296
+ const sendFailures = (await Promise.all([...destinations.values()].map(async (destination) => {
297
+ try {
298
+ await require_screenshots_zip.sendSpans(destination.spans, destination.options);
299
+ return [];
300
+ } catch (error) {
301
+ return [{
302
+ destination,
303
+ error
304
+ }];
305
+ }
306
+ }))).flat();
307
+ for (const failure of sendFailures) console.warn(`Failed to send spans to ${failure.destination.options.tracesEndpoint}: ${errorMessage(failure.error)}`);
308
+ for (const artifact of this.pendingTraceArtifacts) {
309
+ const prepared = await artifact.prepared;
310
+ if ("error" in prepared) throw prepared.error;
311
+ if (prepared.traceZipBlob) await writeTraceZip(artifact.outputDir, artifact.test, prepared.traceZipBlob);
312
+ }
313
+ const traceApiFailure = sendFailures.find((failure) => failure.destination.kind === "trace-api");
314
+ if (traceApiFailure) throw traceApiFailure.error;
302
315
  }
303
316
  async prepareTraceArtifact(options) {
304
317
  const screenshots = await readTestScreenshots(options);
@@ -416,7 +429,11 @@ function getTestOutputDir(test) {
416
429
  if (!outputDir) throw new Error(`No outputDir found for test "${test.id}"`);
417
430
  return outputDir;
418
431
  }
419
- function addDestinationSpans(destinations, spans, options) {
432
+ function errorMessage(error) {
433
+ if (error instanceof Error) return error.message;
434
+ return String(error);
435
+ }
436
+ function addDestinationSpans(destinations, spans, kind, options) {
420
437
  const key = JSON.stringify(options);
421
438
  const destination = destinations.get(key);
422
439
  if (destination) {
@@ -424,6 +441,7 @@ function addDestinationSpans(destinations, spans, options) {
424
441
  return;
425
442
  }
426
443
  destinations.set(key, {
444
+ kind,
427
445
  spans: [...spans],
428
446
  options
429
447
  });
package/dist/reporter.cjs CHANGED
@@ -1,4 +1,4 @@
1
1
  //#region src/reporter/index.ts
2
- var reporter_default = require("./reporter-Dnqohjyo.cjs").PlaywrightOpentelemetryReporter;
2
+ var reporter_default = require("./reporter-Z2WIipcT.cjs").PlaywrightOpentelemetryReporter;
3
3
  //#endregion
4
4
  module.exports = reporter_default;
@@ -1,2 +1,2 @@
1
- import { t as PlaywrightOpentelemetryReporter } from "./reporter-CLzdtg6G.cjs";
1
+ import { t as PlaywrightOpentelemetryReporter } from "./reporter-DaCojFom.cjs";
2
2
  export = PlaywrightOpentelemetryReporter;
@@ -1,2 +1,2 @@
1
- import { t as PlaywrightOpentelemetryReporter } from "./reporter-CLzdtg6G.mjs";
1
+ import { t as PlaywrightOpentelemetryReporter } from "./reporter-DaCojFom.mjs";
2
2
  export { PlaywrightOpentelemetryReporter as default };
package/dist/reporter.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { t as PlaywrightOpentelemetryReporter } from "./reporter-CMGLSTHi.mjs";
1
+ import { t as PlaywrightOpentelemetryReporter } from "./reporter-Owv9goRm.mjs";
2
2
  //#region src/reporter/index.ts
3
3
  var reporter_default = PlaywrightOpentelemetryReporter;
4
4
  //#endregion
@@ -22,7 +22,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
22
22
  //#endregion
23
23
  let _zip_js_zip_js = require("@zip.js/zip.js");
24
24
  //#region package.json
25
- var version = "0.15.0";
25
+ var version = "0.16.0";
26
26
  const PLAYWRIGHT_TRACE_API_SOURCE_HEADER = "x-playwright-otel-source";
27
27
  const PLAYWRIGHT_TRACE_API_SOURCE_REPORTER = "reporter";
28
28
  function withPlaywrightTraceApiHeaders(headers) {
@@ -1,6 +1,6 @@
1
1
  import { BlobReader, BlobWriter, TextWriter, ZipReader, ZipWriter } from "@zip.js/zip.js";
2
2
  //#region package.json
3
- var version = "0.15.0";
3
+ var version = "0.16.0";
4
4
  const PLAYWRIGHT_TRACE_API_SOURCE_HEADER = "x-playwright-otel-source";
5
5
  const PLAYWRIGHT_TRACE_API_SOURCE_REPORTER = "reporter";
6
6
  function withPlaywrightTraceApiHeaders(headers) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "playwright-opentelemetry",
3
- "version": "0.15.0",
3
+ "version": "0.16.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",