Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
18c3ab3
feat(ai): add invoke_agent tracing baseline
constantinius Mar 16, 2026
e5ea71e
fix(ai): compatibility with PHP < 8 and test class fix
constantinius Mar 17, 2026
1c95e55
fix(ai): test fix
constantinius Mar 17, 2026
93f3f58
fix(ai): test fix
constantinius Mar 17, 2026
cd9b98b
fix(ai): really fixing test issue
constantinius Mar 17, 2026
7e083eb
refactor(ai): remove test stubs in favor of laravel/ai dev dependency
constantinius Apr 2, 2026
6f06a2c
ci: handle laravel/ai dev dependency in CI matrix
constantinius Apr 2, 2026
94cf6f2
ci: add PHPStan baseline entries for optional laravel/ai types
constantinius Apr 2, 2026
3c6f0ca
feat(ai): add chat span lifecycle and step enrichment
constantinius Mar 16, 2026
4b1fa6a
ci: add PHPStan baseline entries for chat span types
constantinius Apr 2, 2026
27c390a
feat(ai): instrument tool execution spans and definitions
constantinius Mar 16, 2026
4c89ea0
fix(ai): align tool definition test with HasTools gating
constantinius Mar 17, 2026
1e34147
ci: add PHPStan baseline entries for tool span types
constantinius Apr 2, 2026
bcaf478
feat(ai): capture messages, attachments, and redaction metadata
constantinius Mar 16, 2026
7d9054f
fix(ai): use array attachments in attachment handling test
constantinius Mar 17, 2026
1c5d398
ci: add PHPStan baseline entries for message redaction types
constantinius Apr 2, 2026
77168f8
feat(ai): add embeddings instrumentation and CI compatibility
constantinius Mar 16, 2026
1dd7a83
ci: add PHPStan baseline entries for embeddings types
constantinius Apr 2, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,11 @@ jobs:
- name: Install Composer dependencies
run: |
# friendsofphp/php-cs-fixer: No need for this package to run phpunit and it conflicts with older Laravel versions
# laravel/ai: Only supports PHP 8.4+ and Laravel 12, remove globally and re-add below where supported
composer remove friendsofphp/php-cs-fixer laravel/ai --dev --no-interaction --no-update

# laravel/pennant: Does not yet support Laravel 13
# laravel/octane: Does not yet support Laravel 13
composer remove friendsofphp/php-cs-fixer --dev --no-interaction --no-update
[[ "${{ matrix.packages.laravel }}" == "^13.0" ]] && composer remove laravel/pennant laravel/octane --dev --no-interaction --no-update || true

# Require the correct versions we want to run phpunit for
Expand All @@ -76,12 +78,21 @@ jobs:
"orchestra/testbench:${{ matrix.packages.testbench }}" \
--no-interaction --no-update

# Re-require laravel/ai for supported combinations (PHP 8.4+ and Laravel 12)
if [ "${{ matrix.packages.laravel }}" == "^12.0" ] && ([ "${{ matrix.php }}" == "8.4" ] || [ "${{ matrix.php }}" == "8.5" ]); then
composer require "laravel/ai:^0.1.5" --dev --no-interaction --no-update
fi

# Actually run the composer installation
composer install --no-interaction --prefer-dist --no-progress

- name: Run phpunit
run: vendor/bin/phpunit --coverage-clover=coverage.xml --coverage-filter=src/Sentry

- name: Run AI integration tests
if: matrix.packages.laravel == '^12.0' && (matrix.php == '8.4' || matrix.php == '8.5')
run: vendor/bin/phpunit test/Sentry/Features/AiIntegrationTest.php

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
Expand Down Expand Up @@ -177,7 +188,8 @@ jobs:
# laravel/folio: Only supported on PHP 8.1 + Laravel 10.0 and above
# laravel/pennant: Only supported on PHP 8.1 + Laravel 10.0 and above
# laravel/octane: Only supported on PHP 8.1 + Laravel 10.10.1 and above
composer remove friendsofphp/php-cs-fixer livewire/livewire laravel/folio laravel/pennant laravel/octane --dev --no-interaction --no-update
# laravel/ai: Only supported on PHP 8.4+ and Laravel 12
composer remove friendsofphp/php-cs-fixer livewire/livewire laravel/folio laravel/pennant laravel/octane laravel/ai --dev --no-interaction --no-update

# Require the correct versions we want to run phpunit for
composer require \
Expand Down
10 changes: 8 additions & 2 deletions .github/workflows/cs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ jobs:
php-version: '8.3'

- name: Install dependencies
run: composer update --no-progress --no-interaction --prefer-dist
run: |
# laravel/ai: Only supported on PHP 8.4+
composer remove laravel/ai --dev --no-interaction --no-update
composer update --no-progress --no-interaction --prefer-dist

- name: Run script
run: vendor/bin/php-cs-fixer fix --verbose --diff --dry-run
Expand All @@ -42,7 +45,10 @@ jobs:
php-version: '8.3'

- name: Install dependencies
run: composer update --no-progress --no-interaction --prefer-dist
run: |
# laravel/ai: Only supported on PHP 8.4+
composer remove laravel/ai --dev --no-interaction --no-update
composer update --no-progress --no-interaction --prefer-dist

- name: Run script
run: vendor/bin/phpstan analyse
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
"require-dev": {
"friendsofphp/php-cs-fixer": "^3.11",
"guzzlehttp/guzzle": "^7.2",
"laravel/ai": "^0.1.5",
"laravel/folio": "^1.1",
"laravel/framework": "^6.0 | ^7.0 | ^8.0 | ^9.0 | ^10.0 | ^11.0 | ^12.0 | ^13.0",
"laravel/octane": "^2.15",
Expand Down
15 changes: 15 additions & 0 deletions config/sentry.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,21 @@
// This is required to capture any spans that are created after the response has been sent like queue jobs dispatched using `dispatch(...)->afterResponse()` for example
'continue_after_response' => env('SENTRY_TRACE_CONTINUE_AFTER_RESPONSE', true),

// Capture AI agent interactions as spans (requires laravel/ai)
'gen_ai' => env('SENTRY_TRACE_GEN_AI_ENABLED', true),

// Capture AI invoke_agent spans
'gen_ai_invoke_agent' => env('SENTRY_TRACE_GEN_AI_INVOKE_AGENT_ENABLED', true),

// Capture AI chat spans
'gen_ai_chat' => env('SENTRY_TRACE_GEN_AI_CHAT_ENABLED', true),

// Capture AI execute_tool spans
'gen_ai_execute_tool' => env('SENTRY_TRACE_GEN_AI_EXECUTE_TOOL_ENABLED', true),

// Capture AI embeddings spans
'gen_ai_embeddings' => env('SENTRY_TRACE_GEN_AI_EMBEDDINGS_ENABLED', true),

// Enable the tracing integrations supplied by Sentry (recommended)
'default_integrations' => env('SENTRY_TRACE_DEFAULT_INTEGRATIONS_ENABLED', true),
],
Expand Down
75 changes: 75 additions & 0 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -99,3 +99,78 @@ parameters:
message: "#^Class Laravel\\\\Lumen\\\\Application not found\\.$#"
count: 2
path: src/Sentry/Laravel/Tracing/ServiceProvider.php

-
message: "#^Parameter \\$event of method Sentry\\\\Laravel\\\\Features\\\\AiIntegration\\:\\:handlePromptingAgentForTracing\\(\\) has invalid type Laravel\\\\Ai\\\\Events\\\\PromptingAgent\\.$#"
count: 1
path: src/Sentry/Laravel/Features/AiIntegration.php

-
message: "#^Parameter \\$event of method Sentry\\\\Laravel\\\\Features\\\\AiIntegration\\:\\:handleAgentPromptedForTracing\\(\\) has invalid type Laravel\\\\Ai\\\\Events\\\\AgentPrompted\\.$#"
count: 1
path: src/Sentry/Laravel/Features/AiIntegration.php

-
message: "#^Parameter \\$agent of method Sentry\\\\Laravel\\\\Features\\\\AiIntegration\\:\\:resolveAgentAttribute\\(\\) has invalid type Laravel\\\\Ai\\\\Contracts\\\\Agent\\.$#"
count: 1
path: src/Sentry/Laravel/Features/AiIntegration.php

-
message: "#^Parameter \\$usage of method Sentry\\\\Laravel\\\\Features\\\\AiIntegration\\:\\:setTokenUsage\\(\\) has invalid type Laravel\\\\Ai\\\\Responses\\\\Data\\\\Usage\\.$#"
count: 1
path: src/Sentry/Laravel/Features/AiIntegration.php

-
message: "#^Parameter \\$response of method Sentry\\\\Laravel\\\\Features\\\\AiIntegration\\:\\:enrichChatSpansWithStepData\\(\\) has invalid type Laravel\\\\Ai\\\\Responses\\\\AgentResponse\\.$#"
count: 1
path: src/Sentry/Laravel/Features/AiIntegration.php

-
message: "#^Parameter \\$provider of method Sentry\\\\Laravel\\\\Features\\\\AiIntegration\\:\\:resolveProviderUrlPrefix\\(\\) has invalid type Laravel\\\\Ai\\\\Providers\\\\Provider\\.$#"
count: 1
path: src/Sentry/Laravel/Features/AiIntegration.php

-
message: "#^Parameter \\$event of method Sentry\\\\Laravel\\\\Features\\\\AiIntegration\\:\\:handleInvokingToolForTracing\\(\\) has invalid type Laravel\\\\Ai\\\\Events\\\\InvokingTool\\.$#"
count: 1
path: src/Sentry/Laravel/Features/AiIntegration.php

-
message: "#^Parameter \\$event of method Sentry\\\\Laravel\\\\Features\\\\AiIntegration\\:\\:handleToolInvokedForTracing\\(\\) has invalid type Laravel\\\\Ai\\\\Events\\\\ToolInvoked\\.$#"
count: 1
path: src/Sentry/Laravel/Features/AiIntegration.php

-
message: "#^Parameter \\$agent of method Sentry\\\\Laravel\\\\Features\\\\AiIntegration\\:\\:resolveToolDefinitions\\(\\) has invalid type Laravel\\\\Ai\\\\Contracts\\\\Agent\\.$#"
count: 1
path: src/Sentry/Laravel/Features/AiIntegration.php

-
message: "#^Class Laravel\\\\Ai\\\\Contracts\\\\HasTools not found\\.$#"
count: 1
path: src/Sentry/Laravel/Features/AiIntegration.php

-
message: "#^Parameter \\$tool of method Sentry\\\\Laravel\\\\Features\\\\AiIntegration\\:\\:resolveToolDefinition\\(\\) has invalid type Laravel\\\\Ai\\\\Contracts\\\\Tool\\.$#"
count: 1
path: src/Sentry/Laravel/Features/AiIntegration.php

-
message: "#^Parameter \\$prompt of method Sentry\\\\Laravel\\\\Features\\\\AiIntegration\\:\\:resolveAttachments\\(\\) has invalid type Laravel\\\\Ai\\\\Prompts\\\\AgentPrompt\\.$#"
count: 1
path: src/Sentry/Laravel/Features/AiIntegration.php

-
message: "#^Parameter \\$agent of method Sentry\\\\Laravel\\\\Features\\\\AiIntegration\\:\\:resolveAgentInstructions\\(\\) has invalid type Laravel\\\\Ai\\\\Contracts\\\\Agent\\.$#"
count: 1
path: src/Sentry/Laravel/Features/AiIntegration.php

-
message: "#^Parameter \\$event of method Sentry\\\\Laravel\\\\Features\\\\AiIntegration\\:\\:handleGeneratingEmbeddingsForTracing\\(\\) has invalid type Laravel\\\\Ai\\\\Events\\\\GeneratingEmbeddings\\.$#"
count: 1
path: src/Sentry/Laravel/Features/AiIntegration.php

-
message: "#^Parameter \\$event of method Sentry\\\\Laravel\\\\Features\\\\AiIntegration\\:\\:handleEmbeddingsGeneratedForTracing\\(\\) has invalid type Laravel\\\\Ai\\\\Events\\\\EmbeddingsGenerated\\.$#"
count: 1
path: src/Sentry/Laravel/Features/AiIntegration.php
1 change: 1 addition & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<testsuites>
<testsuite name="Sentry Laravel Test Suite">
<directory>./test/Sentry/</directory>
<exclude>./test/Sentry/Features/AiIntegrationTest.php</exclude>
</testsuite>
</testsuites>
</phpunit>
Loading
Loading