|
| 1 | +# Configuration |
| 2 | + |
| 3 | +OpenTelemetry PHP Distro supports standard OpenTelemetry SDK configuration and distro-specific options. |
| 4 | + |
| 5 | +## Configuration method |
| 6 | + |
| 7 | +Configure via environment variables available to PHP processes: |
| 8 | + |
| 9 | +- `OTEL_*` for OpenTelemetry standard options |
| 10 | +- `OTEL_PHP_*` for distro-specific options |
| 11 | + |
| 12 | +Example: |
| 13 | + |
| 14 | +```bash |
| 15 | +export OTEL_EXPORTER_OTLP_ENDPOINT="https://your-endpoint:443/" |
| 16 | +export OTEL_EXPORTER_OTLP_HEADERS="Authorization=Bearer <token>" |
| 17 | +export OTEL_PHP_LOG_LEVEL_STDERR="INFO" |
| 18 | +``` |
| 19 | + |
| 20 | +## OpenTelemetry options |
| 21 | + |
| 22 | +The distro supports standard OpenTelemetry PHP SDK options. |
| 23 | + |
| 24 | +| Option | Default | Accepted values | Description | |
| 25 | +| --- | --- | --- | --- | |
| 26 | +| `OTEL_EXPORTER_OTLP_ENDPOINT` | `http://localhost:4318` | URL | OTLP endpoint URL | |
| 27 | +| `OTEL_EXPORTER_OTLP_HEADERS` | (empty) | `key=value,key2=value2` | OTLP request headers | |
| 28 | +| `OTEL_EXPORTER_OTLP_INSECURE` | `false` | `true` or `false` | Disable TLS verification (testing only) | |
| 29 | +| `OTEL_EXPORTER_OTLP_CERTIFICATE` | (empty) | Filesystem path (PEM) | CA certificate path for OTLP TLS | |
| 30 | +| `OTEL_EXPORTER_OTLP_CLIENT_CERTIFICATE` | (empty) | Filesystem path (PEM) | Client certificate for OTLP mTLS | |
| 31 | +| `OTEL_EXPORTER_OTLP_CLIENT_KEY` | (empty) | Filesystem path (PEM) | Client key for OTLP mTLS | |
| 32 | +| `OTEL_EXPORTER_OTLP_CLIENT_KEYPASS` | (empty) | String | Passphrase for encrypted OTLP client key | |
| 33 | +| `OTEL_SERVICE_NAME` | `unknown_service` | String | Value of `service.name` resource attribute | |
| 34 | +| `OTEL_RESOURCE_ATTRIBUTES` | (empty) | `key=value,key2=value2` | Resource attributes | |
| 35 | +| `OTEL_TRACES_SAMPLER` | `parentbased_always_on` | Sampler name | Trace sampler | |
| 36 | +| `OTEL_TRACES_SAMPLER_ARG` | (empty) | String/number | Sampler argument | |
| 37 | +| `OTEL_LOG_LEVEL` | `info` | `error`, `warn`, `info`, `debug` | SDK internal log level | |
| 38 | + |
| 39 | +## Distro-specific options (`OTEL_PHP_*`) |
| 40 | + |
| 41 | +All `OTEL_PHP_*` options can be set as environment variables or in `php.ini`. |
| 42 | + |
| 43 | +For `php.ini`, use the `opentelemetry_distro.` prefix and lowercase option names. |
| 44 | + |
| 45 | +Example: |
| 46 | + |
| 47 | +```bash |
| 48 | +export OTEL_PHP_ENABLED=true |
| 49 | +``` |
| 50 | + |
| 51 | +```ini |
| 52 | +opentelemetry_distro.enabled=true |
| 53 | +``` |
| 54 | + |
| 55 | +### General configuration |
| 56 | + |
| 57 | +| Option | Default | Accepted values | Description | |
| 58 | +| --- | --- | --- | --- | |
| 59 | +| `OTEL_PHP_ENABLED` | `true` | `true` or `false` | Enables automatic bootstrap | |
| 60 | +| `OTEL_PHP_NATIVE_OTLP_SERIALIZER_ENABLED` | `true` | `true` or `false` | Enables native OTLP protobuf serializer | |
| 61 | + |
| 62 | +### Asynchronous data sending |
| 63 | + |
| 64 | +| Option | Default | Accepted values | Description | |
| 65 | +| --- | --- | --- | --- | |
| 66 | +| `OTEL_PHP_ASYNC_TRANSPORT` | `true` | `true` or `false` | Enables background transfer of telemetry | |
| 67 | +| `OTEL_PHP_ASYNC_TRANSPORT_SHUTDOWN_TIMEOUT` | `30s` | Duration (`ms`, `s`, `m`) | Flush timeout at shutdown | |
| 68 | +| `OTEL_PHP_MAX_SEND_QUEUE_SIZE` | `2MB` | Integer with optional `B`, `MB`, `GB` | Max async buffer size per worker | |
| 69 | + |
| 70 | +### Logging |
| 71 | + |
| 72 | +| Option | Default | Accepted values | Description | |
| 73 | +| --- | --- | --- | --- | |
| 74 | +| `OTEL_PHP_LOG_FILE` | (empty) | Filesystem path | Log output file path | |
| 75 | +| `OTEL_PHP_LOG_LEVEL_FILE` | `OFF` | `OFF`, `CRITICAL`, `ERROR`, `WARNING`, `INFO`, `DEBUG`, `TRACE` | File sink log level | |
| 76 | +| `OTEL_PHP_LOG_LEVEL_STDERR` | `OFF` | `OFF`, `CRITICAL`, `ERROR`, `WARNING`, `INFO`, `DEBUG`, `TRACE` | Stderr sink log level | |
| 77 | +| `OTEL_PHP_LOG_LEVEL_SYSLOG` | `OFF` | `OFF`, `CRITICAL`, `ERROR`, `WARNING`, `INFO`, `DEBUG`, `TRACE` | Syslog sink log level | |
| 78 | +| `OTEL_PHP_LOG_FEATURES` | (empty) | `FEATURE=LEVEL,...` | Per-feature log levels | |
| 79 | + |
| 80 | +### Transaction span |
| 81 | + |
| 82 | +| Option | Default | Accepted values | Description | |
| 83 | +| --- | --- | --- | --- | |
| 84 | +| `OTEL_PHP_TRANSACTION_SPAN_ENABLED` | `true` | `true` or `false` | Auto root span for web SAPI | |
| 85 | +| `OTEL_PHP_TRANSACTION_SPAN_ENABLED_CLI` | `true` | `true` or `false` | Auto root span for CLI | |
| 86 | +| `OTEL_PHP_TRANSACTION_URL_GROUPS` | (empty) | Comma-separated wildcards | URL grouping patterns | |
| 87 | + |
| 88 | +### Inferred spans |
| 89 | + |
| 90 | +| Option | Default | Accepted values | Description | |
| 91 | +| --- | --- | --- | --- | |
| 92 | +| `OTEL_PHP_INFERRED_SPANS_ENABLED` | `false` | `true` or `false` | Enables inferred spans | |
| 93 | +| `OTEL_PHP_INFERRED_SPANS_REDUCTION_ENABLED` | `true` | `true` or `false` | Reduces consecutive duplicate frames | |
| 94 | +| `OTEL_PHP_INFERRED_SPANS_STACKTRACE_ENABLED` | `true` | `true` or `false` | Attaches stacktrace to inferred spans | |
| 95 | +| `OTEL_PHP_INFERRED_SPANS_SAMPLING_INTERVAL` | `50ms` | Duration (`ms`, `s`, `m`) | Stacktrace sampling interval | |
| 96 | +| `OTEL_PHP_INFERRED_SPANS_MIN_DURATION` | `0` | Duration (`ms`, `s`, `m`) | Minimum inferred span duration | |
| 97 | + |
| 98 | +### Central configuration (OpAMP) |
| 99 | + |
| 100 | +| Option | Default | Accepted values | Description | |
| 101 | +| --- | --- | --- | --- | |
| 102 | +| `OTEL_PHP_OPAMP_ENDPOINT` | (empty) | HTTP/HTTPS URL ending with `/v1/opamp` | OpAMP endpoint | |
| 103 | +| `OTEL_PHP_OPAMP_HEADERS` | (empty) | `key=value,key2=value2` | OpAMP request headers | |
| 104 | +| `OTEL_PHP_OPAMP_HEARTBEAT_INTERVAL` | `30s` | Duration (`ms`, `s`, `m`) | OpAMP heartbeat interval | |
| 105 | +| `OTEL_PHP_OPAMP_SEND_TIMEOUT` | `10s` | Duration (`ms`, `s`, `m`) | OpAMP send timeout | |
| 106 | +| `OTEL_PHP_OPAMP_SEND_MAX_RETRIES` | `3` | Integer >= 0 | Retry count | |
| 107 | +| `OTEL_PHP_OPAMP_SEND_RETRY_DELAY` | `10s` | Duration (`ms`, `s`, `m`) | Retry delay | |
| 108 | +| `OTEL_PHP_OPAMP_INSECURE` | `false` | `true` or `false` | Disable TLS verification (testing only) | |
| 109 | +| `OTEL_PHP_OPAMP_CERTIFICATE` | (empty) | Filesystem path (PEM) | CA certificate path for OpAMP TLS | |
| 110 | +| `OTEL_PHP_OPAMP_CLIENT_CERTIFICATE` | (empty) | Filesystem path (PEM) | Client certificate path for OpAMP mTLS | |
| 111 | +| `OTEL_PHP_OPAMP_CLIENT_KEY` | (empty) | Filesystem path (PEM) | Client key path for OpAMP mTLS | |
| 112 | +| `OTEL_PHP_OPAMP_CLIENT_KEYPASS` | (empty) | String | Passphrase for encrypted client key | |
| 113 | + |
| 114 | +## Notes |
| 115 | + |
| 116 | +- Background transfer works with OTLP HTTP/protobuf mode. |
| 117 | +- `OTEL_PHP_AUTOLOAD_ENABLED` is enforced as enabled by the distro runtime. |
0 commit comments