-
Notifications
You must be signed in to change notification settings - Fork 4
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
Disable config switch #191
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved with some non-blocking comments.
configuration := config.New() | ||
|
||
initLogging(&configuration) | ||
|
||
ossignal.Watch() | ||
|
||
m := metrics.New() | ||
var m *metrics.MetricEmitter = nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Kind of a nit, especially if this library is going away, but might be nice to instead extract an interface and use a no-op implementation so we don't have to check for nil before calling methods on the variable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I like that. I'll add a comment to this effect for now.
|
||
shutdownCondition := registerApiAndStartMainLoop(m, &configuration) | ||
shutdownCondition := registerApiAndStartMainLoop(enabled, m, &configuration) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also a nit and just a personal style preference (it's also in Clean Code!): instead of passing in a boolean flag then modifying the behavior of the function based on its value, consider creating two separate functions.
@@ -121,5 +140,9 @@ func initLogging(configuration *config.Configuration) { | |||
} | |||
|
|||
func extensionName() string { | |||
return path.Base(os.Args[0]) | |||
name := os.Getenv(extensionNameKey) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: another way to write this function using Go idioms:
if name := os.Getenv(extensionNameKey); name != "" {
return name
}
return path.Base(os.Args[0])
Add a config environment variable to disable the collection of metrics through this extension. Owing to the rules the lambda engine places on extensions, this isn't as simple as "just exit" - you still have to Register as an extension, and ask for at least the shutdown event. Additionally, add a config switch for "extension name" to make a complicated workaround for disabling the opentelemetry collector possible.