autotel-playwright 0.5.2 → 0.5.4

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 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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "autotel-playwright",
3
- "version": "0.5.2",
3
+ "version": "0.5.4",
4
4
  "description": "Playwright fixture for OpenTelemetry: one span per test and trace context injected into API requests",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
@@ -31,7 +31,7 @@
31
31
  "NOTICE"
32
32
  ],
33
33
  "dependencies": {
34
- "autotel": "7.6.2"
34
+ "autotel": "7.7.0"
35
35
  },
36
36
  "peerDependencies": {
37
37
  "@playwright/test": ">=1.62.0"