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

Exporter Zipkin Laravel Package

open-telemetry/exporter-zipkin

OpenTelemetry Zipkin Exporter for PHP. Sends OpenTelemetry traces to a Zipkin collector for storage and visualization. Use with the OpenTelemetry PHP SDK to export spans over HTTP, enabling distributed tracing and diagnostics in your applications.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture Fit

  • Observability Strategy Alignment: The package enables distributed tracing for Laravel applications, complementing existing logging/metrics by providing end-to-end request visibility. This is critical for microservices, async workflows (e.g., Laravel queues), and debugging latency issues.
  • OpenTelemetry Ecosystem: Leverages the OpenTelemetry PHP SDK, which is already a standard for modern PHP observability. This ensures future-proofing (e.g., switching exporters without re-instrumenting).
  • Zipkin Compatibility: Bridges Laravel’s PHP stack with Zipkin’s UI/analysis tools, enabling teams already using Zipkin (or tools like Grafana Tempo) to avoid vendor lock-in.
  • Laravel-Specific Gaps: While the package is generic, Laravel’s event-driven architecture (queues, jobs, HTTP middleware) can benefit from custom instrumentation (e.g., auto-tagging queue jobs with trace IDs).

Integration Feasibility

  • Modular Design: The exporter is plug-and-play with OpenTelemetry’s SpanProcessor interface, requiring minimal Laravel code changes.
  • HTTP Transport: Uses async HTTP clients (via php-http/async-client-implementation), which aligns with Laravel’s non-blocking I/O patterns (e.g., queues, async jobs).
  • Configuration Flexibility: Supports:
    • Custom Zipkin endpoints (e.g., self-hosted, cloud-based).
    • Batch processing (reduces export volume).
    • Timeouts (mitigates slow Zipkin servers).
  • Laravel Middleware: Can integrate with Laravel’s HTTP middleware to inject/extract trace context (e.g., X-B3-TraceId headers).

Technical Risk

Risk Mitigation
PHP Version Dependency (8.1+) Laravel 9+ supports PHP 8.1+. If using older Laravel, require a PHP upgrade.
Zipkin Server Unavailability Implement retry logic (e.g., exponential backoff) or fallback buffering (store traces locally if Zipkin is down).
Attribute Casting Issues Validate custom attributes are strings (as per PR #1406).
Performance Overhead Use sampling (e.g., 1–10% of traces) or batch exports to limit impact.
Lack of Laravel-Specific Instrumentation Extend OpenTelemetry’s auto-instrumentation for Laravel components (e.g., queues, HTTP clients).

Key Questions

  1. Zipkin Infrastructure:
    • Is there an existing Zipkin-compatible collector (e.g., Jaeger, Grafana Tempo)?
    • What are the SLA requirements for trace export (latency, reliability)?
  2. Sampling Strategy:
    • Should traces be sampled (e.g., 5% of requests) to reduce volume?
    • How will sampling be configured (head-based, tail-based)?
  3. Laravel Integration Depth:
    • Should all HTTP requests, queue jobs, and commands be traced?
    • Are there custom Laravel events that need trace correlation?
  4. Error Handling:
    • How should failed exports be logged/monitored?
    • Should traces be buffered during Zipkin outages?
  5. Cost vs. Alternatives:
    • Is Zipkin the best fit (vs. OTLP exporters, Datadog, New Relic)?
    • Are there budget constraints for self-hosting Zipkin?

Integration Approach

Stack Fit

  • OpenTelemetry PHP SDK: The package is designed for OpenTelemetry’s PHP SDK, which is already a mature stack in Laravel via:
  • HTTP Clients: Laravel’s Guzzle or Symfony HTTP Client can be reused for Zipkin exports if async transport is configured.
  • Logging Correlation: Traces can be correlated with Laravel logs via:
    • X-B3-TraceId headers in HTTP requests.
    • Custom log formatters (e.g., Monolog processors).
  • Async Workflows: Integrates with Laravel’s queues/jobs by:
    • Auto-instrumenting Illuminate\Bus\Queueable.
    • Injecting trace context into dispatched jobs.

Migration Path

Step Action Laravel Integration Dependencies
1 Upgrade PHP Ensure PHP 8.1+ Laravel 9+
2 Install OpenTelemetry SDK Add to composer.json open-telemetry/sdk
3 Instrument Core Components Auto-instrument HTTP, queues, jobs OpenTelemetry SDK
4 Add Zipkin Exporter Replace/extend exporters open-telemetry/exporter-zipkin
5 Configure Middleware Inject/extract trace headers Laravel HTTP Kernel
6 Validate Traces Test with Zipkin UI Zipkin collector

Example Implementation:

// composer.json
"require": {
    "open-telemetry/sdk": "^1.0",
    "open-telemetry/exporter-zipkin": "^1.2",
    "telemetryphp/telemetry": "^1.0" // Optional: Auto-instrumentation
},

// config/telemetry.php
'exporters' => [
    \OpenTelemetry\Contrib\Zipkin\Exporter\ZipkinExporter::class => [
        'endpoint' => env('ZIPKIN_ENDPOINT', 'http://zipkin:9411/api/v2/spans'),
        'timeout' => 2.0,
        'batch' => [
            'size' => 50,
            'interval' => 1000, // ms
        ],
    ],
],

// app/Providers/AppServiceProvider.php
use OpenTelemetry\SDK\Trace\SpanProcessor\BatchSpanProcessor;
use OpenTelemetry\Contrib\Zipkin\Exporter\ZipkinExporter;

public function boot()
{
    $exporter = new ZipkinExporter(config('telemetry.exporters.zipkin'));
    $provider = \OpenTelemetry\SDK\Trace\Provider::getProvider();
    $provider->addSpanProcessor(new BatchSpanProcessor($exporter));
}

Compatibility

Component Compatibility Notes
PHP 8.1+ ✅ Required Laravel 9+ supports this.
OpenTelemetry SDK v1.0+ ✅ Full Package is built for this version.
Zipkin v2 API ✅ Full Supports modern collectors (Jaeger, Tempo).
Laravel HTTP ✅ Partial Requires middleware for header injection.
Laravel Queues ✅ Partial Needs auto-instrumentation for job tracing.
Async HTTP Clients ✅ Full Uses php-http/async-client-implementation.

Sequencing

  1. Phase 1: Instrumentation
    • Add OpenTelemetry SDK and auto-instrument Laravel’s HTTP layer (routes, middleware).
    • Example: Trace all incoming requests with OpenTelemetry\API\Trace\TracerInterface.
  2. Phase 2: Zipkin Exporter
    • Configure the Zipkin exporter with batch settings and timeout.
    • Test with a local Zipkin instance (e.g., Docker).
  3. Phase 3: Async Workflows
    • Instrument queues/jobs to include trace context.
    • Example: Use telemetryphp/telemetry for queue auto-instrumentation.
  4. Phase 4: Middleware Integration
    • Add middleware to inject/extract trace headers (X-B3-TraceId, X-B3-SpanId).
    • Example:
      // app/Http/Middleware/TraceContext.php
      public function handle($request, Closure $next)
      {
          $traceContext = \OpenTelemetry\API\Trace\Propagation\TextMapPropagator::getInstance()
              ->extract(\OpenTelemetry\API\GlobalPropagation::get(), $request->headerBag);
          // ... inject into current span
          return $next($request);
      }
      
  5. Phase 5: Validation
    • Verify traces appear in Zipkin for:
      • API endpoints.
      • Queue jobs.
      • Background commands.
    • Check for missing attributes or correlation gaps.

Operational Impact

Maintenance

Task Frequency Effort Owner
Exporter Updates Quarterly Low DevOps/Backend
Zipkin Server Monitoring Continuous
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.
craftcms/url-validator
directorytree/privacy-filter-classifier
directorytree/privacy-filter
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony
develia/geo-bundle
dreamzy/livewire-charts
touchestate-sdk/php-sdk
22h/doctrine-garbage-collection-bundle
agtp/agtp-php
agtp/mod-php
splash/sonata-admin
splash/metadata
splash/openapi
splash/scopes
splash/toolkit
testo/output-teamcity
testo/bridge-symfony