Repository navigation
feat(otel): add request context to application spans - #375
Conversation
Generated-By: PostHog Desktop Task-Id: 5681be44-4986-48db-b140-1bda88f75f96
posthog-go Compliance ReportDate: 2026-10-23 16:58:13 UTC ✅ All Tests Passed!111/111 tests passed Capture_V1 Tests✅ 94/94 tests passed View Details
Feature_Flags Tests✅ 17/17 tests passed View Details
|
Generated-By: PostHog Desktop Task-Id: 5681be44-4986-48db-b140-1bda88f75f96
|
Note 🤖 Automated comment by QA Swarm — not written by a human Verdict: ✅ APPROVE (privacy round @ 40432bb)The processor and HTTP wrapper now take their PostHog client. A nil, disabled, or closed client adds no span IDs. Separate clients stay independent. A custom wrapper without Checks
Before release
Earlier roundsVerdict: ✅ APPROVE (round 1 @ 56f84cf)No remaining actionable finding in the reviewed change. The optional module boundary, request lifetime, explicit attributes, and repeated processor shutdown were checked. Key findings
ConvergenceNo remaining duplicate finding. Reviewer summaries
Automated by QA Swarm. Human review is required. This comment does not approve a merge or release. |
Generated-By: PostHog Desktop Task-Id: bfd18848-e498-4352-a58a-b9ba85de4198
[Robot] Prepared with PostHog Desktop on behalf of @pauldambra.
💡 Motivation and Context
Backend developers need to connect browser sessions to application traces. The existing AI exporter attaches request IDs only to its exported AI spans.
posthog-go/otelmodule.Public API:
ContextSpanProcessor,NewContextSpanProcessor(client), andNewRequestContextMiddleware(client, next, ...posthog.RequestContextOption)inposthogotel. Core clients get anIsEnabled()method on their concrete types only, not on theClientinterface, so existing custom clients still compile.IsEnabled(), the same fallback .NET uses.Important
When this ships,
otel/go.modmust require the core release that addsIsEnabled(). Against an older core, disabled and closed clients count as enabled.Use the optional wrapper for HTTP lifetime checks. Detached work needs a fresh context to opt in to its own IDs. Manual context has no automatic lifetime.
Tracks sdk-specs#128. Implements the proposed general-span contract in sdk-specs#129. The AI processor keeps its separate attribute contract.
💚 How did you test it?
go test ./...(2,011 tests) andgo test -race ./...in the core module, and the race tests (99) in the otel module. A feature-flag race test unrelated to this change failed once and passed on rerun.📝 Checklist
If releasing new changes
pnpm changesetto generate a changeset fileAdded the equivalent minor changeset file directly.
🤖 Agent context
Autonomy: Human-driven (agent-assisted)
GPT-6 (Codex) implemented this change with PostHog Desktop. The independent gpt-6-astra pass added the private shutdown guard and its regression test. Used the writing-tests, writing-code-comments, writing-user-facing-copy, and writing-pr-descriptions skills. The bridge uses public OpenTelemetry span APIs and keeps HTTP lifetime state in the optional module. Claude Opus 5.5 (claude-opus-5-5) bound the span check to its client after a cross-SDK privacy review. Human review is required.
Created with PostHog Desktop