docs(laravel): Add AI monitoring guide#18512
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
1 Skipped Deployment
|
Document Laravel AI agent monitoring support, including setup, verification, conversation tracking, and feature flags. Link the new guide from AI Monitoring and Conversations docs so users can discover the integration.
cf0b0a0 to
e5cde6e
Compare
coolguyzone
left a comment
There was a problem hiding this comment.
Looks good, thanks for the update 🫡
Co-authored-by: Alex Krawiec <alex.krawiec@sentry.io>
|
|
||
| namespace App\Ai\Tools; | ||
|
|
||
| use Illuminate\Contracts\JsonSchema\JsonSchema; |
There was a problem hiding this comment.
Bug: The documentation uses Illuminate\Contracts\JsonSchema\JsonSchema, which is only available in Laravel 13+, but claims support for Laravel 12.x, causing a "class not found" error.
Severity: MEDIUM
Suggested Fix
The documentation should be corrected. Either update the prerequisite to require Laravel 13.x or later, or find the correct namespace for the JsonSchema contract within the laravel/ai 0.x community package and update the code example accordingly.
Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.
Location: docs/platforms/php/guides/laravel/integrations/laravel-ai.mdx#L92
Potential issue: The code example in the Laravel AI integration guide imports
`Illuminate\Contracts\JsonSchema\JsonSchema`. This namespace is part of the core Laravel
framework and was introduced in version 13. However, the guide's prerequisites state it
supports Laravel 12.x and the community `laravel/ai` 0.x package. Users on a Laravel
12.x installation who follow this guide will encounter a fatal "class not found" error
at runtime, as the specified `JsonSchema` contract does not exist in their environment.
This makes the provided code example unusable for the documented minimum supported
version.
Did we get this right? 👍 / 👎 to inform future reviews.
| ## Install | ||
|
|
||
| Install the `sentry/sentry-laravel` package: | ||
|
|
||
| ```bash | ||
| composer require sentry/sentry-laravel | ||
| ``` | ||
|
|
||
| Install and configure `laravel/ai`: | ||
|
|
||
| ```bash | ||
| composer require laravel/ai | ||
| php artisan vendor:publish --provider="Laravel\Ai\AiServiceProvider" | ||
| php artisan migrate | ||
| ``` | ||
|
|
||
| Add your AI provider API keys to your `.env` file: | ||
|
|
||
| ```shell {filename:.env} | ||
| ANTHROPIC_API_KEY=your-anthropic-key | ||
| OPENAI_API_KEY=your-openai-key | ||
| ... | ||
| ``` |
There was a problem hiding this comment.
Do we assume that someone that wants to monitor their Laravel AI agent did not already set this up? Like why would install the SDK, the AI package and configure it to monitor it?
| ## Options | ||
|
|
||
| You can selectively disable individual span types in `config/sentry.php` under the `tracing` > `features` key: | ||
|
|
||
| ```php {filename:config/sentry.php} | ||
| 'tracing' => [ | ||
| 'features' => [ | ||
| // Master switch for all AI spans (requires laravel/ai) | ||
| 'gen_ai' => env('SENTRY_TRACE_GEN_AI_ENABLED', true), | ||
|
|
||
| // Individual span types | ||
| 'gen_ai_invoke_agent' => env('SENTRY_TRACE_GEN_AI_INVOKE_AGENT_ENABLED', true), | ||
| 'gen_ai_chat' => env('SENTRY_TRACE_GEN_AI_CHAT_ENABLED', true), | ||
| 'gen_ai_execute_tool' => env('SENTRY_TRACE_GEN_AI_EXECUTE_TOOL_ENABLED', true), | ||
| 'gen_ai_embeddings' => env('SENTRY_TRACE_GEN_AI_EMBEDDINGS_ENABLED', true), | ||
| ], | ||
| ], | ||
| ``` | ||
|
|
||
| Setting `gen_ai` to `false` disables all AI tracing. The individual options let you turn off specific span types while keeping others active. |
There was a problem hiding this comment.
I feel like this could be the entire content of this page.
DESCRIBE YOUR PR
Adds docs for Laravel AI agent monitoring with
sentry/sentry-laravel.Contributes to TET-2516
IS YOUR CHANGE URGENT?
Help us prioritize incoming PRs by letting us know when the change needs to go live.
SLA
Thanks in advance for your help!
PRE-MERGE CHECKLIST
Make sure you've checked the following before merging your changes: