Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

integrations/librato: Use global time.

Niloth P1573e74550a3
diff --git a/static/images/integrations/librato/001.png b/static/images/integrations/librato/001.png
index 4ff5e73f88c..930b91ffcb8 100644
Binary files a/static/images/integrations/librato/001.png and b/static/images/integrations/librato/001.png differ
diff --git a/zerver/webhooks/librato/tests.py b/zerver/webhooks/librato/tests.py
index af4ba26aba1..f30008fcc04 100644
--- a/zerver/webhooks/librato/tests.py
+++ b/zerver/webhooks/librato/tests.py
@@ -21,7 +21,7 @@ class LibratoHookTests(WebhookTestCase):
def test_alert_message_with_default_topic(self) -> None:
expected_topic_name = "Alert alert.name"
- expected_message = "Alert [alert_name](https://metrics.librato.com/alerts#/6294535) has triggered! [Reaction steps](http://www.google.pl):\n * Metric `librato.cpu.percent.idle`, sum was below 44 by 300s, recorded at 2016-03-31 09:11:42 UTC.\n * Metric `librato.swap.swap.cached`, average was absent by 300s, recorded at 2016-03-31 09:11:42 UTC.\n * Metric `librato.swap.swap.cached`, derivative was above 9 by 300s, recorded at 2016-03-31 09:11:42 UTC."
+ expected_message = "Alert [alert_name](https://metrics.librato.com/alerts#/6294535) has triggered! [Reaction steps](http://www.google.pl):\n * Metric `librato.cpu.percent.idle`, sum was below 44 by 300s, recorded at <time:2016-03-31 09:11:42 UTC>.\n * Metric `librato.swap.swap.cached`, average was absent by 300s, recorded at <time:2016-03-31 09:11:42 UTC>.\n * Metric `librato.swap.swap.cached`, derivative was above 9 by 300s, recorded at <time:2016-03-31 09:11:42 UTC>."
self.check_webhook(
"alert",
expected_topic_name,
@@ -32,7 +32,7 @@ class LibratoHookTests(WebhookTestCase):
def test_alert_message_with_custom_topic(self) -> None:
custom_topic_name = "custom_name"
self.url = self.build_webhook_url(topic=custom_topic_name)
- expected_message = "Alert [alert_name](https://metrics.librato.com/alerts#/6294535) has triggered! [Reaction steps](http://www.google.pl):\n * Metric `librato.cpu.percent.idle`, sum was below 44 by 300s, recorded at 2016-03-31 09:11:42 UTC.\n * Metric `librato.swap.swap.cached`, average was absent by 300s, recorded at 2016-03-31 09:11:42 UTC.\n * Metric `librato.swap.swap.cached`, derivative was above 9 by 300s, recorded at 2016-03-31 09:11:42 UTC."
+ expected_message = "Alert [alert_name](https://metrics.librato.com/alerts#/6294535) has triggered! [Reaction steps](http://www.google.pl):\n * Metric `librato.cpu.percent.idle`, sum was below 44 by 300s, recorded at <time:2016-03-31 09:11:42 UTC>.\n * Metric `librato.swap.swap.cached`, average was absent by 300s, recorded at <time:2016-03-31 09:11:42 UTC>.\n * Metric `librato.swap.swap.cached`, derivative was above 9 by 300s, recorded at <time:2016-03-31 09:11:42 UTC>."
self.check_webhook(
"alert",
custom_topic_name,
@@ -41,7 +41,7 @@ class LibratoHookTests(WebhookTestCase):
)
def test_three_conditions_alert_message(self) -> None:
- expected_message = "Alert [alert_name](https://metrics.librato.com/alerts#/6294535) has triggered! [Reaction steps](http://www.use.water.pl):\n * Metric `collectd.interface.eth0.if_octets.tx`, absolute_value was above 4 by 300s, recorded at 2016-04-11 20:40:14 UTC.\n * Metric `collectd.load.load.longterm`, max was above 99, recorded at 2016-04-11 20:40:14 UTC.\n * Metric `librato.swap.swap.cached`, average was absent by 60s, recorded at 2016-04-11 20:40:14 UTC."
+ expected_message = "Alert [alert_name](https://metrics.librato.com/alerts#/6294535) has triggered! [Reaction steps](http://www.use.water.pl):\n * Metric `collectd.interface.eth0.if_octets.tx`, absolute_value was above 4 by 300s, recorded at <time:2016-04-11 20:40:14 UTC>.\n * Metric `collectd.load.load.longterm`, max was above 99, recorded at <time:2016-04-11 20:40:14 UTC>.\n * Metric `librato.swap.swap.cached`, average was absent by 60s, recorded at <time:2016-04-11 20:40:14 UTC>."
expected_topic_name = "Alert TooHighTemperature"
self.check_webhook(
"three_conditions_alert",
@@ -52,7 +52,7 @@ class LibratoHookTests(WebhookTestCase):
def test_alert_clear(self) -> None:
expected_topic_name = "Alert Alert_name"
- expected_message = "Alert [alert_name](https://metrics.librato.com/alerts#/6309313) has cleared at 2016-04-12 13:11:44 UTC!"
+ expected_message = "Alert [alert_name](https://metrics.librato.com/alerts#/6309313) has cleared at <time:2016-04-12 13:11:44 UTC>!"
self.check_webhook(
"alert_cleared",
expected_topic_name,
diff --git a/zerver/webhooks/librato/view.py b/zerver/webhooks/librato/view.py
index fba1d962af9..5961b73630f 100644
--- a/zerver/webhooks/librato/view.py
+++ b/zerver/webhooks/librato/view.py
@@ -97,7 +97,9 @@ class LibratoWebhookHandler(LibratoWebhookParser):
return topic_template.format(alert_name=alert_name)
def handle_alert_clear_message(self) -> str:
- alert_clear_template = "Alert [alert_name]({alert_url}) has cleared at {trigger_time} UTC!"
+ alert_clear_template = (
+ "Alert [alert_name]({alert_url}) has cleared at <time:{trigger_time} UTC>!"
+ )
trigger_time = datetime.fromtimestamp(
self.payload["trigger_time"], tz=timezone.utc
).strftime("%Y-%m-%d %H:%M:%S")
@@ -155,7 +157,7 @@ class LibratoWebhookHandler(LibratoWebhookParser):
)
if duration:
content += f" by {duration}s"
- content += f", recorded at {recorded_at} UTC."
+ content += f", recorded at <time:{recorded_at} UTC>."
return content