TheDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/tracewayapp/opentelemetry-symfony-bundle/llms.txt
Use this file to discover all available pages before exploring further.
sdk: configuration section lets you control OpenTelemetry SDK environment variables through Symfony’s own configuration system — DotEnv, container parameters, and Symfony Secrets — rather than relying on shell environment variables set outside the application. Values written by this section are applied at bundle boot time, before the Symfony container is fully used, giving you fine-grained control that raw shell env cannot provide.
Why this matters: the OTEL_PHP_AUTOLOAD_ENABLED timing problem
The OpenTelemetry PHP SDK initialises itself through a Composer autoload hook in vendor/open-telemetry/sdk/_autoload.php. That hook only fires when OTEL_PHP_AUTOLOAD_ENABLED=true is already present in the environment at the time Composer’s autoloader runs — which happens before Symfony’s kernel boots.
Symfony’s DotEnv component parses .env files and populates $_SERVER / $_ENV during the kernel boot sequence — too late for the SDK autoloader to see the variable. Setting OTEL_PHP_AUTOLOAD_ENABLED in .env therefore has no effect on the autoloader.
sdk.autoload_enabled: true solves this by re-running the SDK autoload file from inside the bundle’s boot() method, after the container is compiled and container parameters (including Secrets) are resolved, but still early enough in the request lifecycle for all instrumentation to work correctly.
Full sdk: YAML example
Setting any
sdk.* sub-key implicitly enables the section (sdk.enabled is treated as true). Use sdk.enabled: false to explicitly disable the section even when other keys are present in the file — for example to temporarily disable SDK config without removing your values.sdk.autoload_enabled
true, the bundle:
- Checks whether
OTEL_PHP_AUTOLOAD_ENABLEDis alreadytruein the current process (via the OTel SDK’s ownConfiguration::getBoolean()helper). - If it is not already set, writes
OTEL_PHP_AUTOLOAD_ENABLED=trueinto$_SERVERand$_ENV. - Re-requires the SDK’s
_autoload.phpfile. Because the autoloader was previously a no-op (the env var was absent), this correctly initialises the SDK for the first time.
OTEL_PHP_AUTOLOAD_ENABLED in your system environment or Docker entrypoint at all — the bundle handles it at the right moment.
sdk.resource_attributes
OTEL_RESOURCE_ATTRIBUTES at boot time. Bundle-provided values win over any values already present in the environment variable, so this config always takes precedence over shell env.
The values support Symfony’s full parameter syntax, including:
- Container parameters:
%kernel.environment% - Environment variables:
%env(APP_VERSION)% - Symfony Secrets:
%env(resolve:MY_SECRET)%(resolved at container compile time)
OTEL_RESOURCE_ATTRIBUTES is a comma-separated key=value string, built by array_replace-ing existing entries with your provided map so no existing attributes are lost.
This is semantically different from setting
OTEL_RESOURCE_ATTRIBUTES in your .env file. The bundle merges rather than replaces, and your config file values always win the merge. DotEnv values set before boot are treated as the existing baseline.sdk.exporter_otlp_headers
sdk.exporter_otlp_headers merges the map you provide into OTEL_EXPORTER_OTLP_HEADERS using the same win-over-existing logic as resource_attributes.
This is the correct place to configure Bearer tokens or API keys because:
- The value can reference a Symfony Secret (
%env(resolve:OTEL_API_BEARER_TOKEN)%), keeping the secret out of your codebase and shell history. - The merge happens at bundle boot, after the Symfony container (including Secrets) is resolved.
- The token is never written to the filesystem or logged by the container compiler.
sdk.use_putenv
$_SERVER and $_ENV. When use_putenv: true is set, it also calls putenv() so the values are visible to C extensions and other code that reads the process environment directly.
How this differs from .env variables
.env / shell environment | sdk: bundle config | |
|---|---|---|
| Resolved by | Symfony DotEnv / OS | Symfony container (parameters + Secrets) |
| Timing | Before autoloader (shell) or after kernel boot (DotEnv) | At bundle boot() — after container is compiled |
| Symfony Secrets support | No (DotEnv only) | Yes |
| Per-environment override | Via .env.prod, .env.dev, etc. | Via config/packages/{env}/open_telemetry.yaml |
| Merge behaviour | Replaces entire variable | Merges; bundle values win |
| Fixes autoload timing | Only if set in shell before PHP starts | Yes — sdk.autoload_enabled: true |
- Use shell environment variables (or Docker/Kubernetes secrets) for
OTEL_EXPORTER_OTLP_ENDPOINTandOTEL_SERVICE_NAME— values that are infrastructure-level concerns. - Use
sdk:bundle config forautoload_enabled,resource_attributes, andexporter_otlp_headers— values that belong to application config and may reference Symfony Secrets or container parameters.
