-
Notifications
You must be signed in to change notification settings - Fork 813
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
provide better feedback on config errors
- Loading branch information
Carlo Cabanilla
committed
Mar 7, 2014
1 parent
e217163
commit a226bf5
Showing
2 changed files
with
55 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -534,6 +534,18 @@ def normalize(self, metric, prefix=None): | |
else: | ||
return name | ||
|
||
@staticmethod | ||
def read_config(instance, key, message=None, cast=None): | ||
try: | ||
val = instance[key] | ||
except KeyError: | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
clofresh
Contributor
|
||
message = message or 'Must provide `%s` value in instance config' % key | ||
raise Exception(message) | ||
|
||
if cast is None: | ||
return val | ||
else: | ||
return cast(val) | ||
|
||
def agent_formatter(metric, value, timestamp, tags, hostname, device_name=None, | ||
metric_type=None, interval=None): | ||
|
This won't catch the case where the key is present but without any value:
http://yaml-online-parser.appspot.com/?yaml=init_config%3A%0A%0Ainstances%3A%0A+++-+key%3A%0A&type=python