Installation:
composer require berriart/apm-bundle
Add to config/bundles.php:
Berriart\APMBundle\BerriartAPMBundle::class => ['all' => true],
Configuration:
Enable Application Insights (or future APM) in config/packages/berriart_apm.yaml:
berriart_apm:
apms:
application_insights:
enabled: true
instrumentation_key: "%env(APP_INSIGHTS_INSTRUMENTATION_KEY)%"
First Use Case: Deploy and verify telemetry in your APM dashboard (e.g., Azure Portal for Application Insights). Check for tracked requests, exceptions, and system metrics.
Automatic Instrumentation:
Manual Telemetry:
Use the APMClient service to send custom events:
$this->container->get('berriart_apm.client')->trackEvent('custom_event', ['key' => 'value']);
Deployment Notifications: Trigger via CLI:
php bin/console berriart:apm:send-message --message="Deployment started" --type=info
berriart_apm.yaml per environment (e.g., berriart_apm_test.yaml).sampling_rate: 0 in config) to reduce noise.Berriart\APMBundle\EventListener\RequestListenerInterface.Beta API Instability:
Performance Overhead:
Configuration Quirks:
.env (e.g., APP_INSIGHTS_INSTRUMENTATION_KEY).Debugging:
berriart_apm:
debug: true
var/log/dev.log (Symfony default).Custom Metrics:
Extend Berriart\APMBundle\Service\APMClient to add custom telemetry:
$client->trackCustomMetric('db.query.time', $durationMs);
Event Listeners:
Subscribe to berriart.apm.event for pre/post-processing:
// src/EventListener/CustomAPMListener.php
public function onAPMEvent(APMEvent $event) {
$event->addContext(['custom_key' => 'value']);
}
APM Service Plugins:
Implement Berriart\APMBundle\Service\APMInterface to add new APM backends (e.g., Datadog).
symfony-monolog-apm (for Monolog integration).snuffleupagus/snuffleupagus (for PHP profiling).How can I help you explore Laravel packages today?