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

Expose the single check instance as an attribute #3093

Merged
merged 1 commit into from
Feb 12, 2019
Merged

Conversation

ofek
Copy link
Contributor

@ofek ofek commented Feb 10, 2019

Motivation

Easier access to the instance (for new checks) so you don't have to pass it around everywhere

@codecov
Copy link

codecov bot commented Feb 10, 2019

Codecov Report

Merging #3093 into master will decrease coverage by 8.98%.
The diff coverage is 100%.

@@            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

Copy link
Contributor

@gzussa gzussa left a 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
Copy link
Contributor

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?

Copy link
Contributor Author

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

Copy link
Contributor

Choose a reason for hiding this comment

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

Confirmed

Copy link
Member

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

Copy link
Contributor

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
Copy link
Contributor

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.

@ofek ofek merged commit 5ba0031 into master Feb 12, 2019
@ofek ofek deleted the ofek/instance branch February 12, 2019 17:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants