Download the PHP package overtrue/laravel-open-telemetry without Composer

On this page you can find all versions of the php package overtrue/laravel-open-telemetry. 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-open-telemetry

Laravel OpenTelemetry

Latest Version on Packagist Total Downloads

This package provides a simple way to add OpenTelemetry to your Laravel application.

⚠️ Breaking Changes in Recent Versions

SpanBuilder API Changes: The SpanBuilder::start() method behavior has been updated for better safety and predictability:

For most use cases, the new start() behavior is safer and recommended. See the Advanced Span Creation section for detailed usage patterns.

Features

Installation

You can install the package via composer:

Configuration

Important Note for Octane Users

When using Laravel Octane, it is highly recommended to set OTEL_* environment variables at the machine or process level (e.g., in your Dockerfile, docker-compose.yml, or Supervisor configuration) rather than relying solely on the .env file.

This is because some OpenTelemetry components, especially those enabled by OTEL_PHP_AUTOLOAD_ENABLED, are initialized before the Laravel application fully boots and reads the .env file. Setting them as system-level environment variables ensures they are available to the PHP process from the very beginning.

This package uses the standard OpenTelemetry environment variables for configuration. Add these to your .env file for basic setup:

Basic Configuration

Package Configuration

For package-specific settings, publish the configuration file:

This will create a config/otel.php file. Here are the key options:

Enabling/Disabling Tracing

You can completely enable or disable tracing for the entire application. This is useful for performance tuning or disabling tracing in certain environments.

Set OTEL_ENABLED=false in your .env file to disable all tracing.

Filtering Requests and Headers

You can control which requests are traced and which headers are recorded to enhance performance and protect sensitive data. All patterns support wildcards (*) and are case-insensitive.

Watchers

You can enable or disable specific watchers to trace different parts of your application.

Usage

The package is designed to work with minimal manual intervention, but it also provides a powerful Measure facade for creating custom spans.

Automatic Tracing

With the default configuration, the package automatically traces:

Creating Custom Spans with Measure::trace()

For tracing specific blocks of code, the Measure::trace() method is the recommended approach. It automatically handles span creation, activation, exception recording, and completion.

The trace method will:

Advanced Span Creation with SpanBuilder

For more control over span lifecycle, you can use the SpanBuilder directly through Measure::span(). The SpanBuilder provides several methods for different use cases:

Basic Span Creation (Recommended for most cases)

Span with Activated Scope

Span with Context (For Manual Propagation)

Using Semantic Spans

To promote standardization, the package provides semantic helper methods that create spans with attributes conforming to OpenTelemetry's Semantic Conventions.

Database Spans

Note: If QueryWatcher is enabled, individual queries are already traced. This is useful for tracing a larger transaction or a specific business operation involving multiple queries.

HTTP Client Spans

Custom Spans

Retrieving the Current Span

You can access the currently active span anywhere in your code.

Watchers

The package includes several watchers that automatically create spans for common Laravel operations. You can enable or disable them in config/otel.php.

Trace ID Injection Middleware

The package includes middleware to add a X-Trace-Id header to your HTTP responses, which is useful for debugging.

You can apply it to specific routes:

Or apply it globally in app/Http/Kernel.php:

Environment Variables Reference

Core OpenTelemetry Variables

Variable Description Default Example
OTEL_PHP_AUTOLOAD_ENABLED Enable PHP SDK auto-loading false true
OTEL_SERVICE_NAME Service name unknown_service my-laravel-app
OTEL_SERVICE_VERSION Service version null 1.0.0
OTEL_TRACES_EXPORTER Trace exporter type otlp console, otlp
OTEL_EXPORTER_OTLP_ENDPOINT OTLP endpoint URL http://localhost:4318 https://api.honeycomb.io
OTEL_EXPORTER_OTLP_PROTOCOL OTLP protocol http/protobuf http/protobuf, grpc
OTEL_PROPAGATORS Context propagators tracecontext,baggage tracecontext,baggage,b3
OTEL_TRACES_SAMPLER Sampling strategy parentbased_always_on always_on, traceidratio
OTEL_TRACES_SAMPLER_ARG Sampler argument null 0.1
OTEL_RESOURCE_ATTRIBUTES Resource attributes null key1=value1,key2=value2

Testing

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

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


All versions of laravel-open-telemetry with dependencies

PHP Build Version
Package Version
Requires php Version >=8.4
laravel/framework Version ^10.0|^11.0|^12.0
open-telemetry/api Version ^1.0
open-telemetry/sdk Version ^1.0
open-telemetry/exporter-otlp Version ^1.3
open-telemetry/sem-conv Version ^1.32
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 overtrue/laravel-open-telemetry contains the following files

Loading the files please wait ....