ryderasking/laravel-ai-trace
Composer 安装命令:
composer require ryderasking/laravel-ai-trace
包简介
LangSmith-style waterfall tracing for Laravel AI SDK workloads.
README 文档
README
Laravel AI Trace is a tracing and debugging package for AI workflows built with Laravel AI SDK (laravel/ai).
It captures full trace -> span -> event lifecycle data with SDK-native hooks so you can inspect execution order, retries, tool calls, streaming milestones, failures, and timing with waterfall-style visibility.
The dashboard provides period-based trend cards, a filterable trace explorer, and quick drill-in links for incident investigation and performance triage.
Compatibility
- Laravel:
12+(currently tested on12.xand13.x) - PHP:
8.3+ - Livewire:
3.6+(including4.x) - Laravel AI SDK (
laravel/ai): currently validated againstv0.3.2
How It Works
Laravel AI Trace subscribes to Laravel AI SDK lifecycle events (for example agent start/end, tool start/end, stream completion, and failover events), then:
- Correlates each callback to a trace and active span context.
- Persists traces, spans, and events in relational tables.
- Deduplicates repeated callbacks inside a configurable TTL window.
- Applies privacy mode/redaction before storing sensitive content.
- Serves dashboard/query data through package services.
This package is SDK-native by design. It does not use HTTP fallback instrumentation.
Dashboard Stack
The dashboard is package-owned UI and uses:
- Livewire components for card rendering, polling, filters, and URL-backed state
- Blade components for layout, cards, tables, and inspector primitives
- Alpine.js + Chart.js for chart interactions and dataset updates
- Tailwind CSS for styling (with compiled package assets)
The design is inspired by Laravel Pulse, but the dashboard does not require a runtime dependency on laravel/pulse.
Installation
- Install Laravel AI SDK (if not already installed):
composer require laravel/ai
- Install Laravel AI Trace:
composer require ryderasking/laravel-ai-trace
- Publish package configuration and migrations:
php artisan vendor:publish --tag=ai-trace-config php artisan vendor:publish --tag=ai-trace-migrations
- Run migrations:
php artisan migrate
- Optional smoke test:
php artisan ai-trace:smoke
Dashboard Authorization Setup
Dashboard authorization is controlled by the host application via gate.
By default, Laravel AI Trace checks gate viewAiTrace (ai-trace.dashboard.authorization_gate). Define it in your AppServiceProvider:
<?php namespace App\Providers; use App\Models\User; use Illuminate\Support\Facades\Gate; use Illuminate\Support\ServiceProvider; class AppServiceProvider extends ServiceProvider { public function boot(): void { Gate::define('viewAiTrace', function (User $user): bool { return $user->is_admin; }); } }
Behavior details:
- If the configured gate exists, access is decided by that gate.
- If no gate is defined, dashboard access falls back to
localenvironment only. - If
ai-trace.dashboard.enabledisfalse, the dashboard routes return404.
Configuration
Published config file: config/ai-trace.php
Important keys:
ai-trace.enabled: master package toggleai-trace.track_ai_sdk: subscribe/unsubscribe SDK event tracingai-trace.record_content_mode:none,hash,redacted,fullai-trace.sample_rate: trace sampling (0..1)ai-trace.dedup_ttl_seconds: event deduplication windowai-trace.stream.max_events_per_invocation: cap stored stream timeline eventsai-trace.retention_days: retention horizon for stored tracesai-trace.dashboard.*: domain/path/middleware/gate settings
Routes
Dashboard routes are registered by the package service provider:
ai-trace.dashboard:/{dashboard-path}(default path:/ai-trace)ai-trace.dashboard.trace:/{dashboard-path}/traces/{traceId}
Data Model
Core persistence tables:
ai_traces: one row per end-to-end workflowai_spans: one row per operation (agent/tool/operation step)ai_span_events: timeline markers for span-level events
This structure enables parent-child waterfall reconstruction and detailed drilldown inspection.
Production Notes
- Keep
record_content_mode=redacted(or stricter) for sensitive environments. - Use gate-based authorization for all non-local dashboard access.
- Tune
sample_rateand stream event caps based on traffic profile. - Plan retention cleanup strategy based on
retention_daysand compliance needs.
ryderasking/laravel-ai-trace 适用场景与选型建议
ryderasking/laravel-ai-trace 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 12 次下载、GitHub Stars 达 1, 最近一次更新时间为 2026 年 04 月 02 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 ryderasking/laravel-ai-trace 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 ryderasking/laravel-ai-trace 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 12
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 27
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-04-02

