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
d5210167
Commit
d5210167
authored
9 years ago
by
arbabnazar
Committed by
Edward Zarecor
9 years ago
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
move datadog initialization into the init
parent
284bb743
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
11 deletions
+9
-11
playbooks/callback_plugins/datadog_tasks_timing.py
+9
-11
No files found.
playbooks/callback_plugins/datadog_tasks_timing.py
View file @
d5210167
...
...
@@ -24,6 +24,14 @@ class CallbackModule(object):
def
__init__
(
self
):
self
.
stats
=
{}
self
.
current_task
=
None
self
.
datadog_api_key
=
os
.
getenv
(
'DATADOG_API_KEY'
)
self
.
datadog_app_key
=
os
.
getenv
(
'DATADOG_APP_KEY'
)
self
.
datadog_api_initialized
=
False
if
self
.
datadog_api_key
and
self
.
datadog_app_key
:
datadog
.
initialize
(
api_key
=
datadog_api_key
,
app_key
=
datadog_app_key
)
self
.
datadog_api_initialized
=
True
def
playbook_on_task_start
(
self
,
name
,
is_conditional
):
...
...
@@ -52,18 +60,8 @@ class CallbackModule(object):
# Sort the tasks by their running time
results
=
sorted
(
self
.
stats
.
items
(),
key
=
lambda
value
:
value
[
1
][
1
],
reverse
=
True
)
datadog_api_key
=
os
.
getenv
(
'DATADOG_API_KEY'
)
datadog_app_key
=
os
.
getenv
(
'DATADOG_APP_KEY'
)
datadog_api_initialized
=
True
if
datadog_api_key
and
datadog_app_key
:
datadog
.
initialize
(
api_key
=
datadog_api_key
,
app_key
=
datadog_app_key
)
else
:
datadog_api_initialized
=
False
# send the metric to datadog
if
datadog_api_initialized
:
if
self
.
datadog_api_initialized
:
for
name
,
points
in
results
:
datadog
.
api
.
Metric
.
send
(
metric
=
"edx.ansible.{0}.task_duration"
.
format
(
name
.
replace
(
" | "
,
"."
)
.
replace
(
" "
,
"-"
)
.
lower
()),
...
...
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