Skip to content

Commit

Permalink
Move GENIRC_TAG defintion to checks_base to be used by the query mana…
Browse files Browse the repository at this point in the history
…ger (#9817)

* Move GENIRC_TAG defintion to checks_base to be used by the query manager

Co-authored-by: Paul <paul.coignet@datadoghq.com>
  • Loading branch information
hithwen and coignetp committed Aug 3, 2021
1 parent d96a2de commit 7153302
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 15 deletions.
21 changes: 6 additions & 15 deletions datadog_checks_base/datadog_checks/base/stubs/aggregator.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,24 +39,15 @@ def backend_normalize_metric_name(metric_name):


def check_tag_names(metric, tags):
forbidden_tags = [
'cluster_name',
'clustername',
'cluster',
'clusterid',
'cluster_id',
'env',
'host_name',
'hostname',
'host',
'service',
'version',
]

if not os.environ.get('DDEV_SKIP_GENERIC_TAGS_CHECK'):
try:
from datadog_checks.base.utils.tagging import GENERIC_TAGS
except ImportError:
GENERIC_TAGS = []

for tag in tags:
tag_name = tag.split(':')[0]
if tag_name in forbidden_tags:
if tag_name in GENERIC_TAGS:
raise Exception(
"Metric {} was submitted with a forbidden tag: {}. Please rename this tag, or skip "
"the tag validation with DDEV_SKIP_GENERIC_TAGS_CHECK environment variable.".format(
Expand Down
15 changes: 15 additions & 0 deletions datadog_checks_base/datadog_checks/base/utils/tagging.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,18 @@
import tagger
except ImportError:
from ..stubs import tagger # noqa: F401


GENERIC_TAGS = {
'cluster_name',
'clustername',
'cluster',
'clusterid',
'cluster_id',
'env',
'host_name',
'hostname',
'host',
'service',
'version',
}

0 comments on commit 7153302

Please sign in to comment.