-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[component] Print path to error in ValidateConfig
#12108
base: main
Are you sure you want to change the base?
[component] Print path to error in ValidateConfig
#12108
Conversation
I think this can be rebased and marked as ready for review |
9b84570
to
38d4974
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #12108 +/- ##
==========================================
+ Coverage 91.28% 91.31% +0.02%
==========================================
Files 465 465
Lines 25616 25693 +77
==========================================
+ Hits 23384 23461 +77
Misses 1819 1819
Partials 413 413 ☔ View full report in Codecov by Sentry. |
As expected, some contrib tests are failing despite no outward API changes. I feel like this is more of an indication that the tests should be rewritten than that we've made a breaking change: most of the test failures seem to be happening because they assume a specific structure of the error object instead of working with the |
Can we fix (some or all of) the contrib tests before merging this? |
Co-authored-by: Pablo Baeyens <[email protected]>
It's definitely possible, let me see what I can do. |
I opened open-telemetry/opentelemetry-collector-contrib#37579 to address hopefully most of the failing contrib tests. Unfortunately it's proven bit challenging to run everything locally. |
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue. Ex. Adding a feature - Explain what this achieves.--> #### Description Fixes some errors introduced by open-telemetry/opentelemetry-collector#12108. Overall this makes tests that check errors resulting from config validation more resilient by only checking that the error message contains the information relevant to the component. The tests changed in this PR make more precise assumptions about the error message that no longer hold up if `component.ValidateConfig` returns errors with different internal structures or messages. I've run this locally with the changes in open-telemetry/opentelemetry-collector#12108, but I encountered some issues that prevented running tests locally in some modules, so not all errors may be fixed. I will play more with this tomorrow, but I also think it's safe to merge this as-is and fix the remaining errors during a `make update-otel` PR.
Description
Follow up to #12102.
This prints the full path to where the error occurred in a config object using available reflection metadata. Currently some paths will be duplicated until we shift otelcol to call
component.ValidateConfig
onotelcol.Config
and remove manual calls toValidate
, but no information will be missing. If this is a concern we can do both steps at once.Example error messages:
I'll clean this PR up once #12102 is merged, but you can see the latest commit for the changes relevant to only this PR.