Skip to content

chore(aio): show per-request context in otel onboarding docs - #117555

Merged
trunk-io[bot] merged 2 commits into
masterfrom
chore(aio)/otel-per-request-context-docs
Oct 15, 2026
Merged

trunk-io[bot] merged 2 commits into
masterfrom
chore(aio)/otel-per-request-context-docs

Conversation

@carlos-marchal-ph

Copy link
Copy Markdown
Contributor

Problem

  • The OpenTelemetry onboarding docs tell server developers to write their own span processor just to set a session ID, and offer no way to set the user per request.
  • The only documented user is a posthog.distinct_id resource attribute, which is fixed for the whole process.
  • The PostHog span processors now read the PostHog context directly: posthog-python#1060 (7.70.0), posthog-js#5299 (@posthog/ai 8.14.0) and posthog-go#371 (otel v1.35.0).

Changes

  • The "Group traces into sessions" step becomes "Users and sessions" on the 9 pages that share it: OpenTelemetry, AWS Bedrock, Instructor, AutoGen, LlamaIndex, Mirascope, Pydantic AI, Semantic Kernel and smolagents.
  • The step shows how to wrap a request in a PostHog context that sets the distinct ID, $ai_session_id and a custom property, in Python, Node and Go.
  • The hand-written SessionIdSpanProcessor examples are gone.
  • Node readers learn to pass their posthog-node client as the processor's client option. Go readers learn about NewRequestContextMiddleware.
  • The step says the context distinct ID takes priority over the resource attribute, so the existing setup code stays valid as the fallback.
  • The OpenTelemetry page adds posthog-node to the Node install line and updates the anonymous-events note.
  • Mechanical: the snippet file is renamed to otel-request-context.tsx, and 9 imports follow.

How did you test this code?

Test rationale: docs-only change, so no new automated test.

  • The three code samples ran against the published packages (PyPI, npm and the Go proxy) with real OpenAI instrumentation and a local PostHog. In each language, two concurrent requests produced $ai_generation events with their own distinct ID, $session_id, $ai_session_id and custom property. A call outside a context stayed anonymous.
  • A context distinct ID overrode a posthog.distinct_id resource attribute (checked in Python).
  • The OpenTelemetry page rendered on a local posthog.com build with all three language tabs. No screenshots are attached yet.
  • Not checked: the other 8 pages in a browser. They share the same step and only change which language tabs show.

Release status

  • No feature flag controls this change

Docs update

This PR is the docs update.

🤖 Agent context

Autonomy: Human-driven (agent-assisted)

Agent: Claude Code, Claude Opus 5.5 (claude-opus-5-5)

  • Directed by @carlos-marchal-ph after the three SDK changes shipped.
  • Skills invoked: /writing-user-facing-copy, /writing-pr-descriptions.
  • The first title, "Identify users and group sessions", was cut off in the posthog.com step header, so it became "Users and sessions".

🤖 Generated with Claude Code

@carlos-marchal-ph
carlos-marchal-ph requested a review from a team October 15, 2026 09:05
@carlos-marchal-ph carlos-marchal-ph self-assigned this Oct 15, 2026
@trunk-io

trunk-io Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

😎 Merged successfully - details.

@github-actions

github-actions Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

🤖 CI report

✅ Trunk lane — non-backend lane

This PR is assigned to the non-backend lane. It does not run backend Python tests and may merge in parallel with PRs in other lanes.

✅ Duplication (Python) — clean

New Python code duplication introduced by this branch. Fails at 70+ tokens in app code, or 150+ tokens when both copies live in test files. Advisory while the gate proves itself: extract a shared helper instead of copying.

✅ Duplication (TypeScript) — clean

New TypeScript code duplication introduced by this branch. Fails at 70+ tokens in app code, or 150+ tokens when both copies live in test files. Advisory while the gate proves itself: extract a shared helper instead of copying.

⚠️ Bundle size — 🔺 +85.2 KiB (+0.1%)

Uncompressed size of every built .js bundle, compared against the base branch.

Total: 76.64 MiB · 🔺 +85.2 KiB (+0.1%)

File Size Δ vs base
posthog-app/_parent/products/product_analytics/frontend/insights/insightScene/InsightScene.js 56.4 KiB 🔺 +56.4 KiB (new)
posthog-app/src/scenes/insights/InsightScene.js removed 🟢 -56.3 KiB (-100.0%)
render-query/src/render-query/render-query.js 24.60 MiB 🔺 +25.3 KiB (+0.1%)
posthog-app/_parent/products/tracing/frontend/components/TraceDialog/TraceDialog.js 20.8 KiB 🔺 +20.8 KiB (new)
posthog-app/_parent/products/tracing/frontend/TracingScene.js 172.8 KiB 🟢 -18.9 KiB (-9.8%)
posthog-app/_parent/products/business_intelligence/frontend/BusinessIntelligenceScene.js 144.2 KiB 🔺 +13.9 KiB (+10.7%)
posthog-app/src/scenes/project-homepage/today/TodayReportHoverCardChart.js removed 🟢 -11.8 KiB (-100.0%)
posthog-app/_parent/products/product_analytics/frontend/insights/insightQuickStart/InsightQuickStart.js 10.1 KiB 🔺 +10.1 KiB (new)
posthog-app/src/scenes/insights/InsightQuickStart/InsightQuickStart.js removed 🟢 -10.0 KiB (-100.0%)
posthog-app/_parent/products/business_knowledge/frontend/scenes/sources/BusinessKnowledgeScene.js 28.1 KiB 🔺 +8.9 KiB (+46.2%)
posthog-app/_parent/products/autoresearch/frontend/AutoresearchPipelineScene.js 110.3 KiB 🔺 +8.7 KiB (+8.6%)
posthog-app/src/scenes/project-homepage/today/TodayHome.js 23.1 KiB 🔺 +7.4 KiB (+47.4%)
posthog-app/src/scenes/project-homepage/today/TodayReportHoverCard.js removed 🟢 -7.4 KiB (-100.0%)
posthog-app/_parent/products/workflows/frontend/WorkflowsScene.js 56.5 KiB 🔺 +6.9 KiB (+13.9%)
posthog-app/src/layout/today/TodayObjectHoverCard.js 5.1 KiB 🔺 +5.1 KiB (new)
posthog-app/src/scenes/project-homepage/today/TodayReportHoverCardMetric.js removed 🟢 -4.9 KiB (-100.0%)
posthog-app/src/scenes/AuthenticatedShell.js 316.1 KiB 🟢 -3.0 KiB (-1.0%)
posthog-app/src/scenes/project-homepage/today/TodayReportPage.js 64.1 KiB 🔺 +2.6 KiB (+4.2%)
posthog-app/_parent/products/business_knowledge/frontend/scenes/source/KnowledgeSourceScene.js 20.0 KiB 🔺 +1.3 KiB (+7.2%)
posthog-app/_parent/products/review_hog/frontend/CodeReviewScene.js 114.2 KiB 🟢 -1.3 KiB (-1.1%)
posthog-app/_parent/products/workflows/frontend/Broadcasts/BroadcastScene.js 100.0 KiB 🔺 +1.3 KiB (+1.3%)
posthog-app/_parent/products/signals/frontend/inbox/InboxScene.js 460.8 KiB 🔺 +1.3 KiB (+0.3%)

Posted automatically by build-bundle-size-report · uncompressed bytes from dist-report

✅ Eager graph — within budget

How much code each root ships on the eager path — downloaded and parsed before the surface is interactive. Measured from the esbuild output chunks (post-tree-shake, static imports only); lazy import() / React.lazy chunks are not counted.

Root Eager (shipped) Δ vs base Budget
entry (logged-out pages, app bootstrap)
src/index.tsx
1012.3 KiB · 23 files 🔺 +6.2 KiB (+0.6%) █████████░ 86.4% of 1.14 MiB
logged-out boot: index + App + bootApp (preloaded by every page, including /login)
src/index.tsx + src/scenes/App.tsx + src/scenes/bootApp.ts
2.88 MiB · 606 files 🔺 +6.3 KiB (+0.2%) █████████░ 94.8% of 3.03 MiB
authenticated shell (every logged-in page)
src/scenes/AuthenticatedShell.tsx
7.46 MiB · 2,537 files 🟢 -35.3 KiB (-0.5%) ██████████ 97.6% of 7.64 MiB
dashboard scene
src/scenes/dashboard/Dashboard.tsx
9.66 MiB · 3,623 files 🔺 +18.5 KiB (+0.2%) █████████░ 93.8% of 10.30 MiB
today home path
src/scenes/AuthenticatedShell.tsx + src/scenes/project-homepage/ProjectHomepage.tsx + src/scenes/project-homepage/today/TodayHome.tsx
7.85 MiB · 2,867 files 🔺 +339.0 KiB (+4.4%) ██████████ 99.5% of 7.89 MiB
events scene
src/scenes/activity/explore/EventsScene.tsx
9.24 MiB · 3,450 files 🔺 +18.7 KiB (+0.2%) █████████░ 93.5% of 9.88 MiB
replay detail scene
src/scenes/session-recordings/detail/SessionRecordingDetail.tsx
11.97 MiB · 4,295 files 🔺 +13.4 KiB (+0.1%) ████████░░ 79.5% of 15.05 MiB

🟢 node_modules/monaco-editor/ stays out of src/index.tsx
🟢 src/lib/components/ActivityLog/describers stays out of src/index.tsx
🟢 node_modules/@posthog/brand/dist/generated/hoggies/svg/ stays out of src/index.tsx
🟢 node_modules/@posthog/brand/dist/generated/hoggies/components/ stays out of src/index.tsx
🟢 node_modules/monaco-editor/ stays out of src/index.tsx + src/scenes/App.tsx + src/scenes/bootApp.ts
🟢 src/layout/navigation-3000/navigationLogic.tsx stays out of src/index.tsx + src/scenes/App.tsx + src/scenes/bootApp.ts
🟢 src/scenes/dashboard/dashboardLogic.tsx stays out of src/index.tsx + src/scenes/App.tsx + src/scenes/bootApp.ts
🟢 src/lib/lemon-ui/LemonMarkdown/ stays out of src/index.tsx + src/scenes/App.tsx + src/scenes/bootApp.ts
🟢 src/lib/components/RichContentEditor/ stays out of src/index.tsx + src/scenes/App.tsx + src/scenes/bootApp.ts
🟢 src/lib/components/CodeSnippet/ stays out of src/index.tsx + src/scenes/App.tsx + src/scenes/bootApp.ts
🟢 src/taxonomy/core-filter-definitions-by-group.json stays out of src/index.tsx + src/scenes/App.tsx + src/scenes/bootApp.ts
🟢 node_modules/zod/ stays out of src/index.tsx + src/scenes/App.tsx + src/scenes/bootApp.ts
🟢 src/scenes/billing/billingLogic.tsx stays out of src/index.tsx + src/scenes/App.tsx + src/scenes/bootApp.ts
🟢 src/lib/components/ProductEmptyState/productSetupPreloadLogic.ts stays out of src/index.tsx + src/scenes/App.tsx + src/scenes/bootApp.ts
🟢 node_modules/monaco-editor/ stays out of src/scenes/AuthenticatedShell.tsx
🟢 src/lib/components/ActivityLog/describers stays out of src/scenes/AuthenticatedShell.tsx
🟢 products/dashboards/frontend/widgets/previews/ stays out of src/scenes/AuthenticatedShell.tsx
🟢 src/scenes/session-recordings/player/sessionRecordingPlayerLogic.ts stays out of src/scenes/AuthenticatedShell.tsx
🟢 zod/v4/locales/de.js stays out of src/scenes/AuthenticatedShell.tsx
🟢 node_modules/@posthog/brand/dist/generated/hoggies/svg/ stays out of src/scenes/AuthenticatedShell.tsx
🟢 node_modules/@posthog/brand/dist/generated/hoggies/components/ stays out of src/scenes/AuthenticatedShell.tsx
🟢 src/scenes/session-recordings/playlist/SessionRecordingsPlaylist.tsx stays out of src/scenes/dashboard/Dashboard.tsx
🟢 src/scenes/web-analytics/tiles/WebAnalyticsTile.tsx stays out of src/scenes/dashboard/Dashboard.tsx
🟢 src/scenes/project-homepage/ai-first/AiFirstHomepage.tsx stays out of src/scenes/AuthenticatedShell.tsx + src/scenes/project-homepage/ProjectHomepage.tsx + src/scenes/project-homepage/today/TodayHome.tsx
🟢 src/scenes/project-homepage/today/TodayReportPage.tsx stays out of src/scenes/AuthenticatedShell.tsx + src/scenes/project-homepage/ProjectHomepage.tsx + src/scenes/project-homepage/today/TodayHome.tsx
🟢 src/queries/Query/Query.tsx stays out of src/scenes/AuthenticatedShell.tsx + src/scenes/project-homepage/ProjectHomepage.tsx + src/scenes/project-homepage/today/TodayHome.tsx
🟢 src/scenes/session-recordings/playlist/SessionRecordingsPlaylist.tsx stays out of src/scenes/activity/explore/EventsScene.tsx
🟢 src/scenes/web-analytics/tiles/WebAnalyticsTile.tsx stays out of src/scenes/activity/explore/EventsScene.tsx

Largest files eagerly shipped from src/index.tsx
Size File
126.8 KiB ../node_modules/.pnpm/react-dom@18.3.1_react@18.3.1/node_modules/react-dom/cjs/react-dom.production.min.js
24.6 KiB ../node_modules/.pnpm/buffer@6.0.3/node_modules/buffer/index.js
6.3 KiB ../node_modules/.pnpm/react@18.3.1/node_modules/react/cjs/react.production.min.js
4.5 KiB ../node_modules/.pnpm/@jspm+core@2.1.0/node_modules/@jspm/core/nodelibs/browser/process.js
3.9 KiB ../node_modules/.pnpm/scheduler@0.23.2/node_modules/scheduler/cjs/scheduler.production.min.js
1.4 KiB ../node_modules/.pnpm/base64-js@1.5.1/node_modules/base64-js/index.js
1.3 KiB src/RootErrorBoundary.tsx
1.3 KiB src/index.tsx
912 B ../node_modules/.pnpm/ieee754@1.2.1/node_modules/ieee754/index.js
839 B src/scenes/ChunkLoadErrorBoundary.tsx
Largest files eagerly shipped from src/index.tsx + src/scenes/App.tsx + src/scenes/bootApp.ts
Size File
319.8 KiB ../node_modules/.pnpm/posthog-js@1.438.8_@types+react@18.3.27_react@18.3.1/node_modules/posthog-js/dist/module.mjs
220.2 KiB ../node_modules/.pnpm/@posthog+icons@0.38.0_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@posthog/icons/dist/posthog-icons.es.js
126.8 KiB ../node_modules/.pnpm/react-dom@18.3.1_react@18.3.1/node_modules/react-dom/cjs/react-dom.production.min.js
105.9 KiB src/products.tsx
99.6 KiB src/lib/api.ts
69.0 KiB src/lib/lemon-ui/icons/icons.tsx
38.7 KiB ../node_modules/.pnpm/@dnd-kit+core@6.0.8_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@dnd-kit/core/dist/core.esm.js
33.9 KiB ../node_modules/.pnpm/kea@4.0.0-pre.6_patch_hash=139b8d1f1304f9d9da452a9a1244c94ea679dbcb85687d8999563146879fb6f5_react@18.3.1/node_modules/kea/lib/index.cjs.js
28.9 KiB src/scenes/scenes.ts
27.9 KiB src/lib/constants.tsx
Largest files eagerly shipped from src/scenes/AuthenticatedShell.tsx
Size File
319.8 KiB ../node_modules/.pnpm/posthog-js@1.438.8_@types+react@18.3.27_react@18.3.1/node_modules/posthog-js/dist/module.mjs
281.1 KiB src/taxonomy/core-filter-definitions-by-group.json
220.2 KiB ../node_modules/.pnpm/@posthog+icons@0.38.0_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@posthog/icons/dist/posthog-icons.es.js
185.5 KiB ../packages/quill/packages/quill/dist/index.js
153.7 KiB ../node_modules/.pnpm/re2js@0.4.1/node_modules/re2js/build/index.esm.js
139.9 KiB ../packages/quill/packages/primitives/dist/index.js
126.8 KiB ../node_modules/.pnpm/react-dom@18.3.1_react@18.3.1/node_modules/react-dom/cjs/react-dom.production.min.js
105.9 KiB src/products.tsx
99.6 KiB src/lib/api.ts
93.3 KiB ../node_modules/.pnpm/prosemirror-view@1.40.1/node_modules/prosemirror-view/dist/index.js
Largest files eagerly shipped from src/scenes/dashboard/Dashboard.tsx
Size File
319.8 KiB ../node_modules/.pnpm/posthog-js@1.438.8_@types+react@18.3.27_react@18.3.1/node_modules/posthog-js/dist/module.mjs
281.1 KiB src/taxonomy/core-filter-definitions-by-group.json
220.2 KiB ../node_modules/.pnpm/@posthog+icons@0.38.0_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@posthog/icons/dist/posthog-icons.es.js
185.5 KiB ../packages/quill/packages/quill/dist/index.js
181.9 KiB src/queries/validators.js
153.7 KiB ../node_modules/.pnpm/re2js@0.4.1/node_modules/re2js/build/index.esm.js
139.9 KiB ../packages/quill/packages/primitives/dist/index.js
126.8 KiB ../node_modules/.pnpm/react-dom@18.3.1_react@18.3.1/node_modules/react-dom/cjs/react-dom.production.min.js
105.9 KiB src/products.tsx
99.6 KiB src/lib/api.ts
Largest files eagerly shipped from src/scenes/AuthenticatedShell.tsx + src/scenes/project-homepage/ProjectHomepage.tsx + src/scenes/project-homepage/today/TodayHome.tsx
Size File
319.8 KiB ../node_modules/.pnpm/posthog-js@1.438.8_@types+react@18.3.27_react@18.3.1/node_modules/posthog-js/dist/module.mjs
281.1 KiB src/taxonomy/core-filter-definitions-by-group.json
220.2 KiB ../node_modules/.pnpm/@posthog+icons@0.38.0_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@posthog/icons/dist/posthog-icons.es.js
185.5 KiB ../packages/quill/packages/quill/dist/index.js
153.7 KiB ../node_modules/.pnpm/re2js@0.4.1/node_modules/re2js/build/index.esm.js
139.9 KiB ../packages/quill/packages/primitives/dist/index.js
126.8 KiB ../node_modules/.pnpm/react-dom@18.3.1_react@18.3.1/node_modules/react-dom/cjs/react-dom.production.min.js
105.9 KiB src/products.tsx
99.6 KiB src/lib/api.ts
93.3 KiB ../node_modules/.pnpm/prosemirror-view@1.40.1/node_modules/prosemirror-view/dist/index.js
Largest files eagerly shipped from src/scenes/activity/explore/EventsScene.tsx
Size File
319.8 KiB ../node_modules/.pnpm/posthog-js@1.438.8_@types+react@18.3.27_react@18.3.1/node_modules/posthog-js/dist/module.mjs
281.1 KiB src/taxonomy/core-filter-definitions-by-group.json
220.2 KiB ../node_modules/.pnpm/@posthog+icons@0.38.0_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@posthog/icons/dist/posthog-icons.es.js
185.5 KiB ../packages/quill/packages/quill/dist/index.js
181.9 KiB src/queries/validators.js
153.7 KiB ../node_modules/.pnpm/re2js@0.4.1/node_modules/re2js/build/index.esm.js
139.9 KiB ../packages/quill/packages/primitives/dist/index.js
126.8 KiB ../node_modules/.pnpm/react-dom@18.3.1_react@18.3.1/node_modules/react-dom/cjs/react-dom.production.min.js
105.9 KiB src/products.tsx
99.6 KiB src/lib/api.ts
Largest files eagerly shipped from src/scenes/session-recordings/detail/SessionRecordingDetail.tsx
Size File
319.8 KiB ../node_modules/.pnpm/posthog-js@1.438.8_@types+react@18.3.27_react@18.3.1/node_modules/posthog-js/dist/module.mjs
316.0 KiB ../node_modules/.pnpm/posthog-js@1.438.8_@types+react@18.3.27_react@18.3.1/node_modules/posthog-js/dist/rrweb.js
281.1 KiB src/taxonomy/core-filter-definitions-by-group.json
220.2 KiB ../node_modules/.pnpm/@posthog+icons@0.38.0_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@posthog/icons/dist/posthog-icons.es.js
185.5 KiB ../packages/quill/packages/quill/dist/index.js
181.9 KiB src/queries/validators.js
153.7 KiB ../node_modules/.pnpm/re2js@0.4.1/node_modules/re2js/build/index.esm.js
126.8 KiB ../node_modules/.pnpm/react-dom@18.3.1_react@18.3.1/node_modules/react-dom/cjs/react-dom.production.min.js
105.9 KiB src/products.tsx
99.6 KiB src/lib/api.ts

Posted automatically by check-eager-graph · sizes are eager output bytes (shipped, post-tree-shake) from the esbuild metafile · part of #32479

✅ Toolbar bundle — eager 2.24 MiB within budget

What the toolbar ships to customer pages, measured from the esbuild output (minified, post-tree-shake). The eager set is the entry plus everything statically imported from it — fetched before any feature runs; deferred chunks load lazily. The eager guardrail is 5.72 MiB. Each output file must also stay below 10 MB, where CloudFront stops compressing it. The module boundary is enforced separately by check-toolbar-graph.

Metric Size Δ vs base Budget
Eager (shipped)
entry + static imports
2.24 MiB · 19 files 🔺 +2.0 KiB (+0.1%) ████░░░░░░ 39.1% of 5.72 MiB
Deferred (lazy) 2.10 MiB · 40 files no change n/a — loads on demand
Loader dist/toolbar.js 1.2 KiB no change █░░░░░░░░░ 6.0% of 19.5 KiB
Largest eagerly-shipped chunks
Size File
877.1 KiB dist/toolbar/toolbar-app-I7G2FM3L.css
664.2 KiB dist/toolbar/chunk-chunk-SUEK4BA3.js
257.8 KiB dist/toolbar/chunk-chunk-7ZYWOYNH.js
131.8 KiB dist/toolbar/chunk-chunk-FDH2IBXT.js
129.6 KiB dist/toolbar/chunk-chunk-7KVJ3SBW.js
74.7 KiB dist/toolbar/toolbar-app-Q3M4UQVL.js
69.0 KiB dist/toolbar/chunk-chunk-TSAL54PB.js
35.6 KiB dist/toolbar/chunk-chunk-PVJXZTW7.js
21.7 KiB dist/toolbar/chunk-chunk-2ZQQMVWZ.js
6.8 KiB dist/toolbar/chunk-chunk-DV7IWQNF.js

Posted automatically by check-toolbar-size · sizes are toolbar output bytes (shipped, post-tree-shake) from the esbuild metafile

✅ Dist folder size — 🔺 +2.07 MiB (+0.2%)

Total size of the built frontend/dist folder (all assets), compared against the base branch.

Total: 1016.71 MiB · 🔺 +2.07 MiB (+0.2%)

@greptile-apps

greptile-apps Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in Greptile

[Low impact] Updates documentation code examples for observability setup.

The PR appears safe to merge, with a non-blocking correction needed in the Node sample.

Reviews (1) · Last reviewed commit: "chore: otel per request context docs" · Reviewed by Greptile

@carlos-marchal-ph
carlos-marchal-ph force-pushed the chore(aio)/otel-per-request-context-docs branch from c03c7ac to 0f86edd Compare October 15, 2026 09:14

@posthog posthog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PostHog Review · Standard · reviewed 0f86edd: 1 Should fix.

Comment on lines +28 to +33
// Pass the client to the processor you configured earlier
new PostHogSpanProcessor({
projectToken: '<ph_project_token>',
host: '<ph_client_api_host>',
client: posthog,
})

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 · Wire the context client into the registered Node processor

When readers append this snippet to the earlier Node setup, new PostHogSpanProcessor creates an unregistered instance and discards it. The processor registered in spanProcessors still lacks client, so withContext contributes no user, session, or custom properties. Show the updated provider setup or explicitly replace its existing processor configuration.

@bernatixer bernatixer left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new step calls identify_context(user_id), so omitting only the posthog.distinct_id resource attribute no longer makes events anonymous. You fixed the note on the OpenTelemetry page, but the same note is still the old wording on AutoGen, AWS Bedrock, Instructor, LlamaIndex, Mirascope, Pydantic AI, Semantic Kernel and smolagents. Worth applying the "don't set a distinct ID in the PostHog context" wording to those too.

<Markdown>
{dedent`
In Go, \`posthog.NewRequestContextMiddleware\` fills the context for each HTTP request
from the \`X-PostHog-Distinct-Id\` and \`X-PostHog-Session-Id\` headers.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The X-PostHog-Session-Id header ends up as $session_id (posthog-go otel/request_context.go writes SessionId to $session_id), and AI ingestion doesn't derive $ai_session_id from it. Since this sits in the sessions step, a Go reader could expect the header to group traces in the Sessions tab. Maybe add that the header sets the web session ID and $ai_session_id still goes in Properties?

@trunk-io
trunk-io Bot merged commit 29af8f0 into master Oct 15, 2026
220 checks passed
@trunk-io
trunk-io Bot deleted the chore(aio)/otel-per-request-context-docs branch October 15, 2026 15:04
@deployment-status-posthog

deployment-status-posthog Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

Deploy status

Environment Status Deployed At Workflow
dev ✅ Deployed 2026-10-15 15:36 UTC Run
prod-us ✅ Deployed 2026-10-15 15:57 UTC Run
prod-eu ✅ Deployed 2026-10-15 15:59 UTC Run

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants