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

Opentelemetry Laravel Package

open-telemetry/opentelemetry

OpenTelemetry PHP metapackage bundling the API and SDK plus common HTTP exporters (OTLP, Zipkin), a PSR-7 factory (nyholm/psr7), and Symfony HTTP client. Great for trying OpenTelemetry; for production, require needed packages directly.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture Fit

  • Observability Alignment: The OpenTelemetry PHP metapackage aligns well with modern Laravel applications requiring distributed tracing, metrics, and logging. It integrates seamlessly with Laravel’s service container, event system, and HTTP stack (e.g., Symfony HTTP Client, PSR-7).
  • Microservices & Cloud-Native Fit: Ideal for Laravel apps deployed in Kubernetes, serverless (AWS Lambda, Bref), or multi-service architectures where cross-service tracing is critical.
  • Instrumentation Scope: Supports tracing HTTP requests, database queries (via Laravel Query Builder), queue jobs, and custom business events (via Laravel’s events system).

Integration Feasibility

  • Laravel Service Provider: Can be bootstrapped via a custom service provider to auto-instrument core Laravel components (e.g., Illuminate\Http\Request, Illuminate\Database).
  • Middleware Integration: Easily pluggable into Laravel’s middleware pipeline for request/response tracing.
  • Queue Workers: Supports tracing Laravel queue jobs (via Illuminate\Queue) with minimal configuration.
  • PSR-15 Middleware: Compatible with Laravel’s PSR-15 middleware stack (e.g., spatie/laravel-psr-middleware).

Technical Risk

  • Versioning Complexity: The metapackage’s "versionless" design may lead to dependency conflicts if not explicitly pinned in composer.json. Mitigation: Require explicit versions of open-telemetry/opentelemetry-sdk and open-telemetry/opentelemetry-api in production.
  • Exporter Configuration: OTLP/Zipkin exporters require backend infrastructure (e.g., Jaeger, Tempo, or OTLP-compatible collectors). Mitigation: Use Dockerized collectors for local dev or cloud-managed services (e.g., Honeycomb, Datadog).
  • Performance Overhead: Tracing adds latency (~1–5ms per span). Mitigation: Sample traces in production (e.g., 10% of requests) and disable in non-critical paths.
  • Laravel-Specific Gaps: No native Laravel Query Builder instrumentation (unlike spatie/laravel-activitylog). Mitigation: Use open-telemetry/opentelemetry-php-instrumentation for manual instrumentation or extend via events.

Key Questions

  1. Backend Compatibility: Is the target observability backend (e.g., Jaeger, Datadog) OTLP/Zipkin-compatible?
  2. Sampling Strategy: How will traces be sampled (e.g., head-based, tail-based) to balance cost and coverage?
  3. Legacy Integration: Are there existing monitoring tools (e.g., New Relic, AppDynamics) that require adaptation?
  4. Cost Implications: What are the budgeted costs for observability data ingestion/storage?
  5. Team Expertise: Does the team have experience with OpenTelemetry or distributed tracing?

Integration Approach

Stack Fit

  • Laravel Core: Integrates with:
    • Illuminate\Http\Request/Response (via PSR-7 middleware).
    • Illuminate\Database (manual instrumentation or event listeners).
    • Illuminate\Queue (job execution tracing).
    • Illuminate\Events (custom business event tracing).
  • HTTP Clients: Works with Laravel’s built-in HTTP client and Symfony’s HttpClient (included in the metapackage).
  • Testing: Compatible with Laravel’s testing tools (e.g., HttpTests) for trace verification.

Migration Path

  1. Pilot Phase:
    • Install the metapackage in a non-production Laravel app:
      composer require open-telemetry/opentelemetry
      
    • Configure a local OTLP exporter (e.g., otel-collector in Docker) or Zipkin.
    • Instrument a single endpoint (e.g., API route) and verify traces in Jaeger/Tempo.
  2. Gradual Rollout:
    • Add tracing to middleware (e.g., app/Http/Middleware/TracingMiddleware.php).
    • Instrument queue workers and database queries via events.
    • Use environment-based sampling (e.g., OTEL_TRACES_SAMPLER=parentbased_always_on in dev, OTEL_TRACES_SAMPLER=parentbased_256 in prod).
  3. Production Hardening:
    • Replace the metapackage with explicit dependencies in composer.json:
      "open-telemetry/opentelemetry-sdk": "^1.0",
      "open-telemetry/opentelemetry-api": "^1.0",
      "open-telemetry/opentelemetry-exporter-otlp": "^1.0"
      
    • Set up alerts for trace errors (e.g., dropped spans).
    • Document trace IDs in error logs for debugging.

Compatibility

  • Laravel Versions: Tested with Laravel 8+ (PHP 8.0+). May require adjustments for older versions.
  • PHP Extensions: No additional extensions required beyond json and curl (for OTLP).
  • Cloud Providers: Works with AWS X-Ray (via OTLP bridge), Google Cloud Trace, and Azure Monitor.

Sequencing

  1. Instrumentation:
    • Start with HTTP request tracing (lowest effort).
    • Add database/query tracing via Illuminate\Database\Events\QueryExecuted.
    • Instrument queue jobs by wrapping Illuminate\Queue\Jobs\Job execution.
  2. Exporters:
    • Begin with OTLP (future-proof) or Zipkin (simpler setup).
    • Add metrics/logs later if needed (via open-telemetry/opentelemetry-php-instrumentation).
  3. Visualization:
    • Use Jaeger for local dev, Tempo for production.
    • Integrate with Grafana for dashboards.

Operational Impact

Maintenance

  • Dependency Management: Explicitly pin OpenTelemetry packages to avoid version conflicts. Use composer why-not to audit updates.
  • Configuration Drift: Centralize OpenTelemetry config (e.g., config/opentelemetry.php) to avoid hardcoded values.
  • Deprecation Risk: Monitor OpenTelemetry PHP’s GitHub issues for breaking changes.

Support

  • Debugging Traces: Train teams to correlate trace IDs with Laravel logs (e.g., Log::debug("Trace ID: {$traceId}")).
  • Exporter Failures: Implement retry logic for OTLP exporters and monitor otel.exporter.otlp.* metrics.
  • Vendor Support: Leverage community support (GitHub Discussions) or commercial vendors (e.g., Lightstep, Honeycomb) for advanced troubleshooting.

Scaling

  • Sampling: Use probabilistic sampling (e.g., AlwaysOnSampler in dev, ParentBasedSampler in prod) to reduce volume.
  • Batch Exporting: Configure OTLP exporters to batch spans (e.g., export_timeout=5s) to minimize overhead.
  • Resource Limits: Monitor PHP memory usage (memory_get_usage()) when tracing high-volume endpoints.

Failure Modes

Failure Scenario Impact Mitigation
OTLP exporter downtime Lost traces Fallback to file-based exporter (ConsoleExporter).
High cardinality trace attributes Backend overload Sanitize attributes (e.g., mask PII).
Sampling misconfiguration Incomplete observability Validate sampling rules in staging.
Laravel cache clearing Trace context loss Store trace IDs in session/cache with TTL.
PHP worker crashes Dropped spans Use opentelemetry/opentelemetry-php-context for graceful shutdowns.

Ramp-Up

  • Onboarding:
    • Developers: 1-day workshop on tracing fundamentals and Laravel integration.
    • Ops: Document exporter setup (e.g., otel-collector Docker Compose) and alerting rules.
  • Training Materials:
    • Record a demo of tracing a Laravel request from frontend to database.
    • Share a template for custom instrumentation (e.g., tracing a LaravelJob).
  • Adoption Metrics:
    • Track % of endpoints instrumented.
    • Measure mean time to resolve issues using traces (vs. logs alone).
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.
amashukov/lnd-client-php
althinect/enum-permission
andydefer/laravel-actions
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
spatie/mailcoach-vapor