rivium-trace/laravel-sdk
Composer 安装命令:
composer require rivium-trace/laravel-sdk
包简介
RiviumTrace Laravel SDK for error tracking, logging, and performance monitoring
README 文档
README
Official Laravel SDK for RiviumTrace — error tracking, logging, and APM.
Requirements
- PHP 8.1+
- Laravel 10, 11, or 12
- Guzzle 7
Installation
composer require rivium-trace/laravel-sdk
Auto-discovery handles service provider and facade registration.
Configuration
Publish config:
php artisan vendor:publish --tag=riviumtrace-config
Add to .env:
RIVIUMTRACE_API_KEY=rv_live_your_api_key_here RIVIUMTRACE_SERVER_SECRET=rv_srv_your_secret_here RIVIUMTRACE_ENVIRONMENT=production RIVIUMTRACE_RELEASE=0.1.2
Self-Hosted
If you're running RiviumTrace Self-Hosted, add RIVIUMTRACE_API_URL pointing to your server:
RIVIUMTRACE_API_URL=http://your-server:3001 RIVIUMTRACE_API_KEY=rv_live_your_api_key_here RIVIUMTRACE_SERVER_SECRET=rv_srv_your_secret_here RIVIUMTRACE_ENVIRONMENT=production
Everything else works the same — error tracking, logging, APM, middleware.
Usage
Automatic Tracking
RiviumTrace automatically captures:
- Unhandled exceptions through Laravel's exception handler
- HTTP requests through middleware (timing, status, breadcrumbs)
- Slow DB queries as performance spans
Manual Error Capture
use RiviumTrace\Laravel\RiviumTraceFacade as RiviumTrace; try { riskyOperation(); } catch (\Throwable $e) { RiviumTrace::captureException($e, [ 'extra' => ['order_id' => $orderId], ]); } RiviumTrace::captureMessage('Payment processed', [ 'extra' => ['amount' => 99.99], ]);
Breadcrumbs
use RiviumTrace\Laravel\Models\Breadcrumb; RiviumTrace::addBreadcrumb( Breadcrumb::custom('User signed up', 'auth', ['plan' => 'pro']) ); RiviumTrace::addBreadcrumb( Breadcrumb::http('POST', '/api/payments', 201, 450.5) ); RiviumTrace::addBreadcrumb( Breadcrumb::user('checkout_completed', ['items' => 3]) );
User Context
RiviumTrace::setUser([ 'id' => $user->id, 'email' => $user->email, 'name' => $user->name, ]);
Scoped Context
RiviumTrace::withScope(function ($scope) { $scope->setUser(['id' => 'temp-user']); processOrder($order); });
Logging
Add the RiviumTrace channel to config/logging.php:
'channels' => [ 'riviumtrace' => [ 'driver' => 'custom', 'via' => \RiviumTrace\Laravel\Logging\RiviumTraceLogChannel::class, ], 'stack' => [ 'driver' => 'stack', 'channels' => ['daily', 'riviumtrace'], ], ],
Usage:
Log::channel('riviumtrace')->info('Order created', ['order_id' => 123]); Log::channel('riviumtrace')->error('Payment failed', ['reason' => 'declined']); RiviumTrace::info('Processing started'); RiviumTrace::warn('Rate limit approaching', ['current' => 95, 'max' => 100]); RiviumTrace::logError('External API timeout', ['service' => 'stripe']);
Set a source ID for batched log delivery:
RIVIUMTRACE_LOG_SOURCE_ID=my-laravel-api RIVIUMTRACE_LOG_SOURCE_NAME=My Laravel API
Performance Monitoring
use RiviumTrace\Laravel\Performance\PerformanceSpan; $result = RiviumTrace::trackOperation('process_payment', function () use ($order) { return PaymentGateway::charge($order); }, ['operationType' => 'custom', 'tags' => ['provider' => 'stripe']]); RiviumTrace::reportPerformanceSpan( PerformanceSpan::custom([ 'operation' => 'generate_report', 'durationMs' => 1500, 'startTime' => $startTime, 'tags' => ['report_type' => 'monthly'], ]) ); RiviumTrace::reportPerformanceSpan( PerformanceSpan::fromHttpRequest([ 'method' => 'POST', 'url' => 'https://api.stripe.com/v1/charges', 'statusCode' => 200, 'durationMs' => 320, 'startTime' => $startTime, ]) );
Config Reference
| Key | Env Var | Default | Description |
|---|---|---|---|
api_key |
RIVIUMTRACE_API_KEY |
'' |
API key (rv_live_xxx / rv_test_xxx) |
api_url |
RIVIUMTRACE_API_URL |
https://trace.rivium.co |
API URL — set for self-hosted only |
server_secret |
RIVIUMTRACE_SERVER_SECRET |
'' |
Server secret (rv_srv_xxx) |
enabled |
RIVIUMTRACE_ENABLED |
true |
Enable/disable SDK |
environment |
RIVIUMTRACE_ENVIRONMENT |
APP_ENV |
Environment name |
release |
RIVIUMTRACE_RELEASE |
0.1.0 |
Release version |
sample_rate |
RIVIUMTRACE_SAMPLE_RATE |
1.0 |
Error sample rate (0.0-1.0) |
debug |
RIVIUMTRACE_DEBUG |
false |
Debug mode |
timeout |
RIVIUMTRACE_TIMEOUT |
5 |
HTTP timeout (seconds) |
performance.enabled |
RIVIUMTRACE_PERFORMANCE_ENABLED |
true |
Enable APM |
logging.enabled |
RIVIUMTRACE_LOGGING_ENABLED |
true |
Enable logging |
logging.source_id |
RIVIUMTRACE_LOG_SOURCE_ID |
null |
Log source ID |
Ignored Exceptions
By default these exceptions are not reported:
AuthenticationExceptionValidationExceptionNotFoundHttpException- 4xx HTTP exceptions
Customize in config/riviumtrace.php:
'exception_handler' => [ 'ignored_exceptions' => [ \App\Exceptions\BusinessException::class, ], 'report_4xx' => true, ],
Middleware
Auto-added to web and api groups. Disable via config:
'middleware' => ['enabled' => false],
Ignore specific paths:
'middleware' => [ 'ignored_paths' => ['_debugbar/*', 'telescope/*', 'health'], ],
License
MIT
rivium-trace/laravel-sdk 适用场景与选型建议
rivium-trace/laravel-sdk 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 6 次下载、GitHub Stars 达 1, 最近一次更新时间为 2026 年 03 月 06 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「logging」 「performance」 「monitoring」 「laravel」 「apm」 「error-tracking」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 rivium-trace/laravel-sdk 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 rivium-trace/laravel-sdk 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 rivium-trace/laravel-sdk 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
g4 application profiler package
CSS/Javascript Minificator, Compressor and Concatenator for TYPO3 - highly configurable frontend asset optimization for CSS/JS merging, minification and compression with optional body parsing, async/defer loading, inline output, data-ignore exclusions, SRI integrity validation/calculation, external
A Symfony bundle for chameleon-system/sanitycheck
WordPress mu-plugin to remove jQuery Migrate from the list of jQuery dependencies and to allow jQuery to enqueue before </body> instead of in the <head>.
Create link to static resources with cache-breaking segment based on md5 of the file
A Zend Framework module that sets up Monolog for logging in applications.
统计信息
- 总下载量: 6
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 27
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-03-06