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

support .env file to load env #2675

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cmd/otelcol/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"log"
"os"

_ "github.com/joho/godotenv/autoload"
Copy link
Contributor

Choose a reason for hiding this comment

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

What is the behavior of invalid .env content and would it be better to use the library directly to marshal the error to a proper handler, like in main or internal/settings?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What behavior would you like to see if the content is invalid? Should the collector forcefully exit then, or is an error log ok?

Copy link
Contributor

@rmfitzpatrick rmfitzpatrick Mar 13, 2023

Choose a reason for hiding this comment

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

imo I'd expect there to be a logged warning about the validity of the file w/ the parsing error and for none of the env vars in the file to be sourced but can see other options being desirable. I'm not sure how feasible this is given we aren't controlling the implementation as is*. Terminating the collector seems overkill.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thanks, I'll factor that in.

flag "github.com/spf13/pflag"
"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/confmap"
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ require (
github.com/hashicorp/vault-plugin-auth-gcp v0.15.0
github.com/hashicorp/vault/api v1.9.0
github.com/jaegertracing/jaeger v1.41.0
github.com/joho/godotenv v1.3.0
github.com/knadh/koanf v1.5.0
github.com/open-telemetry/opentelemetry-collector-contrib/exporter/fileexporter v0.72.0
github.com/open-telemetry/opentelemetry-collector-contrib/exporter/kafkaexporter v0.72.0
Expand Down