Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Release Profiler Bundle Laravel Package

dakenf/release-profiler-bundle

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Setup

  1. Installation Add the bundle via Composer:

    composer require dakenf/release-profiler-bundle
    

    Register the bundle in config/bundles.php (Symfony 4+):

    return [
        // ...
        Dakenf\ReleaseProfilerBundle\DakenfReleaseProfilerBundle::class => ['all' => true],
    ];
    
  2. Configuration Publish the default config:

    php bin/console dakenf:release-profiler:install
    

    Edit config/packages/dakenf_release_profiler.yaml to enable:

    • request_logging (default: false)
    • error_reporting (default: false)
    • Slack/Email channels (e.g., slack_webhook_url or mailer_transport).
  3. First Use Case Trigger a test error in a controller:

    public function testError()
    {
        throw new \RuntimeException('Test error for ReleaseProfiler');
    }
    

    Verify the error appears in Slack/Email (if configured) or logs.


Implementation Patterns

Core Workflows

  1. Request Logging

    • Enable via request_logging: true in config.
    • Logs include:
      • Request method/URL
      • Headers, POST data, and response time.
    • Use Case: Debugging production issues without exposing sensitive data (sanitize sensitive_data_fields in config).
  2. Error Reporting

    • Enable via error_reporting: true.
    • Captures exceptions, stack traces, and request context.
    • Channels:
      • Slack: Format messages with slack_message_format (e.g., *Error*: {{ exception }}).
      • Email: Use mailer_from and mailer_to; customize subject with mailer_subject.
  3. Integration with Monolog

    • Logs to monolog channel (default: release_profiler).
    • Extend handlers in config/packages/monolog.yaml:
      handlers:
          release_profiler:
              type: stream
              path: "%kernel.logs_dir%/release_profiler.log"
              level: debug
      
  4. Conditional Logging

    • Use environment variables or config flags:
      # config/packages/dakenf_release_profiler.yaml
      enabled: '%env(bool:RELEASE_PROFILER_ENABLED)%'
      

Advanced Patterns

  • Custom Error Handlers Extend the bundle’s ErrorListener to filter exceptions:

    // src/EventListener/CustomErrorListener.php
    namespace App\EventListener;
    
    use Dakenf\ReleaseProfilerBundle\Event\ErrorEvent;
    use Symfony\Component\EventDispatcher\EventSubscriberInterface;
    
    class CustomErrorListener implements EventSubscriberInterface
    {
        public static function getSubscribedEvents()
        {
            return [
                'release_profiler.error' => 'onError',
            ];
        }
    
        public function onError(ErrorEvent $event)
        {
            if ($event->getException() instanceof \Symfony\Component\HttpKernel\Exception\HttpException) {
                $event->stopPropagation(); // Skip reporting for HTTP errors
            }
        }
    }
    
  • Dynamic Slack/Email Recipients Use a service to resolve recipients dynamically:

    # config/packages/dakenf_release_profiler.yaml
    slack_webhook_url: '%env(SLACK_WEBHOOK_URL)%'
    slack_recipients: '@app\Service\SlackRecipientResolver'
    

Gotchas and Tips

Pitfalls

  1. Performance Overhead

    • Request logging adds latency (~5–10ms per request). Disable in dev:
      request_logging: '%kernel.debug% ? false : true'
      
    • Exclude sensitive routes:
      excluded_routes:
          - '^/admin'
          - '^/api/v1/tokens'
      
  2. Slack/Email Delays

    • Webhook timeouts or SMTP issues may drop notifications. Monitor with:
      php bin/console debug:container dakenf_release_profiler.slack_notifier
      
  3. Stack Trace Truncation

    • Long stack traces may be cut off in Slack. Adjust slack_max_message_length (default: 2000).
  4. Configuration Conflicts

    • Ensure monolog is configured before release_profiler in bundles.php to avoid handler conflicts.

Debugging Tips

  • Log Levels Use debug level for verbose output:

    handlers:
        release_profiler:
            level: debug
    
  • Test Locally Simulate errors with:

    php bin/console debug:exception --format=json > error.json
    

    Pipe output to Slack/Email for testing.

  • Clear Logs Rotate logs manually:

    php bin/console debug:config monolog | grep handlers
    

Extension Points

  1. Custom Notifiers Implement Dakenf\ReleaseProfilerBundle\Notifier\NotifierInterface:

    class HipChatNotifier implements NotifierInterface
    {
        public function notify(ErrorEvent $event)
        {
            // Custom HipChat logic
        }
    }
    

    Register in services:

    services:
        App\Notifier\HipChatNotifier:
            tags: ['release_profiler.notifier']
    
  2. Request Data Sanitization Override RequestDataSanitizer to strip PII:

    class CustomSanitizer implements RequestDataSanitizerInterface
    {
        public function sanitize(array $data): array
        {
            unset($data['password'], $data['credit_card']);
            return $data;
        }
    }
    

    Bind in services.yaml:

    Dakenf\ReleaseProfilerBundle\Sanitizer\RequestDataSanitizerInterface: '@App\Sanitizer\CustomSanitizer'
    
  3. Event Subscribers Listen to release_profiler.request or release_profiler.error:

    public static function getSubscribedEvents()
    {
        return [
            'release_profiler.request' => 'onRequest',
            'release_profiler.error'   => 'onError',
        ];
    }
    

Configuration Quirks

  • Environment Variables Prefix with RELEASE_PROFILER_ for consistency:

    slack_webhook_url: '%env(RELEASE_PROFILER_SLACK_WEBHOOK)%'
    
  • Default Values Override defaults in config/packages/dakenf_release_profiler.yaml:

    request_logging:
        enabled: true
        exclude_headers: ['authorization', 'cookie']
    
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
terminal42/code-quality-tools
codifyo/ts-generator-bundle
andydefer/laravel-cluster
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky