Repository navigation
Conversation
…en-telemetry#7949) Errors thrown while interpreting declarative configuration now include the path to the offending node in the configuration document, e.g. ".tracer_provider.processors[0].batch exporter is required but is null". DeclarativeConfigContext tracks the path of the node currently being interpreted. Factories push/pop path segments as they descend into children, and FileConfigUtil.requireNonNull / validateSingleKeyValue prefix messages with the current path.
|
|
Pull request dashboard statusWaiting on reviewers · refreshed 2026-10-26 20:50 UTC Review the latest changes. Status above doesn't look right?
|
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #8953 +/- ##
============================================
+ Coverage 90.66% 90.68% +0.02%
- Complexity 10888 10914 +26
============================================
Files 1015 1015
Lines 29736 29806 +70
Branches 3877 3882 +5
============================================
+ Hits 26959 27029 +70
- Misses 1860 1861 +1
+ Partials 917 916 -1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This branch has not been deployed
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Resolves #7949
Motivation
Errors raised while interpreting declarative configuration were generic and
ambiguous, and did not tell you where in the document the problem was:
A document can contain several processors, so this is hard to act on. The issue
asks for the message to include the path to the offending node:
Implementation
DeclarativeConfigContextnow tracks the path of the configuration nodecurrently being interpreted:
getConfigPath()returns""at the root, otherwise"." + join(".", segments).withConfigPath(segment, supplier)pushes/pops around a supplier (restores infinally).pushConfigPath(segment)/popConfigPath()for statement-style call sites(loops and multi-statement blocks) where a lambda is awkward or where NullAway
cannot carry the null-check of a nullable getter into the lambda.
FileConfigUtil.requireNonNull(context, object, description)prefixes the messagewith
getConfigPath(), and a newFileConfigUtil.withConfigPath(context, message)helper covers messages that are not built via
requireNonNull.Each factory descends into its children by pushing a path segment named after the
corresponding configuration model field, so the segment matches the documented key:
OpenTelemetryConfigurationFactorypropagator,resource,meter_provider,logger_provider,tracer_providerTracerProviderFactorysampler,processors[i],id_generator,tracer_configurator/development.tracers[i]LoggerProviderFactoryprocessors[i],logger_configurator/development.loggers[i]MeterProviderFactoryreaders[i],views[i],meter_configurator/development.meters[i]MetricReaderFactoryperiodic,pullSpanProcessorFactorybatch,simpleLogRecordProcessorFactorybatch,simpleSamplerFactoryalways_recordComposableSamplerFactoryrule_based,parent_thresholdComposableRuleBasedSamplerFactoryrules[i],attribute_values,attribute_patternsAttributeListFactoryattributes[i]Before / after
Testing
parseAndCreate_ErrorIncludesDocumentPathinDeclarativeConfigurationCreateTestreproduces the exact scenario from the issue(YAML with
tracer_provider.processors[0].batchmissingexporter).SpanProcessorFactoryTest,LogRecordProcessorFactoryTest,MetricReaderFactoryTest, andSamplerFactoryTest; the factory calls are now wrappedin the corresponding
withConfigPath(...)so the assertions verify the real document path.Notes
variable before use inside a lambda, which is why some call sites use
push/popConfigPathintry/finallyrather thanwithConfigPath.