Zero-config distributed tracing and performance monitoring for Laravel applications.
- Zero Configuration - Works out of the box with sensible defaults
- Automatic Instrumentation - No code changes needed
- HTTP Request Tracing - Track every request, route, and middleware
- Database Query Monitoring - See every query with actual SQL and bindings
- Queue Job Tracking - Monitor Laravel jobs and queues
- Slow Query Detection - Automatically highlight slow database queries
- Error Tracking - Capture exceptions with full context
- Low Overhead - < 5% performance impact
composer require tracekit/laravel-apmphp artisan tracekit:installTRACEKIT_API_KEY=your-api-key-here
TRACEKIT_SERVICE_NAME=my-laravel-app
# Optional: Custom endpoint (defaults to https://app.tracekit.dev/v1/traces)
# TRACEKIT_ENDPOINT=https://your-custom-endpoint.com/v1/tracesGet your API key at https://app.tracekit.dev
Your Laravel app is now automatically traced. Visit your TraceKit dashboard to see your traces.
Publish the configuration file:
php artisan vendor:publish --tag=tracekit-configThis creates config/tracekit.php where you can customize:
Laravel 12 changed how middleware is registered. TraceKit attempts to register middleware automatically for all Laravel versions (10, 11, and 12).
If automatic registration doesn't work, you can manually add the TraceKit middleware to your bootstrap/app.php:
use Illuminate\Foundation\Application;
use Illuminate\Foundation\Configuration\Middleware;
use TraceKit\Laravel\Middleware\TracekitMiddleware;
return Application::configure(basePath: dirname(__DIR__))
->withMiddleware(function (Middleware $middleware) {
$middleware->web(append: [
TracekitMiddleware::class,
]);
$middleware->api(append: [
TracekitMiddleware::class,
]);
})
// ... rest of your configuration
->create();For most cases, the automatic registration via the service provider should work without any manual configuration.
return [
// Enable/disable tracing
'enabled' => env('TRACEKIT_ENABLED', env('APP_ENV') !== 'local'),
// Your TraceKit API key
'api_key' => env('TRACEKIT_API_KEY', ''),
// OTLP endpoint for sending traces
'endpoint' => env('TRACEKIT_ENDPOINT', 'https://app.tracekit.dev/v1/traces'),
// Service name as it appears in TraceKit
'service_name' => env('TRACEKIT_SERVICE_NAME', env('APP_NAME', 'laravel-app')),
// Sample rate (0.0 to 1.0)
'sample_rate' => env('TRACEKIT_SAMPLE_RATE', 1.0),
// Enable/disable specific features
'features' => [
'http' => env('TRACEKIT_HTTP_ENABLED', true),
'database' => env('TRACEKIT_DATABASE_ENABLED', true),
'cache' => env('TRACEKIT_CACHE_ENABLED', true), // Coming soon
'queue' => env('TRACEKIT_QUEUE_ENABLED', true),
'redis' => env('TRACEKIT_REDIS_ENABLED', true), // Coming soon
],
// Routes to ignore
'ignored_routes' => [
'/health',
'/up',
'/_healthz',
],
// Slow query threshold (ms)
'slow_query_threshold' => env('TRACEKIT_SLOW_QUERY_MS', 100),
// Include query bindings in traces
'include_query_bindings' => env('TRACEKIT_INCLUDE_BINDINGS', true),
];Every HTTP request is automatically traced with:
- Route name and URI
- HTTP method and status code
- Request duration
- User agent and client IP
- Query parameters
- Response size
All database queries are traced with:
- Actual SQL with bound parameters
- Query duration
- Slow query highlighting (configurable threshold)
- Connection name and database
Laravel queue jobs are traced with:
- Job class name
- Queue name and connection
- Job status (completed/failed)
- Execution time
- Failure reasons and exceptions
All exceptions are automatically captured with:
- Exception type and message
- Full stack trace
- Request context
- User information
The following features are planned for future releases:
- Cache Operations - Redis, Memcached, and file cache tracing
- Redis Commands - Direct Redis command tracing
- External HTTP Calls - Outgoing HTTP request tracking
You can create custom traces in your code:
use TraceKit\Laravel\TracekitClient;
class MyController extends Controller
{
public function myMethod(TracekitClient $tracekit)
{
$span = $tracekit->startSpan('my-custom-operation', null, [
'user.id' => auth()->id(),
'custom.attribute' => 'value',
]);
try {
// Your code here
$result = $this->doSomething();
$tracekit->endSpan($span, [
'result.count' => count($result),
]);
} catch (\Exception $e) {
$tracekit->recordException($span, $e);
$tracekit->endSpan($span, [], 'ERROR');
throw $e;
}
}
}Disable tracing in local development:
# .env.local
TRACEKIT_ENABLED=falseEnable only specific features:
TRACEKIT_HTTP_ENABLED=true
TRACEKIT_DATABASE_ENABLED=true
TRACEKIT_CACHE_ENABLED=true
TRACEKIT_QUEUE_ENABLED=false
TRACEKIT_REDIS_ENABLED=trueTrace only a percentage of requests (e.g., 10%):
TRACEKIT_SAMPLE_RATE=0.1TraceKit APM is designed to have minimal performance impact:
- < 5% overhead on average request time
- Asynchronous trace sending (doesn't block responses)
- Automatic batching and compression
- Configurable sampling for high-traffic apps
- Sensitive data handling: Query bindings can be disabled
- Secure transmission: HTTPS only
- API key authentication
- No PII collected by default
Disable query bindings:
TRACEKIT_INCLUDE_BINDINGS=false- PHP 8.1 or higher
- Laravel 10.x, 11.x, or 12.x
- Documentation: https://app.tracekit.dev/docs
- Issues: https://github.com/Tracekit-Dev/laravel-apm/issues
- Email: support@tracekit.dev
MIT License. See LICENSE for details.
Built with ❤️ by the TraceKit team.