|
1 | | -# OpenTelemetry Laravel auto-instrumentation |
| 1 | +[](https://github.com/opentelemetry-php/contrib-auto-laravel/releases) |
| 2 | +[](https://github.com/open-telemetry/opentelemetry-php/issues) |
| 3 | +[](https://github.com/open-telemetry/opentelemetry-php-contrib/tree/main/src/Instrumentation/Laravel) |
| 4 | +[](https://github.com/opentelemetry-php/contrib-auto-laravel) |
| 5 | +[](https://packagist.org/packages/open-telemetry/opentelemetry-auto-laravel/) |
| 6 | +[](https://packagist.org/packages/open-telemetry/opentelemetry-auto-laravel/) |
2 | 7 |
|
3 | | -**Preferred and simplest way to install auto-instrumentation (c extension plus instrumentation libraries) is to use [opentelemetry-instrumentation-installer](https://github.com/open-telemetry/opentelemetry-php-contrib/tree/main/src/AutoInstrumentationInstaller).** |
4 | | -**The same process can be done manually by installing [c extension](https://github.com/open-telemetry/opentelemetry-php-instrumentation#installation) plus all needed instrumentation libraries like [Laravel](#Installation-via-composer)** |
| 8 | +This is a read-only subtree split of https://github.com/open-telemetry/opentelemetry-php-contrib. |
5 | 9 |
|
6 | | -## Requirements |
| 10 | +# OpenTelemetry Laravel auto-instrumentation |
7 | 11 |
|
8 | | -* OpenTelemetry extension |
9 | | -* OpenTelemetry SDK and exporters (required to actually export traces) |
| 12 | +Please read https://opentelemetry.io/docs/instrumentation/php/automatic/ for instructions on how to |
| 13 | +install and configure the extension and SDK. |
10 | 14 |
|
11 | 15 | ## Overview |
12 | | -Currently only root span creation is supported (Illuminate\Foundation\Http\Kernel::handle hook). |
13 | | - |
14 | | -To export spans, you will need to create and register a `TracerProvider` early in your application's |
15 | | -lifecycle. This can be done either manually or using SDK autoloading. |
16 | | - |
17 | | -### Using SDK autoloading |
18 | | - |
19 | | -See https://github.com/open-telemetry/opentelemetry-php#sdk-autoloading |
20 | | - |
21 | | -### Manual setup |
22 | | - |
23 | | -```php |
24 | | -<?php |
25 | | -require_once 'vendor/autoload.php'; |
26 | | - |
27 | | -$tracerProvider = /*create tracer provider*/; |
28 | | -$scope = \OpenTelemetry\API\Instrumentation\Configurator::create() |
29 | | - ->withTracerProvider($tracerProvider) |
30 | | - ->activate(); |
31 | | - |
32 | | -//your application runs here |
33 | | - |
34 | | -$scope->detach(); |
35 | | -$tracerProvider->shutdown(); |
36 | | -``` |
37 | | - |
38 | | -## Installation via composer |
39 | | - |
40 | | -```bash |
41 | | -$ composer require open-telemetry/opentelemetry-auto-laravel |
42 | | -``` |
43 | | - |
44 | | -## Installing dependencies and executing tests |
45 | | - |
46 | | -From Laravel subdirectory: |
47 | | - |
48 | | -```bash |
49 | | -$ composer install |
50 | | -$ ./vendor/bin/phpunit tests |
51 | | -``` |
| 16 | +Auto-instrumentation hooks are registered via composer, and spans will automatically be created. |
52 | 17 |
|
53 | 18 | ## Configuration |
54 | 19 |
|
55 | | -Parts of this auto-instrumentation library can be configured, more options are available throught the |
56 | | -[General SDK Configuration](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/sdk-environment-variables.md#general-sdk-configuration): |
| 20 | +The extension can be disabled via [runtime configuration](https://opentelemetry.io/docs/instrumentation/php/sdk/#configuration): |
57 | 21 |
|
58 | | -| Name | Default value | Values | Example | Description | |
59 | | -|-------------------------------------|---------------|-------------------------|---------|---------------------------------------------------------------------------------| |
60 | | -| OTEL_PHP_DISABLED_INSTRUMENTATIONS | [] | Instrumentation name(s) | laravel | Disable one or more installed auto-instrumentations, names are comma seperated. | |
61 | | - |
62 | | -Configurations can be provided as environment variables, or via `php.ini` (or a file included by `php.ini`) |
| 22 | +```shell |
| 23 | +OTEL_PHP_DISABLED_INSTRUMENTATIONS=laravel |
| 24 | +``` |
0 commit comments