SDK
The OpenTelemetry SDK provides a working implementation of the API, and can be set up and configured in a number of ways.
Manual setup¶
Setting up an SDK manually gives you the most control over the SDK's configuration:
SDK Builder¶
The SDK builder provides a convenient interface to configure parts of the SDK. However, it doesn't support all of the features that manual setup does.
Autoloading¶
If all configuration comes from environment variables (or php.ini
), you can
use SDK autoloading to automatically configure and globally register an SDK. The
only requirement for this is that you set OTEL_PHP_AUTOLOAD_ENABLED=true
, and
provide any required/non-standard configuration as set out in
sdk-configuration.
For example:
SDK autoloading happens as part of the composer autoloader.
{{% alert title="Important" color="warning" %}}The batch span and log processors
emit metrics about their internal state, so ensure that you have a correctly
configured metrics exporter. Alternatively, you can disable metrics by setting
OTEL_METRICS_EXPORTER=none
}
Configuration¶
The PHP SDK supports most of the available configurations. Our conformance to the specification is listed in the spec compliance matrix.
There are also a number of PHP-specific configurations:
Name | Default value | Values | Example | Description |
---|---|---|---|---|
OTEL_PHP_TRACES_PROCESSOR | batch | batch, simple | simple | Span processor selection |
OTEL_PHP_DETECTORS | all | env, host, os, process, process_runtime, sdk, sdk_provided, container | env,os,process | Resource detector selection |
OTEL_PHP_AUTOLOAD_ENABLED | false | true, false | true | Enable/disable SDK autoloading |
OTEL_PHP_DISABLED_INSTRUMENTATIONS | [] | Instrumentation name(s) | psr15,psr18 | Disable one or more installed auto-instrumentations |
Configurations can be provided as environment variables, or via php.ini
(or a
file included by php.ini
)