Repository navigation
feat(metrics): attach trace exemplars to flushed metric series - #5291
Conversation
A sample recorded inside a sampled span now stamps its series with an exemplar: trace ID, span ID, and value. Hosts expose the active span through an optional MetricsHost.getActiveSpan; posthog-node already provides it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Generated-By: PostHog Desktop Task-Id: b5bf025d-b42c-461d-a1c9-1591be9ce76d
Coherence2 spec problems · 0 failing chokepoints · 2 spec gaps · 0 guard failures 44 components, 5 bullets (5 invariants, 0 requirements), 2 problems Spec problems (spec --check)
Chokepoints: none declared. Spec gaps: 2 entrances with outside or unknown trust and no traced control, and 10 more held by the adoption baseline
Close one with |
Node SDK compliance v2Commit: 13b84a3 Capture v0 — acceptance
Capture v1 — acceptance
Capture v0 — migration
Capture v1 — migration
|
|
Size Change: +25.5 kB (+0.11%) Total Size: 24.1 MB 📦 View Changed
ℹ️ View Unchanged
|
|
[Medium impact] Adds trace exemplars to metric data points. Shorten the changeset to satisfy the release requirement before merging; no behavioral blocker was found. Reviews (1) · Last reviewed commit: "feat(metrics): attach trace exemplars to..." · Reviewed by Greptile |
posthog-js Compliance ReportDate: 2026-10-13 17:13:49 UTC ✅ All Tests Passed!26/26 tests passed Capture Tests✅ 26/26 tests passed View Details
|
Metrics now imports traceparent parsing, which pulls traces/ids into the browser bundle. Its module-level '0'.repeat(...) threw on load in IE11, so spell the invalid-id constants out. Also regenerate the terser mangled names for the new _activeTraceContext method. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Generated-By: PostHog Desktop Task-Id: 6921bfc1-7e35-4637-83d4-353c11b3af05
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Generated-By: PostHog Desktop Task-Id: 6921bfc1-7e35-4637-83d4-353c11b3af05
|
There was a problem hiding this comment.
Approved.
The risky changes have test coverage and no identified substantive blockers, but the reported agent assurance is a discussion comment rather than a qualifying APPROVED or COMMENTED review. Request a current-head review from Anna Garcia, an agent reviewer, or a teammate covering the metric payload and browser build changes before re-requesting.
- PostHog Review (Standard) reviewed the current head: no findings.
- 👍 on the PR from greptile-apps[bot].
Gate mechanics and policy version
| Gate | Result | |
|---|---|---|
| prerequisites | ✓ | all clear |
| deny-list | ✓ | no deny categories matched |
| size | ✓ | 87L, 6F substantive, 184L/9F incl. docs/generated/snapshots — within ceiling |
| tier | ✓ | T1-agent / T1c-medium (184L, 9F, two-areas, feat) |
| stamphog 2.5.0 | .stamphog/policy.yml @ 13b84a3 · reviewed head 13b84a3 |
…talls through corepack again, and only pnpm 12 and later use Kern's own pinned corepack, because the corepack in Node 24 and older images looks for a file pnpm 12 no longer ships (pnpm 11 has no native launcher, so the npm route Kern took for it failed on 18 real projects such as PostHog/posthog-js#5291 and openclaw#134760); corepack checks the pinned hash itself, and a project that pins no pnpm gets corepack's own fixed version instead of whatever is newest that day, so the same pull request gets the same pnpm on every check; a test run's temporary folder is a fresh volume on disk outside the project, as on the project's own CI, because a folder inside node_modules made temporary projects find the repository's own files (webpack#22695 went from 15 to 1,346 tests failing on both sides, vercel/workflow#3052 from 1 to 36), and it is removed with the container
Problem
posthog.metricsnever links to a trace, even inside a sampled span. The Metrics UI has no exemplar to jump from a chart point to the request that produced it.posthog.metrics, so the gap is in the SDK.Changes
posthog.withSpannow carries that span's exemplar. The node client already exposesgetActiveSpan(), so it satisfies the new optionalMetricsHost.getActiveSpanwith no wiring change.traceId/spanId, nanos as a decimal string.getActiveSpan.Release info Sub-libraries affected
Libraries affected
Checklist
If releasing new changes
pnpm changesetto generate a changeset file🤖 Agent context
Autonomy: Human-driven (agent-assisted)
claude-opus-5-5) through the PostHog Slack app. Skills:writing-pr-descriptions.withSpanpath end to end through the client.Created with PostHog from a Slack thread
🤖 Generated with Claude Code