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
OpenEdx
configuration
Commits
850b696e
Commit
850b696e
authored
Jul 25, 2016
by
Calen Pennington
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Only sort stats in the Formatter that needs them sorted
parent
c76d71c0
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
12 deletions
+12
-12
playbooks/callback_plugins/task_timing.py
+12
-12
No files found.
playbooks/callback_plugins/task_timing.py
View file @
850b696e
...
...
@@ -57,7 +57,7 @@ class DatadogFormatter(Formatter):
def
log_play
(
self
,
playbook_name
,
playbook_timestamp
,
results
):
if
self
.
datadog_api_initialized
:
datadog_tasks_metrics
=
[]
for
name
,
timestamp
in
results
:
for
name
,
timestamp
in
results
.
items
()
:
datadog_tasks_metrics
.
append
({
'metric'
:
'edx.ansible.task_duration'
,
'date_happened'
:
timestamp
.
start
,
...
...
@@ -86,12 +86,11 @@ class JsonFormatter(Formatter):
# python logging infrastructure.
if
ANSIBLE_TIMER_LOG
is
not
None
:
log_path
=
playbook_timestamp
.
start
.
strftime
(
ANSIBLE_TIMER_LOG
)
if
not
exists
(
dirname
(
log_path
)):
os
.
makedirs
(
dirname
(
log_path
))
with
open
(
log_path
,
'a'
)
as
outfile
:
for
name
,
timestamp
in
results
:
for
name
,
timestamp
in
results
.
items
()
:
log_message
=
{
'task'
:
name
,
'playbook'
:
playbook_name
,
...
...
@@ -126,7 +125,15 @@ class JsonFormatter(Formatter):
class
LoggingFormatter
(
Formatter
):
def
log_play
(
self
,
playbook_name
,
playbook_timestamp
,
results
):
for
name
,
timestamp
in
results
[:
10
]:
# Sort the tasks by their running time
sorted_results
=
sorted
(
results
.
items
(),
key
=
lambda
(
task
,
timestamp
):
timestamp
.
duration
,
reverse
=
True
)
for
name
,
timestamp
in
sorted_results
[:
10
]:
logger
.
info
(
"{0:-<80}{1:->8}"
.
format
(
'{0} '
.
format
(
name
),
...
...
@@ -193,16 +200,9 @@ class CallbackModule(object):
self
.
playbook_timestamp
.
stop
()
# Sort the tasks by their running time
results
=
sorted
(
self
.
stats
.
items
(),
key
=
lambda
(
task
,
timestamp
):
timestamp
.
duration
,
reverse
=
True
)
for
formatter
in
self
.
formatters
:
formatter
.
log_play
(
self
.
playbook_name
,
self
.
playbook_timestamp
,
resul
ts
,
self
.
sta
ts
,
)
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