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

chore: log config init errors using exposed methods #4541

Merged
merged 3 commits into from
Apr 12, 2024
Merged

Conversation

lvrach
Copy link
Member

@lvrach lvrach commented Apr 4, 2024

WARN: To be merge after rudder-go-kit change is merged and released.

Description

Related and depended on rudderlabs/rudder-go-kit#406

Config init error will no longer be logged but the library, rather two methods are exposed so they can be handled downstream.

This is how the output looks like now:

No errors:

2024-04-04T10:14:09.178+0300    INFO    runner  runner/runner.go:107    Config: Using config file: ./config/config.yaml
2024-04-04T10:14:09.178+0300    INFO    runner  runner/runner.go:113    Config: Loaded .env file

With errors:

2024-04-04T10:15:21.710+0300    WARN    runner  runner/runner.go:105    Config: Failed to parse config file from path "./config/config.yaml", using default values: open ./config/config.yaml: no such file or directory
2024-04-04T10:15:21.710+0300    INFO    runner  runner/runner.go:111    Config: No .env file loaded: open .env: no such file or directory

vs before:

INFO: No .env file found.
[Config] :: Failed to parse config file from path "./config/config.yaml", using default values: open ./config/config.yaml: no such file or directory

Linear Ticket

https://linear.app/rudderstack/issue/PIPE-956/rudder-go-kit-config-init-error-logs

resolves PIPE-956

Security

  • The code changed/added as part of this pull request won't create any security issues with how the software is being used.

Copy link
Contributor

coderabbitai bot commented Apr 4, 2024

Important

Auto Review Skipped

Auto reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository.

To trigger a single review, invoke the @coderabbitai review command.


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Comment on lines +103 to +114
path, err := config.Default.ConfigFileUsed()
if err != nil {
r.logger.Warnf("Config: Failed to parse config file from path %q, using default values: %v", path, err)
} else {
r.logger.Infof("Config: Using config file: %s", path)
}

if err := config.Default.DotEnvLoaded(); err != nil {
r.logger.Infof("Config: No .env file loaded: %v", err)
} else {
r.logger.Infof("Config: Loaded .env file")
}
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
path, err := config.Default.ConfigFileUsed()
if err != nil {
r.logger.Warnf("Config: Failed to parse config file from path %q, using default values: %v", path, err)
} else {
r.logger.Infof("Config: Using config file: %s", path)
}
if err := config.Default.DotEnvLoaded(); err != nil {
r.logger.Infof("Config: No .env file loaded: %v", err)
} else {
r.logger.Infof("Config: Loaded .env file")
}
path, err := config.Default.ConfigFileUsed()
if err != nil {
r.logger.Warnn("Config: Failed to parse config file, using default values",
logger.NewStringField("path", path),
obskit.Error(err),
)
} else {
r.logger.Infon("Config: Using config file", logger.NewStringField("path", path))
}
if err := config.Default.DotEnvLoaded(); err != nil {
r.logger.Infon("Config: No .env file loaded", obskit.Error(err))
} else {
r.logger.Infon("Config: Loaded .env file")
}

@lvrach lvrach marked this pull request as ready for review April 10, 2024 07:44
Copy link

codecov bot commented Apr 10, 2024

Codecov Report

Attention: Patch coverage is 55.55556% with 4 lines in your changes are missing coverage. Please review.

Project coverage is 74.22%. Comparing base (d7e9a9e) to head (21e50e5).

Files Patch % Lines
runner/runner.go 55.55% 2 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4541      +/-   ##
==========================================
- Coverage   74.24%   74.22%   -0.03%     
==========================================
  Files         413      413              
  Lines       48371    48380       +9     
==========================================
- Hits        35915    35909       -6     
- Misses      10111    10122      +11     
- Partials     2345     2349       +4     

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

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