Skip to content

Emit telemetry when OpenMetrics reaches its metric limit#24577

Draft
nubtron wants to merge 3 commits into
masterfrom
nubtron/ai-7012-openmetrics-telemetry
Draft

Emit telemetry when OpenMetrics reaches its metric limit#24577
nubtron wants to merge 3 commits into
masterfrom
nubtron/ai-7012-openmetrics-telemetry

Conversation

@nubtron

@nubtron nubtron commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

  • Add an optional first-limit-reached callback to the metric limiter while preserving its existing warning, counting, de-duplication, and drop behavior.
  • Opt OpenMetrics v1 and v2 checks into a best-effort openmetrics.max_returned_metrics_reached Agent telemetry counter, emitted once per limiter warning with only the canonical check_name label.
  • Feature-detect the labeled Agent bridge so newer datadog_checks_base remains compatible with older Agents, and keep the signal independent from debug_metrics.metric_contexts.

Validation:

  • ddev --no-interactive test datadog_checks_base -- tests/base/utils/test_utils.py -k limiter
  • ddev --no-interactive test datadog_checks_base -- tests/base/checks/test_agent_check.py -k 'metric_limit or debug_metrics or telemetry'
  • ddev --no-interactive test -fs datadog_checks_base
  • ddev --no-interactive test --lint datadog_checks_base
  • Combined custom-Agent smoke tests for OpenMetrics v1 and v2, confirming one warning, raw cumulative value 1, and only check_name=openmetrics in the filtered payload.

Motivation

OpenMetrics drops metric contexts beyond max_returned_metrics for the remainder of a check run. Today this is visible only through a one-per-run warning. Emitting a low-cardinality structured counter at the same transition makes this degradation observable without exposing endpoint or instance identity.

Companion Agent bridge and Agent Telemetry profile: DataDog/datadog-agent#53751

Review checklist (to be filled by reviewers)

  • Feature or bugfix MUST have appropriate tests (unit, integration, e2e)
  • Add qa/required if this PR needs QA validation, or qa/skip-qa if it does not. Exactly one of the two is required.
  • If you need to backport this PR to another branch, you can add the backport/<branch-name> label to the PR and it will automatically open a backport PR once this one is merged

@nubtron nubtron added the qa/skip-qa Automatically skip this PR for the next QA label Jul 16, 2026
@dd-octo-sts

dd-octo-sts Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Validation Report

All 21 validations passed.

Show details
Validation Description Status
agent-reqs Verify check versions match the Agent requirements file
ci Validate CI configuration and code coverage settings
codeowners Validate every integration has a CODEOWNERS entry
config Validate default configuration files against spec.yaml
dep Verify dependency pins are consistent and Agent-compatible
http Validate integrations use the HTTP wrapper correctly
imports Validate check imports do not use deprecated modules
integration-style Validate check code style conventions
jmx-metrics Validate JMX metrics definition files and config
labeler Validate PR labeler config matches integration directories
legacy-signature Validate no integration uses the legacy Agent check signature
license-headers Validate Python files have proper license headers
licenses Validate third-party license attribution list
metadata Validate metadata.csv metric definitions
models Validate configuration data models match spec.yaml
openmetrics Validate OpenMetrics integrations disable the metric limit
package Validate Python package metadata and naming
qa-label Validate the pull request declares whether it needs QA for the next Agent release
readmes Validate README files have required sections
saved-views Validate saved view JSON file structure and fields
version Validate version consistency between package and changelog

View full run

@datadog-datadog-us1-prod

datadog-datadog-us1-prod Bot commented Jul 16, 2026

Copy link
Copy Markdown

Pipelines  Tests  Code Coverage

Fix all issues with BitsAI

⚠️ Warnings

🚦 3 Pipeline jobs failed

PR All | test / j06ca546 / SNMP   View in Datadog   GitHub Actions

PR All | test / j92d42de / ArgoCD   View in Datadog   GitHub Actions

PR All | test / j71c1491 / Apache NiFi   View in Datadog   GitHub Actions

🧪 3 Tests failed in 1 job

PR All | run   GitHub Actions

test_e2e_openmetrics_v1 from test_e2e.py   View in Datadog
Needed exactly 2 candidates for &#39;argocd.app_controller.openmetrics.health&#39;, got 0
Expected:
        ServiceCheckStub(check_id=None, name=&#39;argocd.app_controller.openmetrics.health&#39;, status=0, tags=None, hostname=None, message=None)
Difference to closest:
        Expected name: argocd.app_controller.openmetrics.health
        Found argocd.appset_controller.openmetrics.health

Similar submitted:
Score   Most similar
0.97    ServiceCheckStub(check_id=&#39;argocd:fe8f69051fb4528&#39;, name=&#39;argocd.appset_controller.openmetrics.health&#39;, status=0, tags=[&#39;endpoint:http://10.1.0.221:45719/metrics&#39;], hostname=&#39;runnervm76tkm&#39;, message=&#39;&#39;)
...
test_e2e from test_e2e.py   View in Datadog
[s6-init] making user provided files available at /var/run/s6/etc...exited 0.
[s6-init] ensuring user provided files have correct perms...exited 0.
[fix-attrs.d] applying ownership &amp; permissions fixes...
[fix-attrs.d] done.
[cont-init.d] executing container initialization scripts...
[cont-init.d] 01-check-apikey.sh: executing... 
[cont-init.d] 01-check-apikey.sh: exited 0.
[cont-init.d] 50-ci.sh: executing... 
[cont-init.d] 50-ci.sh: exited 0.
[cont-init.d] 50-ecs-managed.sh: executing... 
...

View all failed tests

ℹ️ Info

No other issues found (see more)

❄️ No new flaky tests detected

🎯 Code Coverage (details)
Patch Coverage: 100.00%
Overall Coverage: 88.40% (+0.09%)

Useful? React with 👍 / 👎

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 4e49c1c | Docs | Datadog PR Page | Give us feedback!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

base_package qa/skip-qa Automatically skip this PR for the next QA

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant