playwright-opentelemetry 0.8.1 → 0.10.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-Db932l_s.d.cts → config-CSm32mXS.d.cts} +0 -1
- package/dist/{config-Db932l_s.d.mts → config-CSm32mXS.d.mts} +0 -1
- package/dist/{config-uXd4Im5F.mjs → config-DKm2ymJf.mjs} +7 -10
- package/dist/{config-Z0Hqjd_6.cjs → config-DiOttOMJ.cjs} +12 -9
- package/dist/fixture.cjs +597 -3
- package/dist/fixture.d.cts +51 -3
- package/dist/fixture.d.mts +51 -3
- package/dist/fixture.mjs +596 -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-CM4W2jxM.mjs → reporter-BGDFTuxD.mjs} +5 -8
- package/dist/{reporter-DKlbB_nC.cjs → reporter-yOZUJcsx.cjs} +5 -8
- package/dist/reporter.cjs +1 -1
- package/dist/reporter.mjs +1 -1
- package/package.json +1 -7
- package/dist/fixture/factory.cjs +0 -3
- package/dist/fixture/factory.d.cts +0 -2
- package/dist/fixture/factory.d.mts +0 -2
- package/dist/fixture/factory.mjs +0 -2
- package/dist/playwright-opentelemetry-fixture-2vhqZLmh.mjs +0 -483
- package/dist/playwright-opentelemetry-fixture-BQXmeAcf.cjs +0 -489
- package/dist/playwright-opentelemetry-fixture-Dx53ybJd.d.cts +0 -67
- package/dist/playwright-opentelemetry-fixture-xHcfAc5d.d.mts +0 -67
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
//#region package.json
|
|
2
|
-
var version = "0.
|
|
3
|
-
//#endregion
|
|
4
|
-
//#region src/shared/otel.ts
|
|
2
|
+
var version = "0.10.0";
|
|
5
3
|
/** Generate a random 32-character hex trace ID. */
|
|
6
4
|
function generateTraceId() {
|
|
7
5
|
return Array.from({ length: 32 }, () => Math.floor(Math.random() * 16).toString(16)).join("");
|
|
@@ -89,10 +87,10 @@ function buildResourceSpan(spans, serviceName, playwrightVersion) {
|
|
|
89
87
|
}]
|
|
90
88
|
};
|
|
91
89
|
}
|
|
92
|
-
function buildOtlpRequest(spans,
|
|
90
|
+
function buildOtlpRequest(spans, playwrightVersion) {
|
|
93
91
|
const spansByService = /* @__PURE__ */ new Map();
|
|
94
92
|
for (const span of spans) {
|
|
95
|
-
const spanServiceName = span.serviceName ??
|
|
93
|
+
const spanServiceName = span.serviceName ?? "playwright-tests";
|
|
96
94
|
const serviceSpans = spansByService.get(spanServiceName);
|
|
97
95
|
if (serviceSpans) serviceSpans.push(span);
|
|
98
96
|
else spansByService.set(spanServiceName, [span]);
|
|
@@ -103,7 +101,7 @@ function buildOtlpRequest(spans, serviceName, playwrightVersion) {
|
|
|
103
101
|
}
|
|
104
102
|
async function sendSpans(spans, options) {
|
|
105
103
|
if (spans.length === 0) return;
|
|
106
|
-
const body = JSON.stringify(buildOtlpRequest(spans, options.
|
|
104
|
+
const body = JSON.stringify(buildOtlpRequest(spans, options.playwrightVersion));
|
|
107
105
|
if (options.debug) console.log("Sending spans to", options.tracesEndpoint);
|
|
108
106
|
const response = await fetch(options.tracesEndpoint, {
|
|
109
107
|
method: "POST",
|
|
@@ -142,6 +140,7 @@ function normalizeTraceMode(trace) {
|
|
|
142
140
|
//#region src/fixture/trace-context.ts
|
|
143
141
|
const TRACE_CONTEXT_ATTACHMENT_NAME = "playwright-opentelemetry-trace-context";
|
|
144
142
|
const FIXTURE_SPANS_ATTACHMENT_NAME = "playwright-opentelemetry-fixture-spans";
|
|
143
|
+
const BROWSER_SERVICE_NAME = "playwright-browser";
|
|
145
144
|
async function createTestTraceContext(testInfo) {
|
|
146
145
|
const traceContext = {
|
|
147
146
|
traceId: generateTraceId(),
|
|
@@ -173,7 +172,6 @@ async function flushFixtureSpans(traceContext, config, options) {
|
|
|
173
172
|
await Promise.all(destinations.map((destination) => sendSpans(traceContext.spans, {
|
|
174
173
|
tracesEndpoint: destination.tracesEndpoint,
|
|
175
174
|
headers: destination.headers,
|
|
176
|
-
serviceName: "playwright-browser",
|
|
177
175
|
playwrightVersion: "unknown",
|
|
178
176
|
debug: config.debug
|
|
179
177
|
})));
|
|
@@ -221,7 +219,6 @@ function resolvePlaywrightOpentelemetryConfig(config, options = {}) {
|
|
|
221
219
|
storeTraceZip: config?.storeTraceZip === true,
|
|
222
220
|
trace: config?.trace ?? null,
|
|
223
221
|
propagateTraceHeaders: config?.propagateTraceHeaders ?? true,
|
|
224
|
-
serviceName: process.env.OTEL_SERVICE_NAME || config?.serviceName || "playwright-tests",
|
|
225
222
|
debug: debugEnv === void 0 ? config?.debug ?? false : debugEnv === "1" || debugEnv === "true"
|
|
226
223
|
};
|
|
227
224
|
if (options.requireDestination === true && !hasPlaywrightOpentelemetryDestination(resolvedConfig)) throw new Error(getConfigurationErrorMessage());
|
|
@@ -231,7 +228,7 @@ function hasPlaywrightOpentelemetryDestination(config) {
|
|
|
231
228
|
return Boolean(config.otlpEndpoint || config.playwrightTraceApiEndpoint || config.storeTraceZip);
|
|
232
229
|
}
|
|
233
230
|
function getConfigurationErrorMessage() {
|
|
234
|
-
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
|
|
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 otlpHeaders: {\n Authorization: 'Bearer YOUR_TOKEN',\n },\n },\n },\n reporter: [['playwright-opentelemetry/reporter']],\n});\n\nNote: Environment variables take precedence over use.playwrightOpentelemetry options.\n";
|
|
235
232
|
}
|
|
236
233
|
//#endregion
|
|
237
|
-
export {
|
|
234
|
+
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 };
|
|
@@ -21,9 +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.
|
|
25
|
-
//#endregion
|
|
26
|
-
//#region src/shared/otel.ts
|
|
24
|
+
var version = "0.10.0";
|
|
27
25
|
/** Generate a random 32-character hex trace ID. */
|
|
28
26
|
function generateTraceId() {
|
|
29
27
|
return Array.from({ length: 32 }, () => Math.floor(Math.random() * 16).toString(16)).join("");
|
|
@@ -111,10 +109,10 @@ function buildResourceSpan(spans, serviceName, playwrightVersion) {
|
|
|
111
109
|
}]
|
|
112
110
|
};
|
|
113
111
|
}
|
|
114
|
-
function buildOtlpRequest(spans,
|
|
112
|
+
function buildOtlpRequest(spans, playwrightVersion) {
|
|
115
113
|
const spansByService = /* @__PURE__ */ new Map();
|
|
116
114
|
for (const span of spans) {
|
|
117
|
-
const spanServiceName = span.serviceName ??
|
|
115
|
+
const spanServiceName = span.serviceName ?? "playwright-tests";
|
|
118
116
|
const serviceSpans = spansByService.get(spanServiceName);
|
|
119
117
|
if (serviceSpans) serviceSpans.push(span);
|
|
120
118
|
else spansByService.set(spanServiceName, [span]);
|
|
@@ -125,7 +123,7 @@ function buildOtlpRequest(spans, serviceName, playwrightVersion) {
|
|
|
125
123
|
}
|
|
126
124
|
async function sendSpans(spans, options) {
|
|
127
125
|
if (spans.length === 0) return;
|
|
128
|
-
const body = JSON.stringify(buildOtlpRequest(spans, options.
|
|
126
|
+
const body = JSON.stringify(buildOtlpRequest(spans, options.playwrightVersion));
|
|
129
127
|
if (options.debug) console.log("Sending spans to", options.tracesEndpoint);
|
|
130
128
|
const response = await fetch(options.tracesEndpoint, {
|
|
131
129
|
method: "POST",
|
|
@@ -164,6 +162,7 @@ function normalizeTraceMode(trace) {
|
|
|
164
162
|
//#region src/fixture/trace-context.ts
|
|
165
163
|
const TRACE_CONTEXT_ATTACHMENT_NAME = "playwright-opentelemetry-trace-context";
|
|
166
164
|
const FIXTURE_SPANS_ATTACHMENT_NAME = "playwright-opentelemetry-fixture-spans";
|
|
165
|
+
const BROWSER_SERVICE_NAME = "playwright-browser";
|
|
167
166
|
async function createTestTraceContext(testInfo) {
|
|
168
167
|
const traceContext = {
|
|
169
168
|
traceId: generateTraceId(),
|
|
@@ -195,7 +194,6 @@ async function flushFixtureSpans(traceContext, config, options) {
|
|
|
195
194
|
await Promise.all(destinations.map((destination) => sendSpans(traceContext.spans, {
|
|
196
195
|
tracesEndpoint: destination.tracesEndpoint,
|
|
197
196
|
headers: destination.headers,
|
|
198
|
-
serviceName: "playwright-browser",
|
|
199
197
|
playwrightVersion: "unknown",
|
|
200
198
|
debug: config.debug
|
|
201
199
|
})));
|
|
@@ -243,7 +241,6 @@ function resolvePlaywrightOpentelemetryConfig(config, options = {}) {
|
|
|
243
241
|
storeTraceZip: config?.storeTraceZip === true,
|
|
244
242
|
trace: config?.trace ?? null,
|
|
245
243
|
propagateTraceHeaders: config?.propagateTraceHeaders ?? true,
|
|
246
|
-
serviceName: process.env.OTEL_SERVICE_NAME || config?.serviceName || "playwright-tests",
|
|
247
244
|
debug: debugEnv === void 0 ? config?.debug ?? false : debugEnv === "1" || debugEnv === "true"
|
|
248
245
|
};
|
|
249
246
|
if (options.requireDestination === true && !hasPlaywrightOpentelemetryDestination(resolvedConfig)) throw new Error(getConfigurationErrorMessage());
|
|
@@ -253,9 +250,15 @@ function hasPlaywrightOpentelemetryDestination(config) {
|
|
|
253
250
|
return Boolean(config.otlpEndpoint || config.playwrightTraceApiEndpoint || config.storeTraceZip);
|
|
254
251
|
}
|
|
255
252
|
function getConfigurationErrorMessage() {
|
|
256
|
-
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
|
|
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 otlpHeaders: {\n Authorization: 'Bearer YOUR_TOKEN',\n },\n },\n },\n reporter: [['playwright-opentelemetry/reporter']],\n});\n\nNote: Environment variables take precedence over use.playwrightOpentelemetry options.\n";
|
|
257
254
|
}
|
|
258
255
|
//#endregion
|
|
256
|
+
Object.defineProperty(exports, "BROWSER_SERVICE_NAME", {
|
|
257
|
+
enumerable: true,
|
|
258
|
+
get: function() {
|
|
259
|
+
return BROWSER_SERVICE_NAME;
|
|
260
|
+
}
|
|
261
|
+
});
|
|
259
262
|
Object.defineProperty(exports, "FIXTURE_SPANS_ATTACHMENT_NAME", {
|
|
260
263
|
enumerable: true,
|
|
261
264
|
get: function() {
|