Download the PHP package mumzworld/laravel-opentelemetry without Composer
On this page you can find all versions of the php package mumzworld/laravel-opentelemetry. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download mumzworld/laravel-opentelemetry
More information about mumzworld/laravel-opentelemetry
Files in mumzworld/laravel-opentelemetry
Package laravel-opentelemetry
Short Description OpenTelemetry integration package for Laravel applications with complete observability stack
License MIT
Informations about the package laravel-opentelemetry
Laravel OpenTelemetry Package
A comprehensive OpenTelemetry integration package for Laravel applications that provides complete observability through distributed tracing, metrics collection, and visualization. This package enables you to monitor your application's performance, track requests across microservices, and identify bottlenecks in your Laravel application.
Learn more about OpenTelemetry:
๐ Features
- Easy Integration: Single composer require + artisan publish
- Environment-Driven: All settings configurable via .env variables
- Complete Observability Stack: Includes OpenTelemetry Collector, Tempo, and Grafana
- Custom Tracing: Simple TracerService for business logic tracing
- Docker Ready: Complete observability stack with Docker Compose
- Laravel Integration: Automatic service provider registration
- Production Ready: Configurable sampling, batching, and resource limits
- Automatic Instrumentation: PHP extension support for zero-code tracing
- Error Tracking: Automatic exception recording in traces
- Test Routes: Built-in test endpoints to verify integration
๐ Prerequisites
- PHP 8.4+ (Laravel 11 with latest Symfony dependencies requires PHP 8.4)
- Laravel 11.0+
- Docker & Docker Compose (for observability stack)
- OpenTelemetry PHP Extension (required for automatic instrumentation)
- Composer (for package installation)
๐ ๏ธ Installation
โ ๏ธ CRITICAL: The OpenTelemetry PHP extension must be installed BEFORE running
composer require. The package installation will fail without it.
Docker Environment (Recommended)
For Fresh Laravel Projects: If you don't have Docker setup yet, create these files first:
Create Dockerfile:
Create docker-compose.yml:
Step 1: Add Extension to Dockerfile (If Docker Already Exists)
Add the OpenTelemetry extension to your Dockerfile:
Step 2: Rebuild Docker Container
Step 3: Install the Package
Note: The service provider is automatically registered via Laravel's package auto-discovery.
Non-Docker Environment
Step 1: Install OpenTelemetry PHP Extension
Using PECL (Most Common):
Verify Installation:
Step 2: Install the Package
Note: The service provider is automatically registered via Laravel's package auto-discovery.
Step 4: Publish Configuration Files
Note: The publish command creates a
.env.opentelemetry.examplefile as a reference. You can safely delete this file after copying the variables to your.envfile.
For Docker Environment:
For Non-Docker Environment:
Step 5: Configure Environment Variables
Add these variables to your .env file:
Step 6: Setup Docker Observability Stack
Add the OpenTelemetry services to your docker-compose.yml:
Step 7: Start the Observability Stack
Step 8: Verify Installation
If test routes return 404:
- Ensure you've added the test route inclusion to
routes/api.php - Clear route cache:
docker-compose exec app php artisan route:clear - Restart the app container:
docker-compose restart app
๐ Troubleshooting
Common Issues
1. No traces appearing in Grafana
Check if services are running:
Check collector logs:
2. PHP Extension not loading
Verify OpenTelemetry extension is installed:
Check PHP configuration:
3. Traces not being exported
Check environment variables:
Test with debug mode:
4. High memory usage
Adjust sampling rate:
๐ฏ Usage Examples
Basic Custom Tracing
Controller Integration
Database Query Tracing
Job Tracing
๐งช Testing the Integration
The package includes test routes to verify your OpenTelemetry setup:
Test Routes
Enable Test Routes
Add to your routes/api.php (development only):
Note: After testing is complete, you can safely remove the
opentelemetry-test.phpfile and the test route inclusion fromroutes/api.php. These files are only for setup verification and are not needed in production.
Expected Test Responses
Basic Test (/api/opentelemetry/test):
Configuration Test (/api/opentelemetry/config):
๐ง Configuration Options
Environment Variables
| Variable | Default | Description |
|---|---|---|
OTEL_ENABLED |
true |
Enable/disable OpenTelemetry |
OTEL_SERVICE_NAME |
APP_NAME |
Service name for traces |
OTEL_SERVICE_VERSION |
1.0.0 |
Service version |
OTEL_ENVIRONMENT |
APP_ENV |
Deployment environment |
OTEL_TRACES_EXPORTER |
otlp |
Trace exporter type |
OTEL_EXPORTER_OTLP_ENDPOINT |
http://otel-collector:4318 |
OTLP endpoint |
OTEL_PROPAGATORS |
baggage,tracecontext |
Trace propagators |
OTEL_TRACES_SAMPLER |
parentbased_traceidratio |
Sampling strategy |
OTEL_TRACES_SAMPLER_ARG |
1.0 |
Sampling ratio (0.0-1.0) |
OTEL_PHP_AUTOLOAD_ENABLED |
true |
Enable PHP auto-instrumentation |
OTEL_INSTRUMENTATION_ENABLED |
true |
Enable instrumentation |
Configuration File
The package publishes a configuration file at config/opentelemetry.php:
๐ณ Docker Integration
Complete Stack
The package includes a complete observability stack:
Service URLs
- Grafana Dashboard: http://your-host:3000 (admin/admin)
- Tempo API: http://your-host:3200
- Collector Health: http://your-host:13133
- Test Routes: http://your-host/api/opentelemetry/test
๐ Viewing Traces
Grafana Dashboard
- Open Grafana at http://your-host:3000
- Login with admin/admin
- Go to "Explore" โ Select "Tempo" datasource
- Search for traces by:
- Service name:
{service.name="your-service-name"} - HTTP operations:
{service.name="your-service-name" && name=~".*GET.*"} - Slow traces:
{service.name="your-service-name" && duration>100ms}
- Service name:
Sample Trace Queries
Runtime Issues
No traces in Grafana:
Traces not exported:
High memory usage:
๐ Production Deployment
Environment Configuration
Performance Considerations
- Sampling: Use appropriate sampling rates for production (0.1 = 10%)
- Batching: Configure batch processors in collector
- Resource Limits: Set memory and CPU limits
- Network: Use gRPC for better performance
- Storage: Configure appropriate retention policies
๐ค Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests
- Submit a pull request
๐ License
This package is licensed under the MIT License.
๐ Support
For support and questions:
- Create an issue in the repository
- Check the troubleshooting section
- Review the Laravel OpenTelemetry documentation
Built with โค๏ธ by Mumzworld Development Team
All versions of laravel-opentelemetry with dependencies
laravel/framework Version ^11.0|^12.0|^13.0
open-telemetry/api Version ^1.0
open-telemetry/sdk Version ^1.0
open-telemetry/exporter-otlp Version ^1.0
open-telemetry/opentelemetry-auto-laravel Version ^1.1