You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A missing or unparseable OTEL_CONFIG_FILE no longer blows up.
Single parse, two roots
Configuration::parseFile() now loads the document once and processes the resulting arrays
against both configuration roots. The SDK root stays lazy behind create(); a new getInstrumentationConfig() accessor serves the instrumentation root.
SdkAutoloader::autoload() was the other half of the problem: it built one Configuration
eagerly for instrumentation config and a second inside the deferred Globals initializer. It
now parses once and threads the instance into both consumers.
The two roots stay separate on purpose, and the reasoning is now recorded on InstrumentationConfigurationRegistry rather than carried as a @todo to remove them. /development is exempt from the file format's versioning guarantees, so it is the part of the
document most likely to disagree with what we can parse. Keeping it a separate root gives it
independent failure: a node that does not validate costs the caller its instrumentation config
and leaves the SDK configured. ignoreExtraKeys() and IgnoresUnknownProviders only tolerate
unknown keys and unregistered providers — not a known node that fails type validation.
Instrumentation config is resolved during autoload, under its own try/catch, because hooks must
be installed before the first instrumented call. An exception during processing is reported
verbatim, which provides more useful detail.
Deep copy between roots
Processing one document against two roots exposed a latent aliasing bug. Under ext-yaml,
YAML aliases materialise as genuine PHP references (symfony/yaml deep-copies instead), and
references survive the by-value copy Processor::process() makes. Environment substitution
writes back into the array it is given, so the first root processed would mutate what the second
sees:
without the copy: shared.ca_file "${MY_CA}" -> "/env/ca.pem" (leaked)
with the copy: shared.ca_file "${MY_CA}" (intact)
Related fixes
ConfigProviderInterface::getInstrumentationConfig() takes a Context. Both
implementations are updated. Config\SDK\ConfigProvider now logs through $context->logger instead of LogsMessagesTrait, so a caller-supplied logger is actually
honoured — previously a warning was filtered by the global log level and could be discarded
despite the caller asking for it.
Configuration::getList() narrowed to list<string>. It was declared : array, wider
than the string|list<string> that parseFile() accepts, so both callers carried a @psalm-suppress ArgumentTypeCoercion. ListParser::parse() now satisfies list<string> on
every branch; its is_array() branch previously passed maps and non-strings through
untouched. All twelve getList() callers already assumed a list of names.
instrumentation/development schema is statically declared, adding general.http and semconv support (file format 1.0) and tolerating unknown php entries with a warning rather
than a hard failure.
Config\SDK\ConfigProvider registered under SPI as the spec's entry point for
instrumentations that read config without the SDK. It is deliberately not on the
autoloader's path, where resolving it would cost a second parse.
String lists actually enforce strings: sensitive_query_parameters, request_captured_headers, response_captured_headers, known_methods — Symfony's scalarPrototype() let ints/floats/bools through to HttpConfig; now Validation::ensureString() on each
YAML alias security/robustness (ext-yaml only)
Pre-existing bugs that copilot identified during review, fixed here for convenience.
Env-var leak via direct aliases fixed. ext-yaml turns b: *a into a PHP reference; substitution wrote back through it, so $${FOO} escaped-literal resolved to FOO's value and placeholder-looking values got re-expanded — violating the spec's "env vars MUST NOT be injectable via env vars". Loader now copies by value; Configuration::copy() removed as redundant. New alias-escaped-substitution.yaml fixture. (35cbc59)
Recursive aliases (a: &x [*x]) no longer exhaust memory. Was an uncatchable fatal during synchronous autoload; now depth-bounded and reported as an invalid file. (Copilot review on sdk-config: refactor .instrumentation processing #2076) (8765e72)
YamlBackendParityTest: both backends must parse all 54 fixtures identically.
ext-yaml installed in CI (php.yml) The yaml-gated guards silently skipped. Improve test coverage of both ext-yaml and symfony/yaml
ext-yaml added to base developer image: local testing (make test etc) now exercises ext-yaml
sdk-configuration constraints bumped to what should be the next versions released: open-telemetry/api^1.11, open-telemetry/sdk^1.16.
Breaking changes
ConfigProviderInterface::getInstrumentationConfig() gains an optional Context parameter.
Source-compatible for callers; implementors outside this repo must update their signature. The
interface is marked @experimental.
`instrumentation/development` is a sibling of `tracer_provider` etc in the same
document, so parsing it through a separate entry point read and
env-substituted the file twice.
Configuration::parseFile() now loads the file once and processes the
arrays against both roots. The SDK root stays lazy behind create(); the
new getInstrumentationConfig() accessor processes the instrumentation
root on demand, so a file whose instrumentation block we cannot parse
does not stop the SDK from being configured. Each processor gets a deep
copy, since YAML aliases can materialise as PHP references that survive
the by-value copy Processor::process() makes.
Config\SDK\Instrumentation becomes a deprecated thin delegate, and
SdkAutoloader resolves instrumentation config through an SPI
ConfigProviderInterface rather than calling it directly — `sdk` only
suggests `sdk-configuration`, so the indirection degrades to the API's
noop provider when the package is absent.
Folds in the `semconv` and `general` schema nodes, which empties
knownInstrumentationParseFailures(). `general` becomes a fixed node
rather than a component map, since a scalar sibling such as
`stability_opt_in_list` cannot resolve to a provider; its values are
validated but not yet exposed, as nothing in-tree reads them. Unknown
keys under `instrumentation/development` are dropped rather than
rejected, matching Java.
Removing the second parse is what makes the eager path guardable, so a
missing or unparseable OTEL_CONFIG_FILE now logs an initialization error
and degrades to a noop SDK instead of killing the process with exit 255.
ConfigProviderInterface gains an optional Context parameter, which is
technically breaking for external implementors — see the PR for why that
is acceptable now rather than later.
Fixesopen-telemetry#2075
Co-Authored-By: Claude Code
300724d made Configuration::parseFile() serve both configuration roots from
one document, but SdkAutoloader built one Configuration eagerly for
instrumentation config and a second inside the deferred Globals initializer,
reading and env-substituting the file twice.
autoload() now parses once and threads the instance into both consumers.
Instrumentation config is resolved under its own try/catch, so a document
whose instrumentation/development node does not validate still leaves the SDK
configured; an Error there is reported as a version mismatch instead, since
`sdk` can only suggest sdk-configuration and the two release separately.
Covered by a new fixture and test.
SdkAutoloader no longer resolves ConfigProviderInterface over SPI, which
would cost the second parse; Config\SDK\ConfigProvider stays as the spec's
entry point for instrumentations that read configuration without the SDK.
Bumps sdk-configuration's constraints to the releases carrying the API it now
uses: sdk ^1.16 and api ^1.11.
Also rewrites the comments that treated the eager/deferred split and the
separate instrumentation root as costs to be removed. Both are deliberate:
hooks must be installed before the first instrumented call, and the separate
root is what gives that node independent failure while /development remains
exempt from the file format's versioning guarantees.
getList() was declared `: array`, which is wider than the `string|list<string>`
that Config\SDK\Configuration::parseFile() accepts, so both of its callers
carried a @psalm-suppress ArgumentTypeCoercion rather than the type being
provable.
ListParser::parse() now satisfies list<string> on every branch. The empty and
comma-separated branches already did; the is_array() branch returned its input
unchanged, so a map or a list of non-strings passed straight through. It now
discards keys and stringifies values, which is what all twelve getList()
callers already assumed — they feed the result to things expecting a list of
names (exporters, propagators, detectors, config file paths).
❌ Patch coverage is 14.93506% with 131 lines in your changes missing coverage. Please review.
✅ Project coverage is 66.29%. Comparing base (fa9ce32) to head (7010090). ⚠️ Report is 2 commits behind head on main.
Catching Error around getInstrumentationConfig() to blame an outdated
sdk-configuration also caught faults raised by the configuration itself, so
a TypeError from a plugin's createPlugin() was logged as "requires a newer
open-telemetry/sdk-configuration". Let the generic Throwable path report it;
PHP's own message already names the missing method in the skew case.
ext-yaml turns a direct alias (`b: *a`) into a PHP reference, where
symfony/yaml yields independent copies. Environment substitution writes its
result back into the array it normalises, so through a reference the alias
partner received already-substituted text and was substituted a second time.
That is not a no-op: an escaped `$${FOO}` resolved to the value of FOO
instead of staying the literal `${FOO}`, and a value that itself looked like
a placeholder was expanded again — defeating the spec requirement that
environment variables MUST NOT be injectable via environment variables.
Copy by value in the loader so references never enter the pipeline. This
also covers the cacheFile and direct process() paths, which
Configuration::copy() did not, so that method is now redundant and removed.
Predates this PR; affects ext-yaml installs without symfony/yaml.
Install ext-yaml in CI, which never had it: the regression guard above is
gated on the extension, so without this it would silently skip — as would
the two existing yaml-gated tests. Coverage in the config unit tests goes
from 45 tests (4 skipped) to 99.
Add YamlBackendParityTest, asserting both backends parse all 54 fixtures
identically, so a future divergence fails a test rather than reaching users
as a parsing bug.
The new array normalization is not exercised by ListParserTest: its data provider only passes strings, and the arrays there are expected outputs. Add array-input cases covering associative keys and non-string scalar values so the promised reindexing and string coercion cannot regress.
…memory
ext-yaml resolves a recursive alias (`a: &x [*x]`) into a genuinely
self-referential array, which has no finite by-value copy, so the alias
copying added in 35cbc59 recursed until the memory limit — an uncatchable
fatal, during synchronous autoload, where callers otherwise degrade to a
noop configuration.
Bound the traversal depth and report anything past it as an invalid file.
Identity comparison cannot be used to spot the cycle instead: comparing a
self-referential array raises its own fatal. The deepest configuration this
repository parses, upstream fixtures included, is 9 levels.
Reported by Copilot review on open-telemetry#2076
The file-format schema requires every sensitive_query_parameters item to be a string, but Symfony's scalarPrototype() also accepts integers, floats, and booleans. As written, schema-invalid input such as [123] is accepted even though this new tree is intended to validate known nodes. Apply the repository's Validation::ensureString() validator to the prototype.
The changed array branch has no unit coverage: ListParserTest only supplies string inputs, so neither associative-key removal nor conversion of non-string values is verified. Add array cases for both behaviors, since they are the reason this branch now guarantees list<string>.
The file format declares sensitive_query_parameters, request_captured_headers,
response_captured_headers and known_methods as `items: type: string`, but
Symfony's scalarPrototype() accepts any scalar, so ints, floats and booleans
reached HttpConfig unconverted.
Attach Validation::ensureString() to each prototype, as the SDK schema already
does elsewhere. Covered in both directions: non-string items are rejected, and
environment placeholders still resolve, including values that look numeric.
Also cover ListParser's array branch, which no test reached — the provider
supplied only strings, so neither the key reindexing nor the string coercion
behind its `list<string>` guarantee was exercised.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes: #2075
Parse the declarative config document once
A missing or unparseable
OTEL_CONFIG_FILEno longer blows up.Single parse, two roots
Configuration::parseFile()now loads the document once and processes the resulting arraysagainst both configuration roots. The SDK root stays lazy behind
create(); a newgetInstrumentationConfig()accessor serves the instrumentation root.SdkAutoloader::autoload()was the other half of the problem: it built oneConfigurationeagerly for instrumentation config and a second inside the deferred
Globalsinitializer. Itnow parses once and threads the instance into both consumers.
The two roots stay separate on purpose, and the reasoning is now recorded on
InstrumentationConfigurationRegistryrather than carried as a@todoto remove them./developmentis exempt from the file format's versioning guarantees, so it is the part of thedocument most likely to disagree with what we can parse. Keeping it a separate root gives it
independent failure: a node that does not validate costs the caller its instrumentation config
and leaves the SDK configured.
ignoreExtraKeys()andIgnoresUnknownProvidersonly tolerateunknown keys and unregistered providers — not a known node that fails type validation.
Instrumentation config is resolved during autoload, under its own try/catch, because hooks must
be installed before the first instrumented call. An exception during processing is reported
verbatim, which provides more useful detail.
Deep copy between roots
Processing one document against two roots exposed a latent aliasing bug. Under ext-yaml,
YAML aliases materialise as genuine PHP references (symfony/yaml deep-copies instead), and
references survive the by-value copy
Processor::process()makes. Environment substitutionwrites back into the array it is given, so the first root processed would mutate what the second
sees:
Related fixes
ConfigProviderInterface::getInstrumentationConfig()takes aContext. Bothimplementations are updated.
Config\SDK\ConfigProvidernow logs through$context->loggerinstead ofLogsMessagesTrait, so a caller-supplied logger is actuallyhonoured — previously a warning was filtered by the global log level and could be discarded
despite the caller asking for it.
Configuration::getList()narrowed tolist<string>. It was declared: array, widerthan the
string|list<string>thatparseFile()accepts, so both callers carried a@psalm-suppress ArgumentTypeCoercion.ListParser::parse()now satisfieslist<string>onevery branch; its
is_array()branch previously passed maps and non-strings throughuntouched. All twelve
getList()callers already assumed a list of names.instrumentation/developmentschema is statically declared, addinggeneral.httpandsemconvsupport (file format 1.0) and tolerating unknownphpentries with a warning ratherthan a hard failure.
Config\SDK\ConfigProviderregistered under SPI as the spec's entry point forinstrumentations that read config without the SDK. It is deliberately not on the
autoloader's path, where resolving it would cost a second parse.
sensitive_query_parameters,request_captured_headers,response_captured_headers,known_methods— Symfony's scalarPrototype() let ints/floats/bools through to HttpConfig; nowValidation::ensureString() on eachYAML alias security/robustness (ext-yaml only)
Pre-existing bugs that copilot identified during review, fixed here for convenience.
$${FOO}escaped-literal resolved toFOO's value and placeholder-looking values got re-expanded — violating the spec's "env vars MUST NOT be injectable via env vars". Loader now copies by value; Configuration::copy() removed as redundant. New alias-escaped-substitution.yaml fixture. (35cbc59)(a: &x [*x])no longer exhaust memory. Was an uncatchable fatal during synchronous autoload; now depth-bounded and reported as an invalid file. (Copilot review on sdk-config: refactor .instrumentation processing #2076) (8765e72)YamlBackendParityTest: both backends must parse all 54 fixtures identically.ext-yamlinstalled in CI (php.yml) The yaml-gated guards silently skipped. Improve test coverage of both ext-yaml and symfony/yamlext-yamladded to base developer image: local testing (make testetc) now exercises ext-yamlsdk-configurationconstraints bumped to what should be the next versions released:open-telemetry/api^1.11,open-telemetry/sdk^1.16.Breaking changes
ConfigProviderInterface::getInstrumentationConfig()gains an optionalContextparameter.Source-compatible for callers; implementors outside this repo must update their signature. The
interface is marked
@experimental.Assisted-By: Claude Code