Skip to content

Commit dbfc15d

Browse files
bartlomiejuclaude
andcommitted
fix: resolve lint errors and add traceparent docs
Move `as any` cast to a single line so the deno-lint-ignore directive covers it, fixing ban-unused-ignore and no-explicit-any errors on CI. Also document the new traceparent meta tag injection in the OpenTelemetry docs page. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent ed8671d commit dbfc15d

2 files changed

Lines changed: 22 additions & 7 deletions

File tree

docs/latest/advanced/opentelemetry.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,3 +127,21 @@ deno task start
127127

128128
Open `http://localhost:16686` to browse traces. You'll see each request broken
129129
down into its middleware, handler, and rendering spans.
130+
131+
## Client-side trace correlation
132+
133+
When an OpenTelemetry exporter is active, Fresh automatically injects a
134+
[W3C Trace Context](https://www.w3.org/TR/trace-context/) `<meta>` tag into the
135+
`<head>` of every rendered page:
136+
137+
```html
138+
<head>
139+
<meta name="traceparent" content="00-ab42124a3c573678d4d8b21ba52df3bf-d21f7bc17caa5aba-01">
140+
<!-- ... -->
141+
</head>
142+
```
143+
144+
This allows client-side OpenTelemetry instrumentation (such as
145+
[`@opentelemetry/instrumentation-document-load`](https://www.npmjs.com/package/@opentelemetry/instrumentation-document-load))
146+
to link browser performance traces back to the server-side span that rendered the
147+
page, giving you end-to-end visibility from server rendering through page load.

packages/fresh/src/runtime/server/preact_hooks.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -290,13 +290,10 @@ options[OptionsType.DIFF] = (vnode) => {
290290
const spanCtx = activeSpan.spanContext();
291291
if (isSpanContextValid(spanCtx)) {
292292
const flags = (spanCtx.traceFlags & 1) ? "01" : "00";
293-
items.push(
294-
// deno-lint-ignore no-explicit-any
295-
h("meta", {
296-
name: "traceparent",
297-
content: `00-${spanCtx.traceId}-${spanCtx.spanId}-${flags}`,
298-
} as any),
299-
);
293+
const traceparent =
294+
`00-${spanCtx.traceId}-${spanCtx.spanId}-${flags}`;
295+
// deno-lint-ignore no-explicit-any
296+
items.push(h("meta", { name: "traceparent", content: traceparent }) as any);
300297
}
301298
}
302299

0 commit comments

Comments
 (0)