Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[core] cast service_checks message to string #1617

Merged
merged 1 commit into from
May 13, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions checks/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ def count(self, metric, value=0, tags=None, hostname=None, device_name=None):
self.aggregator.submit_count(metric, value, tags, hostname, device_name)

def monotonic_count(self, metric, value=0, tags=None,
hostname=None, device_name=None):
hostname=None, device_name=None):
"""
Submits a raw count with optional tags, hostname and device name
based on increasing counter values. E.g. 1, 3, 5, 7 will submit
Expand Down Expand Up @@ -454,8 +454,12 @@ def service_check(self, check_name, status, tags=None, timestamp=None,
"""
if hostname is None:
hostname = self.hostname
self.service_checks.append(create_service_check(check_name, status,
tags, timestamp, hostname, check_run_id, message))
if message is not None:
message = str(message)
self.service_checks.append(
create_service_check(check_name, status, tags, timestamp,
hostname, check_run_id, message)
)

def has_events(self):
"""
Expand Down Expand Up @@ -635,7 +639,6 @@ def normalize(self, metric, prefix=None, fix_case = False):
METRIC_REPLACEMENT = re.compile(r'([^a-zA-Z0-9_.]+)|(^[^a-zA-Z]+)')
DOT_UNDERSCORE_CLEANUP = re.compile(r'_*\._*')


def convert_to_underscore_separated(self, name):
"""
Convert from CamelCase to camel_case
Expand All @@ -658,6 +661,7 @@ def read_config(instance, key, message=None, cast=None):
else:
return cast(val)


def agent_formatter(metric, value, timestamp, tags, hostname, device_name=None,
metric_type=None, interval=None):
""" Formats metrics coming from the MetricsAggregator. Will look like:
Expand All @@ -683,7 +687,7 @@ def agent_formatter(metric, value, timestamp, tags, hostname, device_name=None,


def create_service_check(check_name, status, tags=None, timestamp=None,
hostname=None, check_run_id=None, message=None):
hostname=None, check_run_id=None, message=None):
""" Create a service_check dict. See AgentCheck.service_check() for
docs on the parameters.
"""
Expand Down