Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
configuration
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
configuration
Commits
79741dbd
Commit
79741dbd
authored
8 years ago
by
Calen Pennington
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Capture playbook timing in a single Timestamp object
parent
28a8b677
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
10 deletions
+9
-10
playbooks/callback_plugins/task_timing.py
+9
-10
No files found.
playbooks/callback_plugins/task_timing.py
View file @
79741dbd
...
...
@@ -45,8 +45,7 @@ class CallbackModule(object):
self
.
stats
=
{}
self
.
current_task
=
None
self
.
playbook_name
=
None
self
.
playbook_start
=
None
self
.
playbook_end
=
None
self
.
playbook_timestamp
=
None
self
.
datadog_api_key
=
os
.
getenv
(
'DATADOG_API_KEY'
)
self
.
datadog_api_initialized
=
False
...
...
@@ -64,7 +63,7 @@ class CallbackModule(object):
self
.
playbook_name
,
_
=
splitext
(
basename
(
self
.
play
.
playbook
.
filename
)
)
self
.
playbook_
start
=
datetime
.
utcnow
()
self
.
playbook_
timestamp
=
Timestamp
()
def
playbook_on_task_start
(
self
,
name
,
is_conditional
):
"""
...
...
@@ -128,7 +127,7 @@ class CallbackModule(object):
def
_json_log_tasks
(
self
,
playbook_name
,
results
):
if
ANSIBLE_TIMER_LOG
is
not
None
:
log_path
=
self
.
playbook_start
.
strftime
(
ANSIBLE_TIMER_LOG
)
log_path
=
self
.
playbook_
timestamp
.
start
.
strftime
(
ANSIBLE_TIMER_LOG
)
if
not
exists
(
dirname
(
log_path
)):
os
.
makedirs
(
dirname
(
log_path
))
...
...
@@ -156,7 +155,7 @@ class CallbackModule(object):
# across all of Open edX tooling, so it deliberately eschews standard
# python logging infrastructure.
if
ANSIBLE_TIMER_LOG
is
not
None
:
log_path
=
self
.
playbook_start
.
strftime
(
ANSIBLE_TIMER_LOG
)
log_path
=
self
.
playbook_
timestamp
.
start
.
strftime
(
ANSIBLE_TIMER_LOG
)
if
not
exists
(
dirname
(
log_path
)):
os
.
makedirs
(
dirname
(
log_path
))
...
...
@@ -164,8 +163,8 @@ class CallbackModule(object):
with
open
(
log_path
,
'a'
)
as
outfile
:
log_message
=
{
'playbook'
:
self
.
playbook_name
,
'started_at'
:
self
.
playbook_start
.
isoformat
(),
'ended_at'
:
self
.
playbook_end
.
isoformat
(),
'started_at'
:
self
.
playbook_
timestamp
.
start
.
isoformat
(),
'ended_at'
:
self
.
playbook_
timestamp
.
end
.
isoformat
(),
'duration'
:
duration
,
}
...
...
@@ -187,7 +186,7 @@ class CallbackModule(object):
if
self
.
current_task
is
not
None
:
self
.
stats
[
self
.
current_task
]
.
stop
()
self
.
playbook_
end
=
datetime
.
utcnow
()
self
.
playbook_
timestamp
.
stop
()
# Sort the tasks by their running time
results
=
sorted
(
...
...
@@ -198,8 +197,8 @@ class CallbackModule(object):
# log the stats
total_seconds
=
(
self
.
playbook_end
-
self
.
playbook_start
)
.
total_seconds
()
total_seconds
=
self
.
playbook_timestamp
.
duration
.
total_seconds
()
i
self
.
_json_log_tasks
(
self
.
playbook_name
,
results
)
self
.
_json_log_play
(
self
.
playbook_name
,
total_seconds
)
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment