Repository navigation
feat(server): add request context to OpenTelemetry spans - #861
pauldambra wants to merge 3 commits into
Conversation
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 @ 1048c0b)The span processor is now bound to one client, accepts the ChecksServer tests (604), API check, and Spotless pass. An independent review found a compile problem with the documented client type; it is fixed and tested through Earlier roundsVerdict: ✅ APPROVE (round 1 @ 6ea9d10)No remaining actionable finding in the reviewed change. The optional server processor, public attribute reads, shutdown, and same-thread scope cleanup were checked. No automatic coroutine or Reactor transfer is claimed. 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
Generated-By: PostHog Desktop Task-Id: bfd18848-e498-4352-a58a-b9ba85de4198
[Robot]
💡 Motivation and Context
JVM server users need to connect application traces to the browser session and person that caused a request.
sessionIdandposthogDistinctIdattributes to an existing recording OpenTelemetry SDK span.com.posthog.server.otel.PostHogContextSpanProcessorcaptures the same IDs when child spans start. Register it on the application's existing provider.PostHogContextSpanProcessor(posthog), whereposthog = PostHog.with(config). Open each request scope with the same client:PostHogRequestContext.withContext(posthog, data, fresh = true) { ... }.Note
This uses the existing
PostHogRequestContexthelper. Each request needs a fresh scope, closed on the same thread.Work on another thread needs its own scope. The change adds no Spring filter, coroutine, Reactor, or Java agent integration.
API-only spans without readable SDK attributes remain unchanged.
Tracks backend span context. The cross-SDK contract is proposed in sdk-specs PR #129.
💚 How did you test it?
PostHog.with(config).📝 Checklist
If releasing new changes
pnpm changesetto generate a changeset file🤖 Agent context
Autonomy: Human-driven (agent-assisted)
GPT-6 (Codex) wrote this change with PostHog Desktop. Claude Opus 5.5 (claude-opus-5-5) bound span enrichment to its client after review. It used the writing-tests, writing-code-comments, writing-user-facing-copy, and writing-pr-descriptions skills.
The processor uses the public SDK span snapshot to preserve attributes of every type. A guarded optional adapter keeps request scopes usable without OpenTelemetry.
Created with PostHog Desktop