Otel
OpenTelemetry support in @posthog/ai: a span processor that turns AI SDK spans into PostHog AI events.
invariants
- the span processor merges context into a copy of the span: With a
clientoption,PostHogSpanProcessorsnapshots the active PostHog context inonStartand merges it into a copy of the span inonEnd; the live span and other processors never see it. - span attributes win over context properties: A span's own attributes win over context properties, which win over the context's distinct ID and session ID (exported as
$session_id). The context's distinct ID is skipped when the span already names a user.