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

Allow env vars to control debug logging for the lambda #238

Merged
merged 1 commit into from
Dec 4, 2023
Merged
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
10 changes: 8 additions & 2 deletions lambda/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@ func Handler(ctx context.Context, evt json.RawMessage) (string, error) {
quiet := quietString == "1" || quietString == "true"
timeout := os.Getenv("BUILDKITE_AGENT_METRICS_TIMEOUT")

debugEnvVar := os.Getenv("BUILDKITE_AGENT_METRICS_DEBUG")
debug := debugEnvVar == "1" || debugEnvVar == "true"
Copy link
Contributor

Choose a reason for hiding this comment

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

I think, one day, we should use strconv.ParseBool for all these.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I kinda wish it were stricter, if it only accepted "true" and "false" and errored on everything else, I would be more happy.


debugHTTPEnvVar := os.Getenv("BUILDKITE_AGENT_METRICS_DEBUG_HTTP")
debugHTTP := debugHTTPEnvVar == "1" || debugHTTPEnvVar == "true"

if quiet {
log.SetOutput(io.Discard)
}
Expand Down Expand Up @@ -108,8 +114,8 @@ func Handler(ctx context.Context, evt json.RawMessage) (string, error) {
Token: token,
Queues: queues,
Quiet: quiet,
Debug: false,
DebugHttp: false,
Debug: debug,
DebugHttp: debugHTTP,
Timeout: configuredTimeout,
})
}
Expand Down