Skip to content

Commit

Permalink
Extend forbidden generic tag list (DataDog#9580)
Browse files Browse the repository at this point in the history
* Extend forbidden generic tag list

* Remove duplicate setenv

* Test some integrations again

* Remove legacy tag from consul test

* Test rethinkdb

* Skip rethinkdb
  • Loading branch information
coignetp authored Jun 28, 2021
1 parent 197f422 commit 98aba87
Show file tree
Hide file tree
Showing 28 changed files with 62 additions and 38 deletions.
3 changes: 3 additions & 0 deletions amazon_msk/tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,6 @@ passenv =
commands =
pip install -r requirements.in
pytest -v {posargs}
setenv =
; OpenmetricsChecks sends generic tags
DDEV_SKIP_GENERIC_TAGS_CHECK=true
2 changes: 2 additions & 0 deletions azure_iot_edge/tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,5 @@ setenv =
IOT_EDGE_E2E_IOTEDGE_URL = https://github.com/Azure/azure-iotedge/releases/download/1.0.10-rc2/iotedge_1.0.10.rc2-1_ubuntu16.04_amd64.deb
IOT_EDGE_E2E_IMAGE = mcr.microsoft.com/azureiotedge-agent:1.0.10-rc2
tls: IOT_EDGE_E2E_TLS_ENABLED = true
; OpenmetricsChecks sends generic tags
DDEV_SKIP_GENERIC_TAGS_CHECK=true
1 change: 1 addition & 0 deletions cilium/tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,5 @@ commands =
pytest -v {posargs}
setenv =
CILIUM_VERSION = 1.6.90
; OpenmetricsChecks sends generic tags
DDEV_SKIP_GENERIC_TAGS_CHECK=true
3 changes: 3 additions & 0 deletions confluent_platform/tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,6 @@ passenv =
commands =
pip install -r requirements.in
pytest -v {posargs}
setenv =
; JMX check sends generic tags
DDEV_SKIP_GENERIC_TAGS_CHECK=true
6 changes: 1 addition & 5 deletions consul/tests/test_unit.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ def test_consul_request(aggregator, instance, mocker):


def test_service_checks(aggregator):
consul_check = ConsulCheck(common.CHECK_NAME, {}, [consul_mocks.MOCK_CONFIG])
consul_check = ConsulCheck(common.CHECK_NAME, {}, [consul_mocks.MOCK_CONFIG_DISABLE_SERVICE_TAG])
my_mocks = consul_mocks._get_consul_mocks()
my_mocks['consul_request'] = consul_mocks.mock_get_health_check
consul_mocks.mock_check(consul_check, my_mocks)
Expand All @@ -187,7 +187,6 @@ def test_service_checks(aggregator):
"consul_datacenter:dc1",
"check:server-loadbalancer",
"consul_service_id:server-loadbalancer",
"service:server-loadbalancer",
"consul_service:server-loadbalancer",
]
aggregator.assert_service_check('consul.check', status=ConsulCheck.CRITICAL, tags=expected_tags, count=1)
Expand All @@ -196,15 +195,13 @@ def test_service_checks(aggregator):
"consul_datacenter:dc1",
"check:server-api",
"consul_service_id:server-loadbalancer",
"service:server-loadbalancer",
"consul_service:server-loadbalancer",
]
aggregator.assert_service_check('consul.check', status=ConsulCheck.OK, tags=expected_tags, count=1)

expected_tags = [
"consul_datacenter:dc1",
"check:server-api",
"service:server-loadbalancer",
"consul_service:server-loadbalancer",
]
aggregator.assert_service_check('consul.check', status=ConsulCheck.OK, tags=expected_tags, count=1)
Expand All @@ -216,7 +213,6 @@ def test_service_checks(aggregator):
"consul_datacenter:dc1",
"check:server-status-empty",
"consul_service_id:server-empty",
"service:server-empty",
"consul_service:server-empty",
]
aggregator.assert_service_check('consul.check', status=ConsulCheck.UNKNOWN, tags=expected_tags, count=1)
Expand Down
2 changes: 2 additions & 0 deletions coredns/tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ platform = linux|darwin|win32
setenv =
1.2.0: COREDNS_VERSION=1.2.0
1.7.0: COREDNS_VERSION=1.7.0
; OpenmetricsChecks sends generic tags
DDEV_SKIP_GENERIC_TAGS_CHECK=true
passenv =
DOCKER*
COMPOSE*
Expand Down
3 changes: 3 additions & 0 deletions datadog_checks_base/datadog_checks/base/stubs/aggregator.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,12 @@ def check_tag_names(metric, tags):
'cluster_name',
'clustername',
'cluster',
'env',
'host_name',
'hostname',
'host',
'service',
'version',
]

if not os.environ.get('DDEV_SKIP_GENERIC_TAGS_CHECK'):
Expand Down
3 changes: 3 additions & 0 deletions datadog_checks_base/tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ passenv =
commands =
pip install --extra-index-url https://datadoghq.dev/ci-wheels/bin -r requirements.in
pytest -v {posargs} --benchmark-skip
setenv =
; OpenmetricsChecks sending generic tags
DDEV_SKIP_GENERIC_TAGS_CHECK=true

[testenv:bench]
basepython = python3.8
Expand Down
2 changes: 2 additions & 0 deletions etcd/tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,5 @@ setenv =
3.3.8: ETCD_VERSION=v3.3.8
3.3.9: ETCD_VERSION=v3.3.9
3.3.10: V3_PREVIEW=true
; OpenmetricsChecks sends generic tags
3.3.10: DDEV_SKIP_GENERIC_TAGS_CHECK=true
2 changes: 2 additions & 0 deletions gitlab_runner/tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,5 @@ commands =
pytest -v {posargs}
setenv =
GITLAB_RUNNER_VERSION=10.8.0
; OpenmetricsChecks sends generic tags
DDEV_SKIP_GENERIC_TAGS_CHECK=true
2 changes: 1 addition & 1 deletion hdfs_namenode/tests/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
# Namesystem metadata url
NAME_SYSTEM_METADATA_URL = NAMENODE_JMX_URI + '?qry=Hadoop:service=NameNode,name=NameNodeInfo'

CUSTOM_TAGS = ["cluster_name:hdfs_dev", "instance:level_tags"]
CUSTOM_TAGS = ["hdfs_cluster:hdfs_dev", "instance:level_tags"]

# Authentication Parameters
TEST_USERNAME = 'Picard'
Expand Down
1 change: 0 additions & 1 deletion hdfs_namenode/tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ passenv =
DOCKER*
COMPOSE*
setenv =
DDEV_SKIP_GENERIC_TAGS_CHECK=true
2.7.1: HDFS_RAW_VERSION=2.7.1
2.7.1: HDFS_IMAGE_TAG=1.1.0-hadoop2.7.1-java8
commands =
Expand Down
2 changes: 2 additions & 0 deletions kong/tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ deps =
-rrequirements-dev.txt
setenv =
1.5: KONG_VERSION=1.5.0
; OpenmetricsChecks sends generic tags
DDEV_SKIP_GENERIC_TAGS_CHECK=true
commands =
pip install -r requirements.in
pytest -v {posargs}
3 changes: 3 additions & 0 deletions kubernetes_state/tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,6 @@ deps =
commands =
pip install -r requirements.in
pytest -v {posargs}
setenv =
; OpenmetricsChecks sends generic tags
DDEV_SKIP_GENERIC_TAGS_CHECK=true
2 changes: 2 additions & 0 deletions marathon/tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,5 @@ passenv =
commands =
pip install -r requirements.in
pytest -v {posargs}
setenv =
DDEV_SKIP_GENERIC_TAGS_CHECK=true
12 changes: 6 additions & 6 deletions php_fpm/tests/test_e2e.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@


def test_status(dd_agent_check, instance, ping_url_tag):
instance['tags'] = ['cluster:forums']
instance['tags'] = ['fpm_cluster:forums']

aggregator = dd_agent_check(instance, rate=True)

Expand All @@ -23,16 +23,16 @@ def test_status(dd_agent_check, instance, ping_url_tag):
'php_fpm.processes.max_reached',
]

expected_tags = ['cluster:forums', 'pool:www']
expected_tags = ['fpm_cluster:forums', 'pool:www']
for metric in metrics:
aggregator.assert_metric(metric, tags=expected_tags)

expected_tags = [ping_url_tag, 'cluster:forums']
expected_tags = [ping_url_tag, 'fpm_cluster:forums']
aggregator.assert_service_check('php_fpm.can_ping', status=ServiceCheck.OK, tags=expected_tags)


def test_status_fastcgi(dd_agent_check, instance_fastcgi, ping_url_tag_fastcgi):
instance_fastcgi['tags'] = ['cluster:forums']
instance_fastcgi['tags'] = ['fpm_cluster:forums']

aggregator = dd_agent_check(instance_fastcgi, rate=True)

Expand All @@ -46,9 +46,9 @@ def test_status_fastcgi(dd_agent_check, instance_fastcgi, ping_url_tag_fastcgi):
'php_fpm.processes.max_reached',
]

expected_tags = ['cluster:forums', 'pool:www']
expected_tags = ['fpm_cluster:forums', 'pool:www']
for metric in metrics:
aggregator.assert_metric(metric, tags=expected_tags)

expected_tags = [ping_url_tag_fastcgi, 'cluster:forums']
expected_tags = [ping_url_tag_fastcgi, 'fpm_cluster:forums']
aggregator.assert_service_check('php_fpm.can_ping', status=ServiceCheck.OK, tags=expected_tags)
12 changes: 6 additions & 6 deletions php_fpm/tests/test_php_fpm.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def test_bad_ping_reply(check, instance, aggregator, ping_url_tag):


def test_status(check, instance, aggregator, ping_url_tag):
instance['tags'] = ['cluster:forums']
instance['tags'] = ['fpm_cluster:forums']
check.check(instance)

metrics = [
Expand All @@ -32,16 +32,16 @@ def test_status(check, instance, aggregator, ping_url_tag):
'php_fpm.processes.max_reached',
]

expected_tags = ['cluster:forums', 'pool:www']
expected_tags = ['fpm_cluster:forums', 'pool:www']
for metric in metrics:
aggregator.assert_metric(metric, tags=expected_tags)

expected_tags = [ping_url_tag, 'cluster:forums']
expected_tags = [ping_url_tag, 'fpm_cluster:forums']
aggregator.assert_service_check('php_fpm.can_ping', status=check.OK, tags=expected_tags)


def test_status_fastcgi(check, instance_fastcgi, aggregator, ping_url_tag_fastcgi):
instance_fastcgi['tags'] = ['cluster:forums']
instance_fastcgi['tags'] = ['fpm_cluster:forums']
check.check(instance_fastcgi)

metrics = [
Expand All @@ -54,9 +54,9 @@ def test_status_fastcgi(check, instance_fastcgi, aggregator, ping_url_tag_fastcg
'php_fpm.processes.max_reached',
]

expected_tags = ['cluster:forums', 'pool:www']
expected_tags = ['fpm_cluster:forums', 'pool:www']
for metric in metrics:
aggregator.assert_metric(metric, tags=expected_tags)

expected_tags = [ping_url_tag_fastcgi, 'cluster:forums']
expected_tags = [ping_url_tag_fastcgi, 'fpm_cluster:forums']
aggregator.assert_service_check('php_fpm.can_ping', status=check.OK, tags=expected_tags)
2 changes: 0 additions & 2 deletions php_fpm/tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,3 @@ deps =
commands =
pip install -r requirements.in
pytest -v {posargs}
setenv =
DDEV_SKIP_GENERIC_TAGS_CHECK=true
2 changes: 1 addition & 1 deletion process/tests/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def get_config_stubs():
'name': 'test_tags',
# index in the array for our find_pids mock
'search_string': ['test_5'],
'tags': ['onetag', 'env:prod'],
'tags': ['onetag', 'environment:prod'],
},
'mocked_processes': set([2]),
},
Expand Down
2 changes: 1 addition & 1 deletion rethinkdb/tests/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

HOST = get_docker_hostname()

TAGS = ['env:testing']
TAGS = ['rethinkdb_env:testing']

# Servers.
# NOTE: server information is tightly coupled to the Docker Compose setup.
Expand Down
4 changes: 2 additions & 2 deletions rethinkdb/tests/unit/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ def test_config(port_28016, min_collection_interval_10):
'username': 'datadog-agent',
'password': 's3kr3t',
'tls_ca_cert': '/path/to/client.cert',
'tags': ['env:testing'],
'tags': ['rethinkdb_env:testing'],
} # type: Instance

config = Config(instance)
assert config.host == '192.168.121.1'
assert config.port == 28016
assert config.user == 'datadog-agent'
assert config.tls_ca_cert == '/path/to/client.cert'
assert config.tags == ['env:testing']
assert config.tags == ['rethinkdb_env:testing']


@pytest.mark.parametrize('value', [42, True, object()])
Expand Down
2 changes: 2 additions & 0 deletions scylla/tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,5 @@ setenv =
3.1: SCYLLA_VERSION=3.1.2
3.2: SCYLLA_VERSION=3.2.1
3.3: SCYLLA_VERSION=3.3.1
; OpenmetricsChecks sends generic tags
DDEV_SKIP_GENERIC_TAGS_CHECK=true
2 changes: 2 additions & 0 deletions snowflake/tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,5 @@ passenv =
commands =
pip install -r requirements.in
pytest -v {posargs}
setenv =
DDEV_SKIP_GENERIC_TAGS_CHECK=true
2 changes: 1 addition & 1 deletion varnish/tests/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@


def get_config_by_version(name=None):
config = {"varnishstat": get_varnish_stat_path(), "tags": ["cluster:webs"]}
config = {"varnishstat": get_varnish_stat_path(), "tags": ["varnish_cluster:webs"]}

if name:
config["name"] = name
Expand Down
2 changes: 1 addition & 1 deletion varnish/tests/test_e2e.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@
def test_check(dd_agent_check, instance):
aggregator = dd_agent_check(instance, rate=True)
for mname in common.COMMON_METRICS:
aggregator.assert_metric(mname, tags=['cluster:webs', 'varnish_name:default'])
aggregator.assert_metric(mname, tags=['varnish_cluster:webs', 'varnish_name:default'])
10 changes: 5 additions & 5 deletions varnish/tests/test_unit.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def test_command_line_manually_unhealthy(mock_subprocess, mock_version, mock_get
args, _ = mock_subprocess.call_args
assert args[0] == [common.VARNISHADM_PATH, '-S', common.SECRETFILE_PATH, 'debug.health']
aggregator.assert_service_check(
"varnish.backend_healthy", status=check.CRITICAL, tags=['backend:default', 'cluster:webs'], count=1
"varnish.backend_healthy", status=check.CRITICAL, tags=['backend:default', 'varnish_cluster:webs'], count=1
)

mock_version.return_value = LooseVersion('4.1.0'), 'xml'
Expand Down Expand Up @@ -126,7 +126,7 @@ def test_command_line_post_varnish4(mock_subprocess, mock_version, mock_geteuid,
args, _ = mock_subprocess.call_args
assert args[0] == [common.VARNISHADM_PATH, '-S', common.SECRETFILE_PATH, 'debug.health']
aggregator.assert_service_check(
"varnish.backend_healthy", status=check.OK, tags=['backend:backend2', 'cluster:webs'], count=1
"varnish.backend_healthy", status=check.OK, tags=['backend:backend2', 'varnish_cluster:webs'], count=1
)

mock_version.return_value = LooseVersion('4.1.0'), 'xml'
Expand Down Expand Up @@ -171,7 +171,7 @@ def test_command_line_post_varnish5(mock_subprocess, mock_version, mock_geteuid,
'-p',
]
aggregator.assert_service_check(
"varnish.backend_healthy", status=check.OK, tags=['backend:backend2', 'cluster:webs'], count=1
"varnish.backend_healthy", status=check.OK, tags=['backend:backend2', 'varnish_cluster:webs'], count=1
)

mock_version.return_value = LooseVersion('5.0.0'), 'json'
Expand Down Expand Up @@ -216,7 +216,7 @@ def test_command_line_post_varnish6_5(mock_subprocess, mock_version, mock_geteui
'-p',
]
aggregator.assert_service_check(
"varnish.backend_healthy", status=check.OK, tags=['backend:backend2', 'cluster:webs'], count=1
"varnish.backend_healthy", status=check.OK, tags=['backend:backend2', 'varnish_cluster:webs'], count=1
)

mock_version.return_value = LooseVersion('6.5.0'), 'json'
Expand Down Expand Up @@ -253,5 +253,5 @@ def test_command_line(mock_subprocess, mock_version, mock_geteuid, aggregator, c
args, _ = mock_subprocess.call_args
assert args[0] == [common.VARNISHADM_PATH, '-S', common.SECRETFILE_PATH, 'debug.health']
aggregator.assert_service_check(
"varnish.backend_healthy", status=check.OK, tags=['backend:default', 'cluster:webs'], count=1
"varnish.backend_healthy", status=check.OK, tags=['backend:default', 'varnish_cluster:webs'], count=1
)
10 changes: 5 additions & 5 deletions varnish/tests/test_varnish.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def test_check(aggregator, check, instance):
metrics_to_check = common.COMMON_METRICS + common.METRICS_6

for mname in metrics_to_check:
aggregator.assert_metric(mname, count=1, tags=['cluster:webs', 'varnish_name:default'])
aggregator.assert_metric(mname, count=1, tags=['varnish_cluster:webs', 'varnish_name:default'])

aggregator.assert_all_metrics_covered()
metadata_metrics = get_metadata_metrics()
Expand All @@ -33,9 +33,9 @@ def test_inclusion_filter(aggregator, check, instance):
check.check(instance)
for mname in common.COMMON_METRICS:
if 'SMA.' in mname:
aggregator.assert_metric(mname, count=1, tags=['cluster:webs', 'varnish_name:default'])
aggregator.assert_metric(mname, count=1, tags=['varnish_cluster:webs', 'varnish_name:default'])
else:
aggregator.assert_metric(mname, count=0, tags=['cluster:webs', 'varnish_name:default'])
aggregator.assert_metric(mname, count=0, tags=['varnish_cluster:webs', 'varnish_name:default'])


def test_exclusion_filter(aggregator, check, instance):
Expand All @@ -44,9 +44,9 @@ def test_exclusion_filter(aggregator, check, instance):
check.check(instance)
for mname in common.COMMON_METRICS:
if 'SMA.Transient.c_req' in mname:
aggregator.assert_metric(mname, count=0, tags=['cluster:webs', 'varnish_name:default'])
aggregator.assert_metric(mname, count=0, tags=['varnish_cluster:webs', 'varnish_name:default'])
elif 'varnish.uptime' not in mname:
aggregator.assert_metric(mname, count=1, tags=['cluster:webs', 'varnish_name:default'])
aggregator.assert_metric(mname, count=1, tags=['varnish_cluster:webs', 'varnish_name:default'])


def test_version_metadata(aggregator, check, instance, datadog_agent):
Expand Down
1 change: 0 additions & 1 deletion varnish/tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ deps =
-e../datadog_checks_base[deps]
-rrequirements-dev.txt
setenv =
DDEV_SKIP_GENERIC_TAGS_CHECK=true
521: VARNISH_VERSION=5_2_1
651: VARNISH_VERSION=6_5_1
commands =
Expand Down

0 comments on commit 98aba87

Please sign in to comment.