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

Nightwatch Laravel Package

laravel/nightwatch

Laravel Nightwatch package for Laravel apps: collects performance and application metrics and securely sends them to the hosted Nightwatch monitoring platform, providing deep Laravel-optimized insights into runtime behavior and overall health.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture Fit

  • Observability-First Design: The package is purpose-built for Laravel, integrating seamlessly with its core components (requests, queues, jobs, scheduled tasks, and exceptions). It leverages Laravel’s event system, middleware stack, and service container, making it a natural fit for applications prioritizing observability.
  • Minimal Overhead: Designed for low-impact instrumentation, with configurable sampling rates (e.g., NIGHTWATCH_COMMAND_SAMPLE_RATE, NIGHTWATCH_SCHEDULED_TASK_SAMPLE_RATE) to balance granularity and performance.
  • Context-Aware Metrics: Captures contextual data (authenticated users, request payloads, headers, and query details) for richer debugging, aligning with modern APM (Application Performance Monitoring) best practices.
  • Extensibility: Supports custom filter/redact callbacks, allowing TPMs to tailor data collection (e.g., PII redaction, sensitive field exclusion) without modifying core logic.

Integration Feasibility

  • Laravel-Centric: Built for Laravel’s ecosystem (v10–13, PHP 8.1–8.5, Octane support), reducing friction in monolithic or microservice architectures where Laravel is the primary runtime.
  • Non-Invasive: Uses Laravel’s service provider bootstrapping and event listeners, avoiding invasive modifications to business logic. Example:
    // config/nightwatch.php
    'sample_rates' => [
        'commands' => 0.1, // 10% sampling
        'scheduled_tasks' => 0.5, // 50% sampling
    ],
    
  • Hosted Backend: Offloads storage/analysis to Nightwatch’s SaaS platform, eliminating self-managed infrastructure for metrics processing.

Technical Risk

  • Vendor Lock-in: Tight coupling with Nightwatch’s proprietary format/analysis may complicate migration to alternative APMs (e.g., New Relic, Datadog). Mitigate by:
    • Exporting raw metrics via Nightwatch::digest() for custom processing.
    • Evaluating Nightwatch’s open-source agent guidelines for extensibility.
  • Sampling Trade-offs: Aggressive sampling (e.g., 100%) may impact performance. Validate with load testing, especially for high-throughput queues or scheduled tasks.
  • Octane-Specific Quirks: Octane (Laravel’s async server) requires explicit configuration (e.g., ignoring octane:status commands) to avoid noise. Test in staging with Octane enabled.
  • Data Privacy: Sensitive data (e.g., request payloads, exceptions) is transmitted to Nightwatch. Ensure compliance with:
    • Redaction: Use Nightwatch::redact() for PII.
    • Filtering: Exclude non-critical endpoints via Nightwatch::ignore().

Key Questions

  1. Observability Goals:
    • Are we prioritizing performance metrics (e.g., request latency, queue depth) or error tracking (e.g., exception context)?
    • Do we need custom metrics beyond Laravel’s defaults (e.g., business-specific KPIs)?
  2. Sampling Strategy:
    • What sampling rates align with our SLA requirements (e.g., 99.9% availability)?
    • Should sampling vary by environment (e.g., 100% in staging, 10% in production)?
  3. Data Retention:
    • How long should metrics be stored in Nightwatch vs. archived locally?
  4. Cost:
    • What is the expected volume of metrics (e.g., requests/hour) and Nightwatch’s pricing tier?
  5. Alternatives:
    • Have we compared Nightwatch to open-source options (e.g., Laravel Telescope + custom exporters) or commercial APMs?
  6. Compliance:
    • Are there regulatory constraints (e.g., GDPR) on transmitting request payloads/exceptions?

Integration Approach

Stack Fit

  • Laravel Core: Native support for:
    • HTTP: Middleware-based request tracking (headers, payloads, latency).
    • Queues: Job/event correlation with authenticated users or requests.
    • Scheduled Tasks: Sub-minute frequency capture.
    • Exceptions: Stack traces with redacted sensitive data.
  • Octane: Optimized for async workers (e.g., excluding bootstrapping time from metrics).
  • Testing: Compatible with Laravel’s testing tools (e.g., FakeTcpStream for queue simulations).
  • CI/CD: Integrates with deploy tracking via nightwatch:deploy Artisan command and NIGHTWATCH_DEPLOY env var (supports Vapor fallbacks).

Migration Path

  1. Pilot Phase:
    • Install in a non-production environment (e.g., staging) with conservative sampling (e.g., 10%).
    • Validate metrics coverage for critical paths (e.g., checkout flows, API endpoints).
    • Test the nightwatch:deploy command with CI/CD pipelines.
  2. Gradual Rollout:
    • Enable sampling for high-impact areas first (e.g., queues, scheduled tasks).
    • Use Nightwatch::ignore() to exclude low-value endpoints (e.g., health checks).
  3. Full Adoption:
    • Adjust sampling rates based on pilot data.
    • Configure custom redaction/filtering for PII or sensitive data.

Compatibility

Component Compatibility Notes
Laravel Version 10.x–13.x Tested in CI; backport for older versions may require dependency tweaks.
PHP Version 8.1–8.5 PHP 8.5 support added in v1.20.0.
Octane Supported Excludes bootstrapping time by default.
Queues Database, Redis, SQS, etc. Correlates jobs with requests/users.
Scheduled Tasks Laravel Task Scheduling Sub-minute frequency capture.
Third-Party Packages Low risk (event-based) May require Nightwatch::ignore() for non-Laravel events.

Sequencing

  1. Prerequisites:
    • Laravel application with PHP 8.1+.
    • Nightwatch account and API token (NIGHTWATCH_TOKEN).
  2. Installation:
    composer require laravel/nightwatch
    php artisan vendor:publish --provider="Laravel\Nightwatch\NightwatchServiceProvider"
    
  3. Configuration:
    • Set NIGHTWATCH_TOKEN in .env.
    • Configure config/nightwatch.php (sample rates, ignored routes, redaction rules).
  4. Testing:
    • Validate metrics in Nightwatch dashboard for key workflows.
    • Test nightwatch:deploy with a manual deploy.
  5. Monitoring:
    • Set up alerts for critical metrics (e.g., error rates, latency spikes).
  6. Optimization:
    • Adjust sampling rates based on performance impact.
    • Fine-tune redaction/filtering for compliance.

Operational Impact

Maintenance

  • Low Effort:
    • Minimal manual intervention required post-integration (automatic metric collection).
    • Updates are version-locked via Composer; major versions require testing.
  • Configuration-Driven:
    • Sampling rates, ignored routes, and redaction rules can be managed via config/env vars.
    • Example:
      // config/nightwatch.php
      'ignored_routes' => [
          'health',
          'ping',
      ],
      'redact' => [
          'request' => ['password', 'credit_card'],
      ],
      
  • Dependency Updates:
    • Monitor Laravel/Nightwatch releases for breaking changes (e.g., PHP 8.5 support in v1.20.0).
    • Use composer why-not laravel/nightwatch to check for version conflicts.

Support

  • Troubleshooting:
    • Metrics Not Appearing:
      • Verify NIGHTWATCH_TOKEN is set.
      • Check Laravel logs for Nightwatch errors (e.g., connection issues).
      • Use Nightwatch::digest() to manually trigger payload transmission.
    • High Latency:
      • Reduce sampling rates or exclude heavy endpoints.
      • Monitor nightwatch:digest queue delays.
    • Data Privacy Issues:
      • Audit redaction rules and ignored_routes.
  • Vendor Support:
    • Official Laravel package; escalate issues via GitHub or Nightwatch’s support channels.
    • Community-driven (350+ stars) with active maintenance (last release: 2026-04-01).

Scaling

  • Performance:
    • Sampling: Mitigates overhead; adjust rates based on load (e.g., 10% for high-traffic APIs).
    • Batch Processing: Uses buffered payload transmission to minimize network calls.
    • Concurrency: Supports up to 5 concurrent requests by default (configurable).
  • Cost:
    • Scales with metric volume; evaluate Nightwatch’s pricing for expected throughput
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.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport