autotel-playwright 0.5.2 → 0.5.3
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/README.md +2 -0
- package/dist/index.cjs +4 -0
- package/dist/index.js +5 -1
- package/dist/reporter.cjs +1 -0
- package/dist/reporter.js +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -112,6 +112,8 @@ test('user flow', async ({ page }) => {
|
|
|
112
112
|
- **page:** For every request whose URL matches the configured API base origin, the fixture adds W3C trace context and `x-test-name` to the request headers (via `page.route`).
|
|
113
113
|
- **requestWithTrace:** Same headers are merged into requests made with the wrapped `request` fixture (get/post/put/patch/delete/head/fetch) when the URL matches the API base.
|
|
114
114
|
- **step(name, fn):** Runs `fn` as a child span `step:${name}` under the test span for finer-grained traces. If `fn` throws, the span is marked as error with `recordException` before re-throwing.
|
|
115
|
+
- Every test gets an `otel-trace` annotation holding the trace URL (from `OTEL_TRACE_URL_TEMPLATE`) or the raw trace id, so the Playwright HTML report points at the backend trace.
|
|
116
|
+
- The reporter puts Playwright's own artefacts on the test span: `test.trace.path`, `test.video.path`, `test.screenshot.path`. Find the failed span in your backend, then `npx playwright show-trace <test.trace.path>` (or drop it on [trace.playwright.dev](https://trace.playwright.dev)) to replay it.
|
|
115
117
|
- Optional per-test attributes: use annotations with type `autotel.attribute` and description `key=value` or semicolon-delimited `key1=value1;key2=value2` (see `AUTOTEL_ATTRIBUTE_ANNOTATION`).
|
|
116
118
|
|
|
117
119
|
## API
|
package/dist/index.cjs
CHANGED
|
@@ -128,6 +128,10 @@ const test = _playwright_test.test.extend({
|
|
|
128
128
|
"test.line": testInfo.line ?? 0
|
|
129
129
|
} });
|
|
130
130
|
setAttributesFromAnnotations(span, testInfo);
|
|
131
|
+
testInfo.annotations.push({
|
|
132
|
+
type: "otel-trace",
|
|
133
|
+
description: (0, autotel.resolveTraceUrl)(void 0, span.spanContext().traceId) ?? span.spanContext().traceId
|
|
134
|
+
});
|
|
131
135
|
const ctx = autotel.otelTrace.setSpan(autotel.context.active(), span);
|
|
132
136
|
const carrier = {};
|
|
133
137
|
autotel.context.with(ctx, () => {
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { expect, test as test$1 } from "@playwright/test";
|
|
2
|
-
import { SpanStatusCode, context, enrichWithTraceContext, getAutotelTracerProvider, getTraceContext, getTracer, isTracing, otelTrace, propagation, resolveTraceUrl } from "autotel";
|
|
2
|
+
import { SpanStatusCode, context, enrichWithTraceContext, getAutotelTracerProvider, getTraceContext, getTracer, isTracing, otelTrace, propagation, resolveTraceUrl, resolveTraceUrl as resolveTraceUrl$1 } from "autotel";
|
|
3
3
|
import { TestSpanCollector } from "autotel/test-span-collector";
|
|
4
4
|
import { SimpleSpanProcessor } from "autotel/processors";
|
|
5
5
|
//#region src/index.ts
|
|
@@ -127,6 +127,10 @@ const test = test$1.extend({
|
|
|
127
127
|
"test.line": testInfo.line ?? 0
|
|
128
128
|
} });
|
|
129
129
|
setAttributesFromAnnotations(span, testInfo);
|
|
130
|
+
testInfo.annotations.push({
|
|
131
|
+
type: "otel-trace",
|
|
132
|
+
description: resolveTraceUrl$1(void 0, span.spanContext().traceId) ?? span.spanContext().traceId
|
|
133
|
+
});
|
|
130
134
|
const ctx = otelTrace.setSpan(context.active(), span);
|
|
131
135
|
const carrier = {};
|
|
132
136
|
context.with(ctx, () => {
|
package/dist/reporter.cjs
CHANGED
|
@@ -34,6 +34,7 @@ var OtelReporter = class {
|
|
|
34
34
|
const key = testKey(test);
|
|
35
35
|
const span = this.testSpans.get(key);
|
|
36
36
|
if (span) {
|
|
37
|
+
for (const attachment of result.attachments) if (attachment.path && (attachment.name === "trace" || attachment.name === "video" || attachment.name === "screenshot")) span.setAttribute(`test.${attachment.name}.path`, attachment.path);
|
|
37
38
|
if (result.status !== "passed" && result.status !== "skipped") {
|
|
38
39
|
span.setStatus({ code: autotel.SpanStatusCode.ERROR });
|
|
39
40
|
if (result.error) span.recordException(toError(result.error));
|
package/dist/reporter.js
CHANGED
|
@@ -30,6 +30,7 @@ var OtelReporter = class {
|
|
|
30
30
|
const key = testKey(test);
|
|
31
31
|
const span = this.testSpans.get(key);
|
|
32
32
|
if (span) {
|
|
33
|
+
for (const attachment of result.attachments) if (attachment.path && (attachment.name === "trace" || attachment.name === "video" || attachment.name === "screenshot")) span.setAttribute(`test.${attachment.name}.path`, attachment.path);
|
|
33
34
|
if (result.status !== "passed" && result.status !== "skipped") {
|
|
34
35
|
span.setStatus({ code: SpanStatusCode.ERROR });
|
|
35
36
|
if (result.error) span.recordException(toError(result.error));
|
package/package.json
CHANGED