Skip to content

Commit 3d513a5

Browse files
committed
rename configuration value to allowed_service_tags
1 parent 6e14fd5 commit 3d513a5

6 files changed

Lines changed: 10 additions & 10 deletions

File tree

consul/assets/configuration/spec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ files:
109109
- <SERVICE_1>
110110
- <SERVICE_2>
111111

112-
- name: services_tags_keys_include
112+
- name: allowed_service_tags
113113
description: |
114114
If set, only tags with keys matching this list will be sent to Datadog.
115115
This is helpful if you have a lot of tags on services that are not

consul/changelog.d/20306.added

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Add a new feature to filter Consul service tags being sent to Datadog using an allow list. It can be configured using the `services_tags_keys_include` option.
1+
Add a new feature to filter Consul service tags being sent to Datadog using an allow list. It can be configured using the `allowed_service_tags` option.

consul/datadog_checks/consul/config_models/instance.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ class InstanceConfig(BaseModel):
5656
)
5757
acl_token: Optional[str] = None
5858
allow_redirects: Optional[bool] = None
59+
allowed_service_tags: Optional[tuple[str, ...]] = None
5960
auth_token: Optional[AuthToken] = None
6061
auth_type: Optional[str] = None
6162
aws_host: Optional[str] = None
@@ -91,7 +92,6 @@ class InstanceConfig(BaseModel):
9192
service: Optional[str] = None
9293
services_exclude: Optional[tuple[str, ...]] = None
9394
services_include: Optional[tuple[str, ...]] = None
94-
services_tags_keys_include: Optional[tuple[str, ...]] = None
9595
single_node_install: Optional[bool] = None
9696
skip_proxy: Optional[bool] = None
9797
tags: Optional[tuple[str, ...]] = None

consul/datadog_checks/consul/consul.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,8 @@ def __init__(self, name, init_config, instances):
106106
'service_whitelist', self.instance.get('services_include', default_services_include)
107107
)
108108
self.services_exclude = set(self.instance.get('services_exclude', self.init_config.get('services_exclude', [])))
109-
self.services_tags_keys_include = set(
110-
self.instance.get("services_tags_keys_include", self.init_config.get("services_tags_keys_include", []))
109+
self.allowed_service_tags = set(
110+
self.instance.get("allowed_service_tags", self.init_config.get("allowed_service_tags", []))
111111
)
112112
self.max_services = self.instance.get('max_services', self.init_config.get('max_services', MAX_SERVICES))
113113
self.threads_count = self.instance.get('threads_count', self.init_config.get('threads_count', THREADS_COUNT))
@@ -316,13 +316,13 @@ def _cull_services_list(self, services):
316316
return services
317317

318318
def _cull_services_tags_list(self, services):
319-
if self.services_tags_keys_include:
319+
if self.allowed_service_tags:
320320
# services is a dict of {service_name: [tags]} where tags is a list
321321
# of string having the form of "tagkey=tagvalue"
322322
for service in services:
323323
tags = services[service]
324324
# get the tagkey (the part before the "=") and check it against the include list
325-
tags = [t for t in tags if t.split("=")[0].lower() in self.services_tags_keys_include]
325+
tags = [t for t in tags if t.split("=")[0].lower() in self.allowed_service_tags]
326326
services[service] = tags
327327

328328
return services

consul/datadog_checks/consul/data/conf.yaml.example

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,13 +126,13 @@ instances:
126126
# - <SERVICE_1>
127127
# - <SERVICE_2>
128128

129-
## @param services_tags_keys_include - list of strings - optional
129+
## @param allowed_service_tags - list of strings - optional
130130
## If set, only tags with keys matching this list will be sent to Datadog.
131131
## This is helpful if you have a lot of tags on services that are not
132132
## relevant to Datadog (ingress routing tags, etc). Tags should be specified
133133
## here in lowercase. Otherwise, the check will downcase tags from Consul before comparing.
134134
#
135-
# services_tags_keys_include:
135+
# allowed_service_tags:
136136
# - <TAG_1>
137137
# - <TAG_2>
138138

consul/tests/test_unit.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ def test_cull_services_tags_keys(aggregator):
8181
"unwanted.tag.noequals",
8282
}
8383

84-
consul_check.services_tags_keys_include = include_tags
84+
consul_check.allowed_service_tags = include_tags
8585
services = consul_mocks.mock_get_n_custom_tagged_services_in_cluster(6, all_tags)
8686

8787
services = consul_check._cull_services_tags_list(services)

0 commit comments

Comments
 (0)