Weave 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

Correlation Bundle Laravel Package

aubes/correlation-bundle

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture Fit

  • Distributed Tracing Lightweight Alternative: The bundle provides a minimalist, Symfony-native solution for correlation ID propagation, avoiding the overhead of full APM tools (e.g., OpenTelemetry, Datadog). It aligns well with microservices, event-driven architectures, and worker-based systems (e.g., Messenger, FrankenPHP).
  • Symfony Ecosystem Integration: Designed for Symfony’s dependency injection, HTTP stack, and async workflows (Messenger, Mercure). Leverages Symfony’s ResetInterface for worker safety, making it compatible with long-running processes.
  • Observability-First: Enables correlation across logs (Monolog), HTTP calls (client/server), messaging (Messenger), and UI (Twig/Mercure). Reduces debugging friction by tying disparate events to a single ID.
  • Extensibility: Custom generators and storage seeding allow adaptation to legacy systems or non-standard ID formats (e.g., W3C Trace Context).

Integration Feasibility

  • Low Friction: Auto-registers via Symfony Flex; zero-config works for basic HTTP use cases. Optional integrations (e.g., Monolog) activate only if dependencies exist.
  • Header-Based Propagation: Standard X-Correlation-Id header aligns with industry practices (e.g., AWS X-Ray, Jaeger). Minimal changes to existing HTTP clients/servers.
  • Async Workflows: Messenger integration ensures IDs propagate across queues without manual instrumentation. Worker-mode support (via ResetInterface) prevents ID leakage between requests.
  • Validation: Strict ID validation (printable ASCII, 1–255 chars) reduces runtime errors from malformed inputs.

Technical Risk

  • Dependency on Symfony: Tight coupling to Symfony’s DI, HTTP, and Messenger components limits portability to non-Symfony PHP apps. Migration effort required for polyfills.
  • Generator Overhead: UUID generation (default) adds ~10–50µs latency per request. Hex32 may be faster but less standardized.
  • Storage Scope: Request-scoped storage could cause issues in edge cases (e.g., CLI commands with nested HTTP calls). Requires careful testing of reset() behavior.
  • Optional Integrations: Some features (e.g., Mercure) may introduce circular dependencies if not explicitly configured. Risk of unintended activation.
  • No Sampling: Unlike APMs, this bundle propagates IDs universally (no sampling). May generate excessive metadata in high-throughput systems.

Key Questions

  1. Observability Stack Compatibility:
    • Does the target system use Monolog/Messenger/Mercure? If not, are the optional integrations worth enabling?
    • How will correlation IDs integrate with existing APM tools (e.g., OpenTelemetry)? Will they be treated as trace IDs or custom metadata?
  2. Performance Impact:
    • What is the acceptable latency budget for ID generation? Is UUID overhead tolerable, or should Hex32 be preferred?
    • How will ID propagation affect HTTP client throughput (e.g., batch requests)?
  3. Worker/Async Scenarios:
    • Are there long-running processes (e.g., CLI workers) where ResetInterface must be manually triggered?
    • How will IDs propagate across service boundaries (e.g., gRPC, Kafka) if not using HTTP?
  4. Debugging/Operational Needs:
    • Is the Web Profiler panel sufficient for debugging, or are custom logging/metrics needed?
    • How will correlation IDs be filtered/queried in log aggregation tools (e.g., ELK, Datadog)?
  5. Customization Requirements:
    • Are custom generators needed (e.g., for legacy systems or compliance)? What are the validation constraints?
    • Should the HTTP header name (X-Correlation-Id) be changed to avoid conflicts with existing headers?

Integration Approach

Stack Fit

  • Symfony-Centric: Ideal for greenfield Symfony 6.4+/7.4+/8.x projects or brownfield upgrades. Minimal changes required if already using Messenger, Monolog, or HTTP Client.
  • Microservices: Excellent for distributed systems where requests span multiple services (e.g., API → Queue → Worker → UI).
  • Event-Driven: Messenger integration ensures IDs flow through async workflows (e.g., command buses, event listeners).
  • Hybrid Cloud/On-Prem: Works with FrankenPHP (worker mode) and traditional PHP-FPM. No cloud provider lock-in.

Migration Path

  1. Assessment Phase:
    • Audit existing logging, HTTP client, and async code for correlation ID usage.
    • Identify gaps (e.g., missing IDs in CLI commands, custom HTTP clients).
  2. Pilot Deployment:
    • Install the bundle in a non-production environment (composer require aubes/correlation-bundle).
    • Enable core HTTP features and test ID propagation across 2–3 services.
    • Validate optional integrations (e.g., Monolog) in staging.
  3. Incremental Rollout:
    • Phase 1: Enable HTTP headers and storage. Verify IDs are generated/propagated.
    • Phase 2: Add Monolog integration. Check log aggregation for correlation fields.
    • Phase 3: Enable Messenger/Mercure if using async workflows or real-time updates.
    • Phase 4: Customize generators/configuration (e.g., Hex32, CLI overrides).
  4. Deprecation:
    • Phase out manual correlation ID handling (e.g., hardcoded in services).
    • Update documentation to reflect the new system.

Compatibility

  • Symfony Versions: Tested on 6.4–8.x. Downgrade risks if using newer Symfony features (e.g., attribute-based routing).
  • PHP 8.2+: Requires named arguments, union types, and other PHP 8.2+ features. May need polyfills for older versions.
  • Existing Headers: Conflict risk if X-Correlation-Id is already used. Configurable via header_name.
  • Legacy Code:
    • Services injecting CorrelationIdProviderInterface will work out-of-the-box.
    • Manual ID handling (e.g., Request::get('correlation_id')) may need updates to use the storage.
  • Third-Party Integrations:
    • HTTP clients not using Symfony’s HttpClient (e.g., Guzzle) require manual header injection.
    • Non-Symfony logging systems (e.g., Monolog without Symfony DI) need custom integration.

Sequencing

  1. Core Infrastructure:
    • Deploy to API gateways/entry points first to ensure IDs are generated/propagated upstream.
  2. Async Workers:
    • Configure Messenger integration before rolling out queue-based services.
  3. UI/Client-Side:
    • Enable Twig/Mercure integrations last to avoid breaking changes to templates.
  4. Observability Tools:
    • Update log aggregation queries to include the correlation_id field before enabling Monolog integration.
  5. Custom Logic:
    • Implement custom generators/storage seeding after validating default behavior.

Operational Impact

Maintenance

  • Low Overhead: Minimal runtime cost (~10–50µs per request for ID generation). No persistent storage required.
  • Configuration-Driven: Changes to behavior (e.g., disabling Monolog) require YAML updates, not code changes.
  • Dependency Updates:
    • Bundle follows Symfony’s release cycle. Monitor for breaking changes in major versions.
    • Optional integrations (e.g., Mercure) may require updates if underlying libraries change.
  • Debugging:
    • correlation:debug command provides visibility into active integrations.
    • Web Profiler panel shows ID source (generated vs. provided) and integrations.

Support

  • Error Handling:
    • Invalid correlation IDs throw InvalidCorrelationIdException with clear messages.
    • Worker safety via ResetInterface prevents ID leakage.
  • Monitoring:
    • Track correlation ID generation rates (e.g., Prometheus metric for correlation_ids_generated_total).
    • Alert on missing IDs in critical paths (e.g., failed HTTP responses without headers).
  • Documentation:
    • Internal docs should highlight:
      • How to inject CorrelationIdProviderInterface in services.
      • Custom generator implementation guidelines.
      • Worker/async process reset requirements.
  • Troubleshooting:
    • Common issues:
      • IDs not propagating: Check HTTP headers, Messenger buses, or custom storage resets.
      • Performance spikes: Profile UUID generation or disable optional integrations.
      • Logs missing IDs: Verify Monolog configuration and handler channels.

Scaling

  • Horizontal Scaling:
    • Stateless design (IDs generated per request) scales horizontally without coordination.
    • Worker processes (e.g., Messenger) handle IDs independently via ResetInterface.
  • High Throughput:
    • UUID generation is the primary bottleneck. Consider:
      • Hex32 generator for lower latency.
      • Caching generated IDs in high-frequency paths (though the bundle memoizes by default).
    • Async workers: Ensure reset() is called after processing to avoid ID leakage.
  • Multi-Region Deployments:
    • IDs are self-contained (no central registry). No additional infrastructure needed.
    • Cross-region HTTP calls require explicit header propagation (handled by the bundle).

Failure Modes

| Failure Scenario | Impact | Mitigation | |-------------------------------------|--------------------------------

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.
xiloryx/log-collector
a21ns1g4ts/filament-stripe
la-php/laravel-admin
artisan-build/community-prompts
vleroy/smart
ayles-software/laravel-australian-public-holidays
cboxdk/laravel-id-spatie
cboxdk/laravel-id-billing
cboxdk/laravel-id-billing-bridge
simple-as-fuck/php-performance-log
hsluv/hsluv
seampact/codegen
seampact/hooks
seampact/ir
mehedimi/laravel-amp-mail
happones/laravel-vue-i18n-generator
jwerd/inertia-table
siberfx/flysystem-wasabi
hollyit/token-replace
ippanelcom/laravel-sdk