summaryrefslogtreecommitdiffstats
path: root/ansible_collections/community/general/plugins/callback/loganalytics.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-26 04:05:56 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-26 04:05:56 +0000
commit67c6a4d1dccb62159b9d9b2dea4e2f487446e276 (patch)
tree9ccbb35137f480bbbdb899accbda52a8135d3416 /ansible_collections/community/general/plugins/callback/loganalytics.py
parentAdding upstream version 9.4.0+dfsg. (diff)
downloadansible-67c6a4d1dccb62159b9d9b2dea4e2f487446e276.tar.xz
ansible-67c6a4d1dccb62159b9d9b2dea4e2f487446e276.zip
Adding upstream version 9.5.1+dfsg.upstream/9.5.1+dfsg
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'ansible_collections/community/general/plugins/callback/loganalytics.py')
-rw-r--r--ansible_collections/community/general/plugins/callback/loganalytics.py13
1 files changed, 8 insertions, 5 deletions
diff --git a/ansible_collections/community/general/plugins/callback/loganalytics.py b/ansible_collections/community/general/plugins/callback/loganalytics.py
index fbcdc6f89..ed7e47b2e 100644
--- a/ansible_collections/community/general/plugins/callback/loganalytics.py
+++ b/ansible_collections/community/general/plugins/callback/loganalytics.py
@@ -59,13 +59,16 @@ import uuid
import socket
import getpass
-from datetime import datetime
from os.path import basename
from ansible.module_utils.urls import open_url
from ansible.parsing.ajson import AnsibleJSONEncoder
from ansible.plugins.callback import CallbackBase
+from ansible_collections.community.general.plugins.module_utils.datetime import (
+ now,
+)
+
class AzureLogAnalyticsSource(object):
def __init__(self):
@@ -93,7 +96,7 @@ class AzureLogAnalyticsSource(object):
return "https://{0}.ods.opinsights.azure.com/api/logs?api-version=2016-04-01".format(workspace_id)
def __rfc1123date(self):
- return datetime.utcnow().strftime('%a, %d %b %Y %H:%M:%S GMT')
+ return now().strftime('%a, %d %b %Y %H:%M:%S GMT')
def send_event(self, workspace_id, shared_key, state, result, runtime):
if result._task_fields['args'].get('_ansible_check_mode') is True:
@@ -167,7 +170,7 @@ class CallbackModule(CallbackBase):
def _seconds_since_start(self, result):
return (
- datetime.utcnow() -
+ now() -
self.start_datetimes[result._task._uuid]
).total_seconds()
@@ -185,10 +188,10 @@ class CallbackModule(CallbackBase):
self.loganalytics.ansible_playbook = basename(playbook._file_name)
def v2_playbook_on_task_start(self, task, is_conditional):
- self.start_datetimes[task._uuid] = datetime.utcnow()
+ self.start_datetimes[task._uuid] = now()
def v2_playbook_on_handler_task_start(self, task):
- self.start_datetimes[task._uuid] = datetime.utcnow()
+ self.start_datetimes[task._uuid] = now()
def v2_runner_on_ok(self, result, **kwargs):
self.loganalytics.send_event(