Skip to content
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] Allow calling component.ValidateConfig at the top level #12102

Merged

Conversation

evan-bradley
Copy link
Contributor

@evan-bradley evan-bradley commented Jan 15, 2025

Description

Updates component.ValidateConfig to recurse through the entire config object by checking for ConfigValidator implementations of structs that are under interfaces. Right now ValidateConfig stops at things like component.Config which themselves can't implement component.ValidateConfig because callValidateIfPossible can only see the interface and not the concrete type before this change.

Link to tracking issue

Replaces #12058.

Works toward #11524.

Copy link

codecov bot commented Jan 15, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.60%. Comparing base (6757cc7) to head (c53dbe7).
Report is 45 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #12102   +/-   ##
=======================================
  Coverage   91.60%   91.60%           
=======================================
  Files         461      461           
  Lines       24678    24678           
=======================================
  Hits        22607    22607           
  Misses       1689     1689           
  Partials      382      382           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@evan-bradley
Copy link
Contributor Author

I'm skipping the contrib tests for now, I'll fix any errors with an update-otel PR in contrib.

@evan-bradley evan-bradley marked this pull request as ready for review January 16, 2025 20:29
@evan-bradley evan-bradley requested a review from a team as a code owner January 16, 2025 20:29
@mx-psi mx-psi requested a review from jade-guiton-dd January 20, 2025 13:07
@mx-psi mx-psi requested a review from TylerHelmuth January 20, 2025 16:36
@TylerHelmuth TylerHelmuth added the ready-to-merge Code review completed; ready to merge by maintainers label Jan 22, 2025
@mx-psi mx-psi added this pull request to the merge queue Jan 23, 2025
Merged via the queue into open-telemetry:main with commit 24f88da Jan 23, 2025
67 of 68 checks passed
sincejune added a commit to sincejune/opentelemetry-collector that referenced this pull request Jan 24, 2025
github-merge-queue bot pushed a commit that referenced this pull request Jan 31, 2025
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue.
Ex. Adding a feature - Explain what this achieves.-->
#### 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` on
`otelcol.Config` and remove manual calls to `Validate`, but no
information will be missing. If this is a concern we can do both steps
at once.

Example error messages:

```
collector server run finished with error: invalid configuration: receivers::otlp: must specify at least one protocol when using the OTLP receiver
service::telemetry: collector telemetry metrics reader should exist when metric level is not None, level is Normal
```

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.

---------

Co-authored-by: Evan Bradley <evan-bradley@users.noreply.github.com>
Co-authored-by: Pablo Baeyens <pbaeyens31+github@gmail.com>
Co-authored-by: Pablo Baeyens <pablo.baeyens@datadoghq.com>
sfc-gh-sili pushed a commit to sfc-gh-sili/opentelemetry-collector that referenced this pull request Feb 3, 2025
…2108)

<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue.
Ex. Adding a feature - Explain what this achieves.-->
#### Description

Follow up to
open-telemetry#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` on
`otelcol.Config` and remove manual calls to `Validate`, but no
information will be missing. If this is a concern we can do both steps
at once.

Example error messages:

```
collector server run finished with error: invalid configuration: receivers::otlp: must specify at least one protocol when using the OTLP receiver
service::telemetry: collector telemetry metrics reader should exist when metric level is not None, level is Normal
```

I'll clean this PR up once
open-telemetry#12102 is
merged, but you can see the latest commit for the changes relevant to
only this PR.

---------

Co-authored-by: Evan Bradley <evan-bradley@users.noreply.github.com>
Co-authored-by: Pablo Baeyens <pbaeyens31+github@gmail.com>
Co-authored-by: Pablo Baeyens <pablo.baeyens@datadoghq.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready-to-merge Code review completed; ready to merge by maintainers Skip Contrib Tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants