From 043e3edd52dc46f7c03ed547a71012c3cf30b09c Mon Sep 17 00:00:00 2001 From: David Bouchare Date: Mon, 30 Dec 2019 15:05:22 +0100 Subject: [PATCH 1/6] Add metric for event duration --- datadog/dogshell/wrap.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/datadog/dogshell/wrap.py b/datadog/dogshell/wrap.py index 1ddd21e5d..1a61dc5c4 100644 --- a/datadog/dogshell/wrap.py +++ b/datadog/dogshell/wrap.py @@ -288,6 +288,8 @@ def parse_options(raw_args=None): parser.add_option('-b', '--buffer_outs', action='store_true', dest='buffer_outs', default=False, help="displays the stderr and stdout of the command only once it has \ returned (the command outputs remains buffered in dogwrap meanwhile)") + parser.add_option('--send_metrics', action='store_true', dest='send_metrics', default=False, + help="sends a metric for event duration") parser.add_option('--tags', action='store', type='string', dest='tags', default='', help="comma separated list of tags") @@ -387,6 +389,8 @@ def main(): print(stdout.strip(), file=sys.stdout) if options.submit_mode == 'all' or returncode != 0: + if options.send_metrics: + api.Metric.send(metric='dogwrap.event.duration', points=duration, type="gauge") api.Event.create(title=event_title, text=event_body, **event) sys.exit(returncode) From f983c4fbd6a44fe202ae828bb4deb17636f2a70f Mon Sep 17 00:00:00 2001 From: David Bouchare Date: Mon, 30 Dec 2019 15:09:05 +0100 Subject: [PATCH 2/6] Singular --- datadog/dogshell/wrap.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/datadog/dogshell/wrap.py b/datadog/dogshell/wrap.py index 1a61dc5c4..b40419598 100644 --- a/datadog/dogshell/wrap.py +++ b/datadog/dogshell/wrap.py @@ -288,7 +288,7 @@ def parse_options(raw_args=None): parser.add_option('-b', '--buffer_outs', action='store_true', dest='buffer_outs', default=False, help="displays the stderr and stdout of the command only once it has \ returned (the command outputs remains buffered in dogwrap meanwhile)") - parser.add_option('--send_metrics', action='store_true', dest='send_metrics', default=False, + parser.add_option('--send_metric', action='store_true', dest='send_metric', default=False, help="sends a metric for event duration") parser.add_option('--tags', action='store', type='string', dest='tags', default='', help="comma separated list of tags") @@ -389,7 +389,7 @@ def main(): print(stdout.strip(), file=sys.stdout) if options.submit_mode == 'all' or returncode != 0: - if options.send_metrics: + if options.send_metric: api.Metric.send(metric='dogwrap.event.duration', points=duration, type="gauge") api.Event.create(title=event_title, text=event_body, **event) From d43ab6de832ed7c758fa9aca961ebc2f12b5d345 Mon Sep 17 00:00:00 2001 From: David Bouchare Date: Mon, 30 Dec 2019 15:15:15 +0100 Subject: [PATCH 3/6] Edit metric name --- datadog/dogshell/wrap.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/datadog/dogshell/wrap.py b/datadog/dogshell/wrap.py index b40419598..f9127d53f 100644 --- a/datadog/dogshell/wrap.py +++ b/datadog/dogshell/wrap.py @@ -390,7 +390,7 @@ def main(): if options.submit_mode == 'all' or returncode != 0: if options.send_metric: - api.Metric.send(metric='dogwrap.event.duration', points=duration, type="gauge") + api.Metric.send(metric='dogwrap.duration', points=duration, type="gauge") api.Event.create(title=event_title, text=event_body, **event) sys.exit(returncode) From e04997fbe80fe8c62ec5b56ca8558d71e1a5baf1 Mon Sep 17 00:00:00 2001 From: David Bouchare Date: Fri, 3 Jan 2020 11:33:34 +0100 Subject: [PATCH 4/6] Add tags --- datadog/dogshell/wrap.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/datadog/dogshell/wrap.py b/datadog/dogshell/wrap.py index f9127d53f..0aea2633e 100644 --- a/datadog/dogshell/wrap.py +++ b/datadog/dogshell/wrap.py @@ -390,7 +390,11 @@ def main(): if options.submit_mode == 'all' or returncode != 0: if options.send_metric: - api.Metric.send(metric='dogwrap.duration', points=duration, type="gauge") + if tags: + duration_tags = tags.append(options.name) + else: + duration_tags = [options.name] + api.Metric.send(metric='dogwrap.duration', points=duration, tags=duration_tags, type="gauge") api.Event.create(title=event_title, text=event_body, **event) sys.exit(returncode) From 2e5a4d3e5e34f302ce97602156a4f8f8fe46ae11 Mon Sep 17 00:00:00 2001 From: David Bouchare Date: Fri, 3 Jan 2020 13:47:10 +0100 Subject: [PATCH 5/6] Review feedback: event_name_tag --- datadog/dogshell/wrap.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/datadog/dogshell/wrap.py b/datadog/dogshell/wrap.py index 0aea2633e..8d488c49c 100644 --- a/datadog/dogshell/wrap.py +++ b/datadog/dogshell/wrap.py @@ -390,10 +390,11 @@ def main(): if options.submit_mode == 'all' or returncode != 0: if options.send_metric: + event_name_tag = "event_name{}".format(options.name) if tags: - duration_tags = tags.append(options.name) + duration_tags = tags + [event_name_tag] else: - duration_tags = [options.name] + duration_tags = [event_name_tag] api.Metric.send(metric='dogwrap.duration', points=duration, tags=duration_tags, type="gauge") api.Event.create(title=event_title, text=event_body, **event) From b4610a91fd10334dc891d39d427ea80308f88d14 Mon Sep 17 00:00:00 2001 From: David Bouchare Date: Mon, 6 Jan 2020 13:42:13 +0100 Subject: [PATCH 6/6] Missing colon --- datadog/dogshell/wrap.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/datadog/dogshell/wrap.py b/datadog/dogshell/wrap.py index 8d488c49c..e7c564b91 100644 --- a/datadog/dogshell/wrap.py +++ b/datadog/dogshell/wrap.py @@ -390,7 +390,7 @@ def main(): if options.submit_mode == 'all' or returncode != 0: if options.send_metric: - event_name_tag = "event_name{}".format(options.name) + event_name_tag = "event_name:{}".format(options.name) if tags: duration_tags = tags + [event_name_tag] else: