-
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
Fix openmetrics v2 service check: there shouldn’t be any host #13146
Conversation
Codecov Report
Flags with carried forward coverage won't be shown. Click here to find out more. |
2b00612
to
0b658e1
Compare
``` style run-test: commands[3] | mypy --config-file=../mypy.ini --py2 --check-untyped-defs --follow-imports silent datadog_checks/base/checks/base.py datadog_checks/base/checks/win/wmi/__init__.py datadog_checks/base/checks/win/winpdh_base.py datadog_checks/base/checks/base.py:213:13: error: Attribute "hostname" already defined on line 211 Found 1 error in 1 file (checked 3 source files) ERROR: InvocationError for command /home/vsts/work/1/s/datadog_checks_base/.tox/style/bin/mypy --config-file=../mypy.ini --py2 --check-untyped-defs --follow-imports silent datadog_checks/base/checks/base.py datadog_checks/base/checks/win/wmi/__init__.py datadog_checks/base/checks/win/winpdh_base.py (exited with code 1) ```
This reverts commit e9af726. This rewrite was useless since it was still generating the following error: ``` style run-test: commands[3] | mypy --config-file=../mypy.ini --py2 --check-untyped-defs --follow-imports silent datadog_checks/base/checks/base.py datadog_checks/base/checks/win/wmi/__init__.py datadog_checks/base/checks/win/winpdh_base.py datadog_checks/base/checks/base.py:212:13: error: Attribute "hostname" already defined on line 210 Found 1 error in 1 file (checked 3 source files) ERROR: InvocationError for command /home/vsts/work/1/s/datadog_checks_base/.tox/style/bin/mypy --config-file=../mypy.ini --py2 --check-untyped-defs --follow-imports silent datadog_checks/base/checks/base.py datadog_checks/base/checks/win/wmi/__init__.py datadog_checks/base/checks/win/winpdh_base.py (exited with code 1) ```
I’ve checked some of the CI tests failures and all the ones I looked at failed because of an error like:
|
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 don't have enough context to understand what this is trying to do, but if the change targets OpenMetrics V2, it doesn't sound like we should be touching the base AgentCheck
class that affects every integration.
On Kubernetes, a It’s possible for a specific metric to specify an explicit host thanks to a Because everything described above is generic and applies to all checks, the implementation of this logic is done in the GO code of Here is where the This parameter is then used when initializing the senders used by the checks: https://github.com/DataDog/datadog-agent/blob/7.39.2/pkg/collector/python/check.go#L242-L250 The flag set is then used to not default the hostname when not set on a metric: https://github.com/DataDog/datadog-agent/blob/7.39.2/pkg/aggregator/sender.go#L253-L255 Everything described above applies to all checks. In the light of what the This rule was respected by the V1 version of Although the bug has been initially reported on an |
To keep context within the PR, as there was some offline discussion: Checks based on the base integrations-core/datadog_checks_base/datadog_checks/base/checks/base.py Lines 666 to 667 in 83d570f
The Therefore, it seems better to simply make |
@alopezz I’ve just updated this PR to move the fix in the |
Looks good but a couple of tests are failing, involving EDIT: I'm referring only to tests affecting datadog_checks_base, the rest of failures are not related from what I can see. |
The |
This reverts commit 4dfd966.
c5d0871
to
e5db34f
Compare
/azp help |
Supported commands
See additional documentation. |
/azp list |
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.
Looks good now.
What does this PR do?
Remove
host
from openmetrics v2 metrics when executed as a service check.Motivation
Service checks should never attach a host to the metrics they emit. Or at least, not the host of the cluster check runner that has executed the check.
Additional Notes
Describe how to test/QA your changes
Add AD annotations with
openmetrics_endpoint
and notprometheus_url
on a k8s Service to schedule anopenmetrics
V2 check.Validate that no
host
is attached to the metrics.Review checklist (to be filled by reviewers)
changelog/
andintegration/
labels attachedqa/skip-qa
label.