Laravel's new official AI SDK simplifies Sentry tracing for LLM calls through event-driven architecture. Instead of manually wrapping each OpenAI call, a single event listener automatically traces all AI interactions—chat completions, streaming, and embeddings—across any provider. The SDK fires events with invocation IDs that correlate start and finish spans, handling token counts and metadata automatically. The listener approach eliminates the need to remember tracing wrappers while maintaining the same gen_ai.* attribute conventions for Sentry's LLM monitoring UI.

5m read timeFrom joshhornby.com
Post cover image
Table of contents
What changedThe listenerWhat’s different from the manual approachThe same patterns still applyBeyond Sentry

Sort: