-
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
Expose the single check instance as an attribute #3093
Conversation
Codecov Report
@@ Coverage Diff @@
## master #3093 +/- ##
==========================================
- Coverage 84.28% 75.29% -8.99%
==========================================
Files 668 47 -621
Lines 36107 3578 -32529
Branches 4283 427 -3856
==========================================
- Hits 30431 2694 -27737
+ Misses 4432 776 -3656
+ Partials 1244 108 -1136 |
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 am not again having self.instance
but I am not convinced this is without risk. Adding this here may conflict with check that define they own self.instance
. I agreed that it would override the value however, we may run into conflicting cases.
@@ -89,6 +89,9 @@ def __init__(self, *args, **kwargs): | |||
# new-style init: the 3rd argument is `instances` | |||
self.instances = args[2] | |||
|
|||
# Agent 6+ will only have one instance |
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.
Why would agent 6+ only have one instance?
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.
Because there is a new AgentCheck instantiated for every check instance cc @olivielpeau or @truthbk maybe can confirm
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.
Confirmed
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.
this is correct, since v6.0 the Agent instantiates one instance of the AgentCheck
class per configured instance of the check. Relevant code: https://github.com/DataDog/datadog-agent/blob/6.9.0/pkg/collector/py/loader.go#L243-L255
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.
ok i wasn't aware of this. Thanks for the update.
@@ -89,6 +89,9 @@ def __init__(self, *args, **kwargs): | |||
# new-style init: the 3rd argument is `instances` | |||
self.instances = args[2] | |||
|
|||
# Agent 6+ will only have one instance |
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.
ok i wasn't aware of this. Thanks for the update.
Motivation
Easier access to the instance (for new checks) so you don't have to pass it around everywhere