Skip to content

Commit

Permalink
Revert "Seek DATADOG_ID in kubernetes annotations"
Browse files Browse the repository at this point in the history
This reverts commit fa30d9f.
  • Loading branch information
hkaj authored and gmmeyer committed Jun 23, 2016
1 parent d72fcd4 commit eafec6b
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions utils/service_discovery/sd_docker_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from utils.service_discovery.abstract_sd_backend import AbstractSDBackend
from utils.service_discovery.config_stores import get_config_store, TRACE_CONFIG

DATADOG_ID = 'com.datadoghq.sd.check.id'
log = logging.getLogger(__name__)


Expand Down Expand Up @@ -144,7 +145,9 @@ def get_configs(self):

for image, cid, labels in containers:
try:
check_configs = self._get_check_configs(cid, image, trace_config=trace_config) or []
# value of the DATADOG_ID tag or the image name if the label is missing
identifier = self.get_config_id(image, labels)
check_configs = self._get_check_configs(cid, identifier, trace_config=trace_config) or []
for conf in check_configs:
if trace_config and conf is not None:
source, conf = conf
Expand Down Expand Up @@ -172,7 +175,11 @@ def get_configs(self):
' discovery failed, leaving it alone.' % (cid[:12], image))
return configs

def _get_check_configs(self, c_id, image, trace_config=False):
def get_config_id(self, image, labels):
"""Look for a DATADOG_ID label, return its value or the image name if missing"""
return labels.get(DATADOG_ID) or image

def _get_check_configs(self, c_id, identifier, trace_config=False):
"""Retrieve configuration templates and fill them with data pulled from docker and tags."""
inspect = self.docker_client.inspect_container(c_id)
config_templates = self._get_config_templates(image, trace_config=trace_config)
Expand Down

0 comments on commit eafec6b

Please sign in to comment.