|
| 1 | +<!-- ## Usage |
| 2 | +
|
| 3 | +This package provides two middlewares for APM functionality: |
| 4 | +
|
| 5 | +1. `apm-metrics`: Collects metrics for each request |
| 6 | +2. `apm-tracing`: Creates a span for each request and adds basic HTTP information |
| 7 | +
|
| 8 | +You can add these middlewares to your routes or middleware groups in your Laravel application: |
| 9 | +
|
| 10 | +```php |
| 11 | +// In app/Http/Kernel.php |
| 12 | +
|
| 13 | +protected $middlewareGroups = [ |
| 14 | + 'web' => [ |
| 15 | + // ... other middlewares |
| 16 | + \Middleware\LaravelApm\Middleware\MetricsMiddleware::class, |
| 17 | + \Middleware\LaravelApm\Middleware\TracingMiddleware::class, |
| 18 | + ], |
| 19 | +]; |
| 20 | +
|
| 21 | +// Or for specific routes in your routes file: |
| 22 | +Route::middleware(['apm-metrics', 'apm-tracing'])->group(function () { |
| 23 | + // Your routes here |
| 24 | +}); --> |
| 25 | + |
| 26 | +# Installing and Setting Up Our OpenTelemetry Logging Package |
| 27 | + |
| 28 | +This guide will walk you through the process of installing and configuring our OpenTelemetry logging package in your Laravel project. |
| 29 | + |
| 30 | +## Prerequisites |
| 31 | + |
| 32 | +- Laravel project (version 8.x or higher recommended) |
| 33 | +- Composer |
| 34 | +- PHP 7.4 or higher |
| 35 | + |
| 36 | +## Installation |
| 37 | + |
| 38 | +1. Install the package using Composer: |
| 39 | + |
| 40 | + ```bash |
| 41 | + composer require Middleware/laravel-apm |
| 42 | + ``` |
| 43 | + |
| 44 | +2. Publish the package configuration: |
| 45 | + |
| 46 | + ```bash |
| 47 | + php artisan vendor:publish --provider="Middleware\LaravelAPM\LaravelAPMServiceProvider" |
| 48 | + ``` |
| 49 | + This will create a config/opentelemetry.php file in your project. |
| 50 | + |
| 51 | +## Configuration |
| 52 | + |
| 53 | +1. Open `config/laravel-apm.php` and adjust the settings as needed: |
| 54 | + |
| 55 | + ```bash |
| 56 | + return [ |
| 57 | + 'endpoint' => env('APM_EXPORTER_OTLP_ENDPOINT', 'http://localhost:9320'), |
| 58 | + 'service_name' => env('APM_SERVICE_NAME', 'laravel-app'), |
| 59 | + 'content_type' => 'application/x-protobuf', |
| 60 | + 'headers' => [ |
| 61 | + 'Content-Type' => 'application/x-protobuf' |
| 62 | + ], |
| 63 | + ]; |
| 64 | + ``` |
| 65 | + |
| 66 | +2. Update your `.env` file with the appropriate values: |
| 67 | + |
| 68 | + ```bash |
| 69 | + APM_SERVICE_NAME=your-app-name |
| 70 | + ``` |
| 71 | + |
| 72 | +## Usage |
| 73 | + |
| 74 | +To use the OpenTelemetry logger in your Laravel application: |
| 75 | + |
| 76 | +1. Update your `config/logging.php` to include our custom channel: |
0 commit comments