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
1d53f992
Commit
1d53f992
authored
8 years ago
by
Calen Pennington
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fail-fast when logging without datadog api initialization
parent
d021ea9a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
22 deletions
+24
-22
playbooks/callback_plugins/task_timing.py
+24
-22
No files found.
playbooks/callback_plugins/task_timing.py
View file @
1d53f992
...
...
@@ -57,28 +57,30 @@ class DatadogFormatter(Formatter):
return
value
.
replace
(
" | "
,
"."
)
.
replace
(
" "
,
"-"
)
.
lower
()
def
log_play
(
self
,
playbook_name
,
playbook_timestamp
,
results
):
if
self
.
datadog_api_initialized
:
datadog_tasks_metrics
=
[]
for
name
,
timestamp
in
results
.
items
():
datadog_tasks_metrics
.
append
({
'metric'
:
'edx.ansible.task_duration'
,
'date_happened'
:
timestamp
.
start
,
'points'
:
timestamp
.
duration
.
total_seconds
(),
'tags'
:
[
'task:{0}'
.
format
(
self
.
clean_tag_value
(
name
)),
'playbook:{0}'
.
format
(
self
.
clean_tag_value
(
playbook_name
))
]
})
try
:
datadog
.
api
.
Metric
.
send
(
datadog_tasks_metrics
)
datadog
.
api
.
Metric
.
send
(
metric
=
"edx.ansible.playbook_duration"
,
date_happened
=
time
.
time
(),
points
=
playbook_timestamp
.
duration
.
total_seconds
(),
tags
=
[
"playbook:{0}"
.
format
(
self
.
clean_tag_value
(
playbook_name
))]
)
except
Exception
as
ex
:
LOGGER
.
error
(
ex
.
message
)
if
not
self
.
datadog_api_initialized
:
return
datadog_tasks_metrics
=
[]
for
name
,
timestamp
in
results
.
items
():
datadog_tasks_metrics
.
append
({
'metric'
:
'edx.ansible.task_duration'
,
'date_happened'
:
timestamp
.
start
,
'points'
:
timestamp
.
duration
.
total_seconds
(),
'tags'
:
[
'task:{0}'
.
format
(
self
.
clean_tag_value
(
name
)),
'playbook:{0}'
.
format
(
self
.
clean_tag_value
(
playbook_name
))
]
})
try
:
datadog
.
api
.
Metric
.
send
(
datadog_tasks_metrics
)
datadog
.
api
.
Metric
.
send
(
metric
=
"edx.ansible.playbook_duration"
,
date_happened
=
time
.
time
(),
points
=
playbook_timestamp
.
duration
.
total_seconds
(),
tags
=
[
"playbook:{0}"
.
format
(
self
.
clean_tag_value
(
playbook_name
))]
)
except
Exception
as
ex
:
LOGGER
.
error
(
ex
.
message
)
class
JsonFormatter
(
Formatter
):
...
...
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