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

Fix bug on empty openmetrics scrape response #14508

Merged
merged 1 commit into from
May 3, 2023

Conversation

ethan-lowman-dd
Copy link
Contributor

What does this PR do?

It looks like #14445 introduced a bug that causes empty openmetrics scrapes to fail.

Without the fix, the added test fails as follows:

tests/test_openmetrics.py:110: in test_openmetrics_empty_response
    dd_run_check(check)
../datadog_checks_dev/datadog_checks/dev/plugin/pytest.py:228: in run_check
    raise Exception('\n'.join(exc_lines))
E   Exception:
E   Traceback (most recent call last):
E     File "/Users/ethan.lowman/go/src/github.com/DataDog/integrations-core/datadog_checks_base/datadog_checks/base/checks/openmetrics/v2/scraper.py", line 289, in parse_metrics
E       line_streamer = chain([next(line_streamer)], line_streamer)
E   StopIteration
E
E   The above exception was the direct cause of the following exception:
E
E   Traceback (most recent call last):
E     File "/Users/ethan.lowman/go/src/github.com/DataDog/integrations-core/datadog_checks_base/datadog_checks/base/checks/base.py", line 1135, in run
E       self.check(instance)
E     File "/Users/ethan.lowman/go/src/github.com/DataDog/integrations-core/datadog_checks_base/datadog_checks/base/checks/openmetrics/v2/base.py", line 64, in check
E       scraper.scrape()
E     File "/Users/ethan.lowman/go/src/github.com/DataDog/integrations-core/datadog_checks_base/datadog_checks/base/checks/openmetrics/v2/scraper.py", line 247, in scrape
E       for metric in self.consume_metrics(runtime_data):
E     File "/Users/ethan.lowman/go/src/github.com/DataDog/integrations-core/datadog_checks_base/datadog_checks/base/checks/openmetrics/v2/scraper.py", line 267, in consume_metrics
E       for metric in metric_parser:
E   RuntimeError: generator raised StopIteration

Motivation

Bug fix.

Additional Notes

Review checklist (to be filled by reviewers)

  • Feature or bugfix MUST have appropriate tests (unit, integration, e2e)
  • PR title must be written as a CHANGELOG entry (see why)
  • Files changes must correspond to the primary purpose of the PR as described in the title (small unrelated changes should have their own PR)
  • PR must have changelog/ and integration/ labels attached
  • If the PR doesn't need to be tested during QA, please add a qa/skip-qa label.

@codecov
Copy link

codecov bot commented May 3, 2023

Codecov Report

Merging #14508 (6f7fa56) into master (6ddcc50) will increase coverage by 0.75%.
The diff coverage is 88.88%.

Flag Coverage Δ
active_directory 100.00% <ø> (+17.64%) ⬆️
activemq_xml 82.31% <ø> (ø)
airflow 90.00% <ø> (ø)
amazon_msk 89.07% <ø> (ø)
ambari 85.75% <ø> (ø)
apache 95.08% <ø> (ø)
arangodb 98.21% <ø> (ø)
argocd 88.43% <ø> (ø)
aspdotnet 100.00% <ø> (+26.19%) ⬆️
avi_vantage 92.54% <ø> (ø)
azure_iot_edge 82.00% <ø> (ø)
boundary 100.00% <ø> (ø)
btrfs 82.91% <ø> (ø)
cacti 87.90% <ø> (ø)
calico 83.33% <ø> (ø)
cassandra_nodetool 93.16% <ø> (ø)
ceph 91.02% <ø> (ø)
cert_manager 77.41% <ø> (ø)
cilium 75.34% <ø> (+0.93%) ⬆️
cisco_aci 95.27% <ø> (ø)
citrix_hypervisor 87.50% <ø> (ø)
cloud_foundry_api 95.98% <ø> (+0.12%) ⬆️
cloudera 99.82% <ø> (ø)
cockroachdb 91.90% <ø> (ø)
consul 91.64% <ø> (ø)
coredns 94.54% <ø> (ø)
couch 95.19% <ø> (+0.48%) ⬆️
couchbase 84.28% <ø> (ø)
crio 89.79% <ø> (ø)
datadog_checks_base 89.66% <75.00%> (+0.34%) ⬆️
datadog_checks_dev 82.75% <ø> (+0.07%) ⬆️
datadog_checks_downloader 81.65% <ø> (ø)
datadog_cluster_agent 90.00% <ø> (ø)
ddev 99.16% <ø> (+0.52%) ⬆️
directory 96.42% <ø> (ø)
disk 89.16% <ø> (-2.15%) ⬇️
dns_check 93.90% <ø> (ø)
dotnetclr 91.39% <ø> (+12.90%) ⬆️
ecs_fargate 80.92% <ø> (ø)
eks_fargate 94.05% <ø> (ø)
elastic 91.91% <ø> (ø)
envoy 94.18% <ø> (ø)
etcd 93.96% <ø> (ø)
exchange_server 96.85% <ø> (+11.81%) ⬆️
external_dns 89.09% <ø> (ø)
fluentd 94.77% <ø> (ø)
foundationdb 78.50% <ø> (ø)
gearmand 78.26% <ø> (+1.24%) ⬆️
gitlab_runner 91.94% <ø> (ø)
glusterfs 80.09% <ø> (+0.92%) ⬆️
go_expvar 92.73% <ø> (ø)
gunicorn 92.10% <ø> (-0.76%) ⬇️
haproxy 95.13% <ø> (+0.16%) ⬆️
harbor 80.04% <ø> (ø)
hazelcast 92.39% <ø> (ø)
hdfs_datanode 89.74% <ø> (ø)
hdfs_namenode 86.72% <ø> (ø)
http_check 95.82% <ø> (+2.15%) ⬆️
ibm_ace 91.79% <ø> (ø)
ibm_db2 95.10% <ø> (ø)
ibm_i 81.95% <ø> (ø)
ibm_mq 91.37% <ø> (+0.13%) ⬆️
iis 95.00% <ø> (+37.60%) ⬆️
istio 77.43% <ø> (+0.55%) ⬆️
kong 87.56% <ø> (ø)
kube_apiserver_metrics 97.89% <ø> (ø)
kube_controller_manager 96.00% <ø> (ø)
kube_dns 95.97% <ø> (ø)
kube_metrics_server 94.87% <ø> (ø)
kube_proxy 96.80% <ø> (ø)
kube_scheduler 96.53% <ø> (ø)
kubelet 90.74% <ø> (ø)
kubernetes_state 89.18% <ø> (ø)
kyototycoon 85.96% <ø> (ø)
lighttpd 83.64% <ø> (ø)
linkerd 85.14% <ø> (+1.14%) ⬆️
linux_proc_extras 96.22% <ø> (ø)
mapr 82.70% <ø> (ø)
marathon 83.12% <ø> (ø)
marklogic 96.03% <ø> (ø)
mcache 93.50% <ø> (ø)
mesos_master 89.75% <ø> (ø)
mesos_slave 93.63% <ø> (ø)
mongo 96.63% <ø> (ø)
mysql 87.42% <ø> (+0.03%) ⬆️
nagios 89.01% <ø> (ø)
network 94.01% <ø> (+31.91%) ⬆️
nfsstat 95.20% <ø> (ø)
nginx 95.24% <ø> (+0.54%) ⬆️
nginx_ingress_controller 98.36% <ø> (ø)
openmetrics 98.02% <100.00%> (+0.06%) ⬆️
openstack 51.45% <ø> (ø)
openstack_controller 91.12% <ø> (ø)
pdh_check 95.65% <ø> (ø)
pgbouncer 91.33% <ø> (ø)
php_fpm 90.25% <ø> (+0.84%) ⬆️
postfix 88.04% <ø> (ø)
powerdns_recursor 96.65% <ø> (ø)
process 85.42% <ø> (+0.28%) ⬆️
prometheus 94.17% <ø> (ø)
proxysql 98.97% <ø> (ø)
pulsar 100.00% <ø> (ø)
redisdb 87.50% <ø> (ø)
rethinkdb 97.93% <ø> (ø)
riak 99.22% <ø> (ø)
riakcs 93.61% <ø> (ø)
sap_hana 91.37% <ø> (-0.27%) ⬇️
scylla 100.00% <ø> (ø)
silk 93.82% <ø> (ø)
singlestore 90.81% <ø> (ø)
snmp 84.55% <ø> (+0.04%) ⬆️
snowflake 96.47% <ø> (ø)
spark 93.63% <ø> (ø)
squid 100.00% <ø> (ø)
ssh_check 91.58% <ø> (ø)
statsd 87.36% <ø> (+1.05%) ⬆️
supervisord 92.30% <ø> (ø)
system_core 90.90% <ø> (ø)
system_swap 98.30% <ø> (ø)
tcp_check 92.92% <ø> (ø)
teamcity 88.35% <ø> (+2.87%) ⬆️
temporal 100.00% <ø> (ø)
teradata 94.24% <ø> (ø)
tls 92.07% <ø> (+0.82%) ⬆️
tokumx 58.40% <ø> (ø)
traffic_server 96.13% <ø> (ø)
twemproxy 79.45% <ø> (ø)
twistlock 79.62% <ø> (ø)
varnish 84.39% <ø> (+0.26%) ⬆️
vault 95.53% <ø> (+0.57%) ⬆️
vertica 98.50% <ø> (ø)
voltdb 96.84% <ø> (ø)
vsphere 89.90% <ø> (+0.08%) ⬆️
win32_event_log 86.54% <ø> (+0.55%) ⬆️
windows_performance_counters 98.36% <ø> (ø)
windows_service 98.00% <ø> (ø)
wmi_check 92.91% <ø> (ø)
yarn 89.50% <ø> (ø)
zk 82.62% <ø> (+1.11%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

@github-actions
Copy link

github-actions bot commented May 3, 2023

Test Results

     970 files       970 suites   6h 45m 37s ⏱️
  5 385 tests   5 309 ✔️      71 💤 2  3 🔥
22 370 runs  18 711 ✔️ 3 654 💤 2  3 🔥

For more details on these failures and errors, see this check.

Results for commit 6f7fa56.

@ethan-lowman-dd ethan-lowman-dd merged commit bd31fe9 into master May 3, 2023
@ethan-lowman-dd ethan-lowman-dd deleted the ethan.lowman/fix-empty-openmetrics branch May 3, 2023 23:36
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.

3 participants