-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Correctly handle errors during initialization + code refactor #9626
Conversation
|
||
|
||
class LegacyKafkaCheck_0_10_2(AgentCheck): | ||
class LegacyKafkaCheck_0_10_2(object): |
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.
I'm not convinced this is a better approach for this case; can you explain your rationale for composition over inheritance?
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.
- Option 1 is to make LegacyKafkaCheck and NewKafkaCheck both inherit from
KafkaConsumerCheck
. This can't be done as the agent refuses to loadKafkaConsumerCheck
if it's subclassed anywhere. - Option 2 is to keep a class
KafkaCheck
and override the__new__
method to return aLegacyKafkaCheck
instance in case a certain condition is found after connecting to Kafka. This is the current situation and it needs to be removed with the refactor. Indeed we can't retry checking that version condition by setting the check as acheck_initialization
, once the class is initialized we can't change it. - Option 3 is to make a
KafkaConsumer
main class that inherit from AgentCheck and this is the only class that can inherit from it. We then need aNewKafkaConsumer
implementation and aLegacyKafkaCheck
implementation. The common code can now live inKafkaConsumer
.
With option 3 there are a few design possibilities, I decided to override the __getattr__
method because of the large number of calls to self.gauge
, self.submit_metadata
etc. that are happening in many places.
* Refactor kafka_consumer * fixup * fixup * Address review 60ac6ae
No description provided.