Skip to content

fix: add OpenTelemetry span IDs to async capture_exception - #1123

Open
eli-r-ph wants to merge 1 commit into
v1-trace-ids-as-sdk-valuesfrom
v1-async-exception-span-ids
Open

eli-r-ph wants to merge 1 commit into
v1-trace-ids-as-sdk-valuesfrom
v1-async-exception-span-ids

Conversation

@eli-r-ph

Copy link
Copy Markdown
Contributor

💡 Motivation and Context

Client.capture_exception always adds the active OpenTelemetry span's $trace_id and $span_id, but AsyncPosthog.capture_exception adds them only when capture_trace_context=True. This makes the async client match the sync one. Stacked on #1122, which set where those IDs sit in the property order.

  • AsyncPosthog.capture_exception now adds the span IDs even with capture_trace_context off, with the same order and pair rule as the sync client.
  • The 8.0 migration guide notes the change, and a changeset describes it.

💚 How did you test it?

  • The async span-ID tests now run capture_exception with capture_trace_context=False, like the sync ones. Two cases fail without this change.
  • pytest posthog/test (5326 passed), ruff check, ruff format --check, mypy and make public_api_check pass locally.

📝 Checklist

  • I reviewed the submitted code.
  • I added tests to verify the changes.
  • I updated the docs if needed.
  • No breaking change or entry added to the changelog.

If releasing new changes

  • Ran sampo add to generate a changeset file

🤖 Agent context

Autonomy: Human-driven (agent-assisted)

Authored with Claude Code (Claude Opus 5.5), directed by @eli-r-ph.

🤖 Generated with Claude Code

AsyncPosthog.capture_exception now adds the active span's $trace_id and
$span_id even with capture_trace_context off, like Client.capture_exception.
They follow the same SDK-value fill order and pair rule.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@eli-r-ph eli-r-ph self-assigned this Oct 24, 2026
@eli-r-ph
eli-r-ph marked this pull request as ready for review October 24, 2026 01:51
@eli-r-ph
eli-r-ph requested a review from a team as a code owner October 24, 2026 01:51

This branch has not been deployed

No deployments
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.

1 participant