A proper Symfony Bundle for Symfony 6.4 and 7.x with semantic YAML/XML configuration, DI container integration, and event subscribers for automated request/console tracing.
Installation
composer require logtide/logtide-symfony
If you're using Symfony Flex, the bundle is registered automatically.
Otherwise, add it to config/bundles.php:
<?php
// config/bundles.php
return [
// ...
LogTide\Symfony\LogtideBundle::class => ['all' => true],
]; Quick Start
Add your DSN to .env:
LOGTIDE_DSN=https://[email protected] Create the bundle configuration:
# config/packages/logtide.yaml
logtide:
dsn: '%env(LOGTIDE_DSN)%'
environment: '%kernel.environment%' That's it! The bundle registers the Hub, event subscribers, and integrations automatically.
Configuration
# config/packages/logtide.yaml
logtide:
dsn: '%env(LOGTIDE_DSN)%'
service: 'my-symfony-app' # default: 'symfony'
environment: '%kernel.environment%'
release: '1.2.3'
# Batching
batch_size: 100 # default: 100
flush_interval: 5000 # ms, default: 5000
max_buffer_size: 10000 # default: 10000
max_retries: 3 # default: 3
# Tracing
traces_sample_rate: 1.0 # 0.0-1.0, default: 1.0
# Privacy
send_default_pii: false # default: false
# Debug
debug: false # default: false Configuration Reference
| Option | Type | Default | Description |
|---|---|---|---|
dsn | string | — | Data Source Name |
service | string | 'symfony' | Service name |
environment | string | — | Deployment environment |
release | string | — | App version |
batch_size | int | 100 | Max events per batch (min: 1) |
flush_interval | int | 5000 | Flush interval in ms (min: 100) |
traces_sample_rate | float | 1.0 | Trace sampling rate (0.0–1.0) |
send_default_pii | bool | false | Send PII (IP, cookies, etc.) |
debug | bool | false | Enable internal debug logging |
Request Subscriber
The RequestSubscriber automatically handles scope lifecycle
per HTTP request:
- • Pushes a new scope on
kernel.request - • Extracts
traceparentheader for distributed tracing - • Starts a SERVER span with HTTP method, route, and URL attributes
- • Captures exceptions on
kernel.exception - • Finishes the span and pops the scope on
kernel.response - • Injects
traceparentinto outgoing response headers
Console Subscriber
Requires symfony/console. Automatically traces Artisan-like
console commands:
- • Creates a span for each command on
console.command - • Captures errors on
console.error - • Finishes the span on
console.terminate
Doctrine Integration
Requires doctrine/dbal. Records SQL queries as breadcrumbs
with query text, parameters, and execution time.
<?php
// Doctrine queries are automatically recorded as breadcrumbs:
// {
// type: "query",
// category: "doctrine",
// message: "SELECT u.* FROM users u WHERE u.id = ?",
// data: { duration_ms: 2.5, params: [123] }
// } Using the Hub
The HubInterface is registered as a service in the DI container.
Inject it into your services or controllers:
<?php
namespace App\Controller;
use LogTide\Enum\LogLevel;
use LogTide\State\HubInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
class OrderController extends AbstractController
{
public function __construct(
private readonly HubInterface $hub,
) {}
public function checkout(): Response
{
$this->hub->captureLog(LogLevel::INFO, 'Checkout started', [
'user_id' => $this->getUser()->getId(),
]);
try {
// ... process order
} catch (\Throwable $e) {
$this->hub->captureException($e);
throw $e;
}
return $this->json(['status' => 'ok']);
}
} You can also use the procedural API anywhere in your code:
<?php
use function LogTide\{info, error, captureException, addBreadcrumb};
use LogTide\Breadcrumb\Breadcrumb;
use LogTide\Enum\BreadcrumbType;
addBreadcrumb(new Breadcrumb(BreadcrumbType::DEFAULT, 'Processing order', category: 'app'));
info('Order processed', ['order_id' => $orderId]); Best Practices
environment: '%kernel.environment%' in the config
to automatically pick up dev, prod,
or test.
LogTide\State\HubInterface into your services
via constructor injection. Autowiring resolves it automatically.
LOGTIDE_DSN environment variable is available
to your Messenger worker processes for background job monitoring.