Download the PHP package jftecnologia/laravel-tracing without Composer

On this page you can find all versions of the php package jftecnologia/laravel-tracing. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-tracing

Laravel Tracing

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

Lightweight, plug-and-play request tracing for Laravel applications.

Laravel Tracing automatically tracks requests across your application using correlation IDs and request IDs. It seamlessly propagates tracing context through queued jobs, HTTP requests, and external API calls — making it easy to correlate logs, debug distributed systems, and trace user sessions end-to-end.


Table of Contents


Overview

In distributed and monolithic Laravel applications, tracking the origin and flow of requests is essential for debugging, monitoring, and log correlation. Without standardized tracing identifiers, it's difficult to:

Laravel Tracing solves this by automatically attaching tracing headers (correlation ID, request ID) to every request, propagating them through queued jobs, and forwarding them to external services.

Why Use Laravel Tracing?


Features


Requirements


Installation

Step 1: Install via Composer

Step 2: Register Middleware

Important: Laravel 12 does not support automatic middleware registration via package discovery. You must manually register the tracing middleware in your bootstrap/app.php file:

Important Notes:

Alternative: Route-Specific Registration

If you prefer to apply tracing only to specific routes:

Step 3: Publish Configuration (Optional)

To customize tracing behavior (header names, enable/disable features, add custom tracings), publish the configuration file:

This creates config/laravel-tracing.php where you can customize all package settings.

Verification

Make a request to your application and check the response headers:

You should see:


Quick Start

Basic Usage

Access tracing values from anywhere in your application:

Use in Log Context

Log output:

Tracing in Queued Jobs

Tracing values are automatically propagated to queued jobs:

Forward Tracing to External APIs

The external service receives:


Configuration

Configuration File Structure

After publishing the config (php artisan vendor:publish --tag=laravel-tracing-config), you'll have access to config/laravel-tracing.php:

Configuration Options

Global Settings

Key Type Default Description
enabled bool true Master switch for the entire package. When false, all tracing operations are skipped (zero overhead).
accept_external_headers bool false When true, tracing values are read from incoming request headers (forwarded by upstream services). When false, values are always generated fresh.

Environment Variables:

Per-Tracing Settings

Each entry in the tracings array supports:

Key Type Required Description
enabled bool Yes Whether this tracing source is active
header string Yes HTTP header name for reading/writing this value
source string Yes Fully-qualified class name of the TracingSource implementation

Built-In Tracings:

HTTP Client Settings

Key Type Default Description
http_client.enabled bool false When true, Http::withTracing() is available globally. When false, it's opt-in per request.

Environment Variable:

Configuration Examples

Disable Tracing in Local Environment

Customize Header Names

Disable External Header Acceptance (Security)

If your application is publicly exposed and you don't want to accept correlation IDs from untrusted sources:

Security Note: When accept_external_headers is true, the package will use correlation/request IDs sent by clients. Only enable this if you trust your upstream services (API gateways, load balancers, internal services).

Enable HTTP Client Tracing Globally

When enabled, all HTTP requests automatically include tracing headers without calling withTracing():


Usage Examples

Example 1: Accessing Tracing Values in Controllers

Example 2: Using Tracings in Log Context

Log output:

Example 3: Session Persistence (Same Correlation ID Across Requests)

Request 1:

Response:

Request 2 (same session):

Response:

The correlation ID persists across requests from the same session, enabling you to trace all actions from a single user.

Example 4: Tracing in Queued Jobs

Result: All logs from the job execution include the same correlation ID as the dispatching request, making it easy to trace the entire flow.

Example 5: Multiple Jobs Share Correlation ID

All dispatched jobs (ProcessOrder, SendInvoice, UpdateInventory) will share the same correlation ID, allowing you to filter logs by correlation ID to see all related job executions.

Example 6: Forwarding Tracings to External APIs

HTTP request sent to external service:

The external service can now log requests with the same correlation ID, enabling distributed tracing across services.


Custom Tracing Sources

Laravel Tracing is fully extensible. You can add custom tracing sources to track additional context like:

Quick Example: Add User ID Tracing

Step 1: Create Custom Source Class

Step 2: Register in Configuration

Step 3: Use in Your Application

HTTP response headers now include:

Alternative: Runtime Registration

Register custom tracings programmatically in a service provider:

Complete Documentation

For comprehensive documentation on custom tracing sources, including:

See: Extension Architecture Documentation


Troubleshooting

Tracing Headers Not Appearing in Response

Symptoms:

Possible Causes & Solutions:

  1. Package disabled via environment variable

  2. Middleware not registered

    • Verify that you manually registered the middleware in bootstrap/app.php (required for Laravel 12)
    • Ensure the middleware is added to the correct middleware group (web for session-based apps)
    • Check that no conflicting middleware is interfering
  3. Response is a redirect or exception
    • Tracing middleware runs on normal responses. If the response is an exception or early redirect, middleware may not execute.

Debugging Steps:


Tracings Not Accessible in Jobs

Symptoms:

Possible Causes & Solutions:

  1. Queue connection doesn't support serialization

    • Ensure your queue driver supports serialization (database, redis, sqs)
    • sync driver works but processes immediately (no async execution)
  2. Job implements custom serialization

    • If your job implements SerializesModels or custom serialization, ensure you're not interfering with the package's job listeners
  3. Package disabled

Debugging Steps:


Custom Tracing Source Not Loaded

Symptoms:

Possible Causes & Solutions:

  1. Config not published or cache issue

  2. Custom source class not found

    • Ensure the class exists at the path specified in config
    • Check namespace matches config entry
    • Run composer dump-autoload to refresh autoloader
  3. Custom tracing disabled in config

  4. TracingSource contract not implemented correctly
    • Verify your custom source implements all three methods:
      • resolve(Request $request): string
      • headerName(): string
      • restoreFromJob(string $value): string

Debugging Steps:


External Headers Not Accepted

Symptoms:

Solution:

Check the accept_external_headers configuration:

When false, the package ignores external headers and always generates fresh values.


Session Correlation ID Not Persisting

Symptoms:

Possible Causes & Solutions:

  1. Session driver not configured

    • Ensure SESSION_DRIVER is set in .env (cookie, file, redis, etc.)
    • array driver doesn't persist sessions across requests
  2. Session middleware not running

    • Check app/Http/Kernel.php includes \Illuminate\Session\Middleware\StartSession::class
  3. Browser not sending cookies
    • Check Set-Cookie header is included in response
    • Ensure browser accepts cookies (not in incognito/privacy mode)

Debugging Steps:


Frequently Asked Questions

Why use correlation ID vs request ID?

Example:

All three requests share the same correlation ID, allowing you to trace the entire session.

Can I use this with stateless APIs?

Yes. For stateless APIs (no session), correlation IDs are still useful when forwarded from upstream services:

  1. Client sends request with correlation ID:

  2. Your API accepts and uses it (if accept_external_headers is true):

  3. Your API forwards it to downstream services:

This enables end-to-end tracing across multiple stateless services.

How do I integrate with logging?

Laravel Tracing provides tracing values — you add them to your log context:

For automatic integration, create a custom log processor:

Now all logs automatically include tracing context.


Testing

Run the test suite:

Run with coverage:


Credits


License

The MIT License (MIT). Please see License File for more information.


All versions of laravel-tracing with dependencies

PHP Build Version
Package Version
Requires php Version ^8.4
illuminate/support Version ^12
illuminate/contracts Version ^12
illuminate/queue Version ^12
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package jftecnologia/laravel-tracing contains the following files

Loading the files please wait ...