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

[service]: add new subcommand to examine the initial configuration #11775

Open
wants to merge 38 commits into
base: main
Choose a base branch
from

Conversation

VihasMakwana
Copy link
Contributor

@VihasMakwana VihasMakwana commented Nov 29, 2024

Description

Why is this useful?

  • Users might want to examine the config if they face any errors at boot time. This subcommand prints the configuration on stdout after merging and resolving from all the --config sources.
  • The command prints the configuration even if it's invalid. This can help user to track down the faulty piece of config.

Usage

./otelcorecol examine --config=file:file.yaml --config=http://remote:8080/config --config=file:file2.yaml

Link to tracking issue

Fixes ##11479

Testing

Added unit test cases.

Documentation

Updated readme.

@VihasMakwana VihasMakwana requested a review from a team as a code owner November 29, 2024 14:03
otelcol/command_examine.go Outdated Show resolved Hide resolved
Co-authored-by: Mauri de Souza Meneguzzo <[email protected]>
@VihasMakwana VihasMakwana requested a review from mauri870 December 2, 2024 15:34
bogdandrutu pushed a commit that referenced this pull request Dec 2, 2024
Copy link

codecov bot commented Dec 2, 2024

Codecov Report

Attention: Patch coverage is 90.32258% with 3 lines in your changes missing coverage. Please review.

Project coverage is 91.38%. Comparing base (44b3eed) to head (52e1abf).

Files with missing lines Patch % Lines
otelcol/command_print.go 90.00% 2 Missing and 1 partial ⚠️

❌ Your patch check has failed because the patch coverage (90.32%) is below the target coverage (95.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #11775      +/-   ##
==========================================
- Coverage   91.38%   91.38%   -0.01%     
==========================================
  Files         468      469       +1     
  Lines       25610    25641      +31     
==========================================
+ Hits        23404    23432      +28     
- Misses       1790     1792       +2     
- Partials      416      417       +1     

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

@VihasMakwana VihasMakwana requested a review from mauri870 December 9, 2024 12:47
@VihasMakwana
Copy link
Contributor Author

@dmitryax @mauri870 can you take a look?

if err != nil {
return fmt.Errorf("error while marshaling to yaml: %w", err)
}
log.Printf("\n%s", b)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you change to fmt.Printf here? This output is likely to be piped/redirected and I would rather not have a random timestamp at the start of the output.

@mauri870
Copy link

Reviewed again, LGTM. Thanks for adding a test to check the tool output.

@github-actions github-actions bot removed the Stale label Jan 16, 2025
mx-psi
mx-psi previously requested changes Jan 16, 2025
otelcol/command_examine.go Outdated Show resolved Hide resolved
.chloggen/examine-subcommand.yaml Outdated Show resolved Hide resolved
otelcol/command_examine.go Outdated Show resolved Hide resolved
otelcol/command_examine.go Outdated Show resolved Hide resolved
otelcol/testdata/configs/2-config-output.yaml Outdated Show resolved Hide resolved
@VihasMakwana
Copy link
Contributor Author

@mx-psi I've addressed the review comments and added a feature flag for this new command. Please take a look!

@VihasMakwana VihasMakwana requested a review from mx-psi January 27, 2025 14:25
otelcol/command_print.go Outdated Show resolved Hide resolved
otelcol/command_print.go Outdated Show resolved Hide resolved
@mx-psi mx-psi dismissed their stale review January 31, 2025 16:31

Feature gate added

@VihasMakwana VihasMakwana requested a review from mx-psi January 31, 2025 16:33
@VihasMakwana
Copy link
Contributor Author

@mx-psi Thank you for your review. Once the CI is green, this should be good to go.

Copy link
Member

@mx-psi mx-psi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One thing left to address (not necessarily on this PR) is sensitive values. This would leak any sensitive values, so we need to make sure the user understands this

otelcol/command_print.go Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants