Skip to content

statsd: add container-based config discovery support#24530

Draft
vitkyrka wants to merge 2 commits into
masterfrom
vwhitchurch/statsd-discovery
Draft

statsd: add container-based config discovery support#24530
vitkyrka wants to merge 2 commits into
masterfrom
vwhitchurch/statsd-discovery

Conversation

@vitkyrka

Copy link
Copy Markdown
Contributor

What does this PR do?

Adds container-based config discovery support to statsd.

Docker-compose change: the fixture builds a custom image from statsd/statsd:${STATSD_VERSION} with no image: tag, so Compose named the built image <project>-statsd, which never matched the statsd ad_identifiers value; added an explicit image: statsd/statsd:${STATSD_VERSION} tag so the locally-built image keeps the same name a real deployment would use. Also added a ${DD_LOG_1:-/dev/null} fallback (target is a file, so the fallback is /dev/null) since assert_all_discovery_candidates_stable's docker compose ps subprocess call doesn't inherit docker_run's env_vars=.

Port selection rationale: Port 8126 is StatsD's official documented default management/admin TCP interface port (mgmt_port in config.js), which is exactly the port the check's StatsCheck.check() connects to over a raw TCP socket to issue health/stats/counters/gauges/timers commands.

Endpoint shape: StatsD talks raw TCP, not HTTP, so spec.yaml uses the manual from_ports strategy with separate host/port candidate fields instead of the discovery/openmetrics_from_ports template.

Exact-tag-match test helper: the existing test_e2e's shared assert_metrics_covered() helper asserts an exact host:/port: tag pair that the check derives from its own connection parameters. Under discovery the Agent connects directly to the container's own internal host/port (unknown ahead of time), so test_e2e_discovery asserts metric/service-check presence without those tags instead of reusing assert_metrics_covered() verbatim.

Motivation

https://datadoghq.atlassian.net/browse/DSCVR-610

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

Adds a from_ports discovery strategy targeting the StatsD management
interface (port 8126), plus an auto_conf.yaml with the statsd ad_identifier.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@datadog-prod-us1-5

Copy link
Copy Markdown

Tests  Code Coverage

🎉 All green!

🧪 All tests passed
❄️ No new flaky tests detected

🎯 Code Coverage (details)
Patch Coverage: 50.00%
Overall Coverage: 82.24%

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

@dd-octo-sts

dd-octo-sts Bot commented Jul 13, 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

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.

1 participant