playwright-opentelemetry 0.13.5 → 0.13.6
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-CiYAieDt.mjs → config-CNqq0WLw.mjs} +48 -17
- package/dist/{config-C-inwZvX.cjs → config-knifnJua.cjs} +48 -17
- package/dist/fixture.cjs +1 -1
- package/dist/fixture.mjs +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +1 -1
- package/dist/{reporter-_hqajn5O.cjs → reporter-CzP9uSdk.cjs} +1 -1
- package/dist/{reporter-DV6yWUMU.mjs → reporter-DCwosQMM.mjs} +1 -1
- 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.13.
|
|
2
|
+
var version = "0.13.6";
|
|
3
3
|
const PLAYWRIGHT_TRACE_API_SOURCE_HEADER = "x-playwright-otel-source";
|
|
4
4
|
const PLAYWRIGHT_TRACE_API_SOURCE_REPORTER = "reporter";
|
|
5
5
|
function withPlaywrightTraceApiHeaders(headers) {
|
|
@@ -111,17 +111,37 @@ async function sendSpans(spans, options) {
|
|
|
111
111
|
if (spans.length === 0) return;
|
|
112
112
|
const body = JSON.stringify(buildOtlpRequest(spans, options.playwrightVersion));
|
|
113
113
|
if (options.debug) console.log("Sending spans to", options.tracesEndpoint);
|
|
114
|
-
const
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
114
|
+
for (const retryDelayMs of [...options.retryDelaysMs ?? [], null]) {
|
|
115
|
+
const failure = await postSpans(body, options);
|
|
116
|
+
if (!failure) return;
|
|
117
|
+
if (retryDelayMs === null || !failure.retryable) throw failure.error;
|
|
118
|
+
await new Promise((resolve) => setTimeout(resolve, retryDelayMs));
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
async function postSpans(body, options) {
|
|
122
|
+
try {
|
|
123
|
+
const response = await fetch(options.tracesEndpoint, {
|
|
124
|
+
method: "POST",
|
|
125
|
+
body,
|
|
126
|
+
headers: {
|
|
127
|
+
"content-type": "application/json",
|
|
128
|
+
...options.headers || {}
|
|
129
|
+
},
|
|
130
|
+
...options.requestTimeoutMs && { signal: AbortSignal.timeout(options.requestTimeoutMs) }
|
|
131
|
+
});
|
|
132
|
+
if (response.ok) return null;
|
|
123
133
|
const error = await response.text();
|
|
124
|
-
|
|
134
|
+
const isThrottled = response.status === 429;
|
|
135
|
+
const isServerError = response.status >= 500;
|
|
136
|
+
return {
|
|
137
|
+
error: /* @__PURE__ */ new Error(`Failed to send spans: ${response.status} ${response.statusText}, ${error}`),
|
|
138
|
+
retryable: isThrottled || isServerError
|
|
139
|
+
};
|
|
140
|
+
} catch (error) {
|
|
141
|
+
return {
|
|
142
|
+
error,
|
|
143
|
+
retryable: true
|
|
144
|
+
};
|
|
125
145
|
}
|
|
126
146
|
}
|
|
127
147
|
//#endregion
|
|
@@ -163,6 +183,8 @@ function normalizeTraceMode(trace) {
|
|
|
163
183
|
const TRACE_CONTEXT_ATTACHMENT_NAME = "playwright-opentelemetry-trace-context";
|
|
164
184
|
const FIXTURE_SPANS_ATTACHMENT_NAME = "playwright-opentelemetry-fixture-spans";
|
|
165
185
|
const BROWSER_SERVICE_NAME = "playwright-browser";
|
|
186
|
+
const FIXTURE_EXPORT_RETRY_DELAYS_MS = [250, 750];
|
|
187
|
+
const FIXTURE_EXPORT_REQUEST_TIMEOUT_MS = 3e3;
|
|
166
188
|
async function createTestTraceContext(testInfo) {
|
|
167
189
|
const traceContext = {
|
|
168
190
|
traceId: generateTraceId(),
|
|
@@ -214,12 +236,21 @@ async function flushFixtureSpans(traceContext, config, options) {
|
|
|
214
236
|
});
|
|
215
237
|
const destinations = fixtureSpanDestinations(config, shouldRetainTrace);
|
|
216
238
|
if (destinations.length === 0) return;
|
|
217
|
-
await Promise.all(destinations.map((destination) =>
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
239
|
+
const failures = await Promise.all(destinations.map(async (destination) => {
|
|
240
|
+
try {
|
|
241
|
+
await sendSpans(traceContext.spans, {
|
|
242
|
+
tracesEndpoint: destination.tracesEndpoint,
|
|
243
|
+
headers: destination.headers,
|
|
244
|
+
playwrightVersion: "unknown",
|
|
245
|
+
debug: config.debug,
|
|
246
|
+
retryDelaysMs: FIXTURE_EXPORT_RETRY_DELAYS_MS,
|
|
247
|
+
requestTimeoutMs: FIXTURE_EXPORT_REQUEST_TIMEOUT_MS
|
|
248
|
+
});
|
|
249
|
+
} catch (error) {
|
|
250
|
+
return `${destination.tracesEndpoint}: ${error instanceof Error ? error.message : String(error)}`;
|
|
251
|
+
}
|
|
252
|
+
}));
|
|
253
|
+
for (const failure of failures) if (failure) console.warn(`Failed to export fixture spans for trace ${traceContext.traceId}: ${failure}`);
|
|
223
254
|
}
|
|
224
255
|
function serializeSpanForAttachment(span) {
|
|
225
256
|
return {
|
|
@@ -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.13.
|
|
24
|
+
var version = "0.13.6";
|
|
25
25
|
const PLAYWRIGHT_TRACE_API_SOURCE_HEADER = "x-playwright-otel-source";
|
|
26
26
|
const PLAYWRIGHT_TRACE_API_SOURCE_REPORTER = "reporter";
|
|
27
27
|
function withPlaywrightTraceApiHeaders(headers) {
|
|
@@ -133,17 +133,37 @@ async function sendSpans(spans, options) {
|
|
|
133
133
|
if (spans.length === 0) return;
|
|
134
134
|
const body = JSON.stringify(buildOtlpRequest(spans, options.playwrightVersion));
|
|
135
135
|
if (options.debug) console.log("Sending spans to", options.tracesEndpoint);
|
|
136
|
-
const
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
136
|
+
for (const retryDelayMs of [...options.retryDelaysMs ?? [], null]) {
|
|
137
|
+
const failure = await postSpans(body, options);
|
|
138
|
+
if (!failure) return;
|
|
139
|
+
if (retryDelayMs === null || !failure.retryable) throw failure.error;
|
|
140
|
+
await new Promise((resolve) => setTimeout(resolve, retryDelayMs));
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
async function postSpans(body, options) {
|
|
144
|
+
try {
|
|
145
|
+
const response = await fetch(options.tracesEndpoint, {
|
|
146
|
+
method: "POST",
|
|
147
|
+
body,
|
|
148
|
+
headers: {
|
|
149
|
+
"content-type": "application/json",
|
|
150
|
+
...options.headers || {}
|
|
151
|
+
},
|
|
152
|
+
...options.requestTimeoutMs && { signal: AbortSignal.timeout(options.requestTimeoutMs) }
|
|
153
|
+
});
|
|
154
|
+
if (response.ok) return null;
|
|
145
155
|
const error = await response.text();
|
|
146
|
-
|
|
156
|
+
const isThrottled = response.status === 429;
|
|
157
|
+
const isServerError = response.status >= 500;
|
|
158
|
+
return {
|
|
159
|
+
error: /* @__PURE__ */ new Error(`Failed to send spans: ${response.status} ${response.statusText}, ${error}`),
|
|
160
|
+
retryable: isThrottled || isServerError
|
|
161
|
+
};
|
|
162
|
+
} catch (error) {
|
|
163
|
+
return {
|
|
164
|
+
error,
|
|
165
|
+
retryable: true
|
|
166
|
+
};
|
|
147
167
|
}
|
|
148
168
|
}
|
|
149
169
|
//#endregion
|
|
@@ -185,6 +205,8 @@ function normalizeTraceMode(trace) {
|
|
|
185
205
|
const TRACE_CONTEXT_ATTACHMENT_NAME = "playwright-opentelemetry-trace-context";
|
|
186
206
|
const FIXTURE_SPANS_ATTACHMENT_NAME = "playwright-opentelemetry-fixture-spans";
|
|
187
207
|
const BROWSER_SERVICE_NAME = "playwright-browser";
|
|
208
|
+
const FIXTURE_EXPORT_RETRY_DELAYS_MS = [250, 750];
|
|
209
|
+
const FIXTURE_EXPORT_REQUEST_TIMEOUT_MS = 3e3;
|
|
188
210
|
async function createTestTraceContext(testInfo) {
|
|
189
211
|
const traceContext = {
|
|
190
212
|
traceId: generateTraceId(),
|
|
@@ -236,12 +258,21 @@ async function flushFixtureSpans(traceContext, config, options) {
|
|
|
236
258
|
});
|
|
237
259
|
const destinations = fixtureSpanDestinations(config, shouldRetainTrace);
|
|
238
260
|
if (destinations.length === 0) return;
|
|
239
|
-
await Promise.all(destinations.map((destination) =>
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
261
|
+
const failures = await Promise.all(destinations.map(async (destination) => {
|
|
262
|
+
try {
|
|
263
|
+
await sendSpans(traceContext.spans, {
|
|
264
|
+
tracesEndpoint: destination.tracesEndpoint,
|
|
265
|
+
headers: destination.headers,
|
|
266
|
+
playwrightVersion: "unknown",
|
|
267
|
+
debug: config.debug,
|
|
268
|
+
retryDelaysMs: FIXTURE_EXPORT_RETRY_DELAYS_MS,
|
|
269
|
+
requestTimeoutMs: FIXTURE_EXPORT_REQUEST_TIMEOUT_MS
|
|
270
|
+
});
|
|
271
|
+
} catch (error) {
|
|
272
|
+
return `${destination.tracesEndpoint}: ${error instanceof Error ? error.message : String(error)}`;
|
|
273
|
+
}
|
|
274
|
+
}));
|
|
275
|
+
for (const failure of failures) if (failure) console.warn(`Failed to export fixture spans for trace ${traceContext.traceId}: ${failure}`);
|
|
245
276
|
}
|
|
246
277
|
function serializeSpanForAttachment(span) {
|
|
247
278
|
return {
|
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-knifnJua.cjs");
|
|
3
3
|
let node_path = require("node:path");
|
|
4
4
|
node_path = require_config.__toESM(node_path, 1);
|
|
5
5
|
let _playwright_test = require("@playwright/test");
|
package/dist/fixture.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as createTestTraceContext, n as BROWSER_SERVICE_NAME, o as flushFixtureSpans, p as generateSpanId, s as registerExpectedTrace, t as resolvePlaywrightOpentelemetryConfig } from "./config-
|
|
1
|
+
import { a as createTestTraceContext, n as BROWSER_SERVICE_NAME, o as flushFixtureSpans, p as generateSpanId, s as registerExpectedTrace, t as resolvePlaywrightOpentelemetryConfig } from "./config-CNqq0WLw.mjs";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { test as test$1 } from "@playwright/test";
|
|
4
4
|
export * from "@playwright/test";
|
package/dist/index.cjs
CHANGED
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { c as shouldRetainPlaywrightTrace, d as PLAYWRIGHT_TRACE_API_SOURCE_REPORTER, f as buildOtlpRequest, g as withPlaywrightTraceApiHeaders, h as sendSpans, i as TRACE_CONTEXT_ATTACHMENT_NAME, l as filterRetainedDestinations, m as generateTraceId, p as generateSpanId, r as FIXTURE_SPANS_ATTACHMENT_NAME, t as resolvePlaywrightOpentelemetryConfig, u as PLAYWRIGHT_TRACE_API_SOURCE_HEADER } from "./config-
|
|
1
|
+
import { c as shouldRetainPlaywrightTrace, d as PLAYWRIGHT_TRACE_API_SOURCE_REPORTER, f as buildOtlpRequest, g as withPlaywrightTraceApiHeaders, h as sendSpans, i as TRACE_CONTEXT_ATTACHMENT_NAME, l as filterRetainedDestinations, m as generateTraceId, p as generateSpanId, r as FIXTURE_SPANS_ATTACHMENT_NAME, t as resolvePlaywrightOpentelemetryConfig, u as PLAYWRIGHT_TRACE_API_SOURCE_HEADER } from "./config-CNqq0WLw.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";
|
package/dist/reporter.cjs
CHANGED
package/dist/reporter.mjs
CHANGED