Skip to content

Commit

Permalink
[network] normalize instance_name tags
Browse files Browse the repository at this point in the history
Instance name used to be a part of the check name and hence normalized
on the agent before being sent to Datadog.
As part of changes #1642 which introduced support for custom tags,
'instance_name' is now sent as a proper tag. Normalize it, to avoid mismatch and
backward incompatiblity.

Fix #1796.
  • Loading branch information
yannmh committed Aug 3, 2015
1 parent eadcf33 commit 63ef7d3
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 4 deletions.
3 changes: 1 addition & 2 deletions checks.d/http_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ def _check(self, instance):
start = time.time()

service_checks = []

try:
self.log.debug("Connecting to %s" % addr)
if disable_ssl_validation and urlparse(addr)[0] == "https":
Expand Down Expand Up @@ -240,7 +239,7 @@ def _create_status_event(self, sc_name, status, msg, instance):
}

def report_as_service_check(self, sc_name, status, instance, msg=None):
instance_name = instance['name']
instance_name = self.normalize(instance['name'])
url = instance.get('url', None)
sc_tags = ['url:{0}'.format(url), "instance:{0}".format(instance_name)]
custom_tags = instance.get('tags', [])
Expand Down
2 changes: 1 addition & 1 deletion checks.d/tcp_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def _create_status_event(self, sc_name, status, msg, instance):
}

def report_as_service_check(self, sc_name, status, instance, msg=None):
instance_name = instance['name']
instance_name = self.normalize(instance['name'])
host = instance.get('host', None)
port = instance.get('port', None)
custom_tags = instance.get('tags', [])
Expand Down
2 changes: 1 addition & 1 deletion checks/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -744,7 +744,7 @@ def from_yaml(cls, path_to_yaml=None, agentConfig=None, yaml_text=None, check_na
check = cls(check_name, config.get('init_config') or {}, agentConfig or {})
return check, config.get('instances', [])

def normalize(self, metric, prefix=None, fix_case = False):
def normalize(self, metric, prefix=None, fix_case=False):
"""
Turn a metric into a well-formed metric name
prefix.b.c
Expand Down

0 comments on commit 63ef7d3

Please sign in to comment.