Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
engine
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
AURA
engine
Commits
13efab7f
Commit
13efab7f
authored
3 years ago
by
David Trattnig
Browse files
Options
Downloads
Patches
Plain Diff
Less verbose logging when API fails.
#33
parent
b85aa202
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/plugins/monitor.py
+18
-6
18 additions, 6 deletions
src/plugins/monitor.py
src/plugins/trackservice.py
+36
-9
36 additions, 9 deletions
src/plugins/trackservice.py
with
54 additions
and
15 deletions
src/plugins/monitor.py
+
18
−
6
View file @
13efab7f
...
...
@@ -197,16 +197,28 @@ class AuraMonitor:
body
[
"
is_healthy
"
]
=
is_healthy
body
[
"
details
"
]
=
json
.
dumps
(
data
,
default
=
str
)
json_data
=
json
.
dumps
(
body
,
default
=
str
)
url
=
self
.
config
.
get
(
"
api_engine_store_health
"
)
url
=
url
.
replace
(
"
${ENGINE_NUMBER}
"
,
str
(
self
.
config
.
get
(
"
api_engine_number
"
)))
headers
=
{
'
content-type
'
:
'
application/json
'
}
r
=
requests
.
post
(
url
,
data
=
json_data
,
headers
=
headers
)
response
=
requests
.
Response
()
response
.
status_code
=
404
if
r
.
status_code
==
204
:
self
.
logger
.
info
(
"
Successfully posted healthy=%s state to Engine API!
"
%
is_healthy
)
else
:
self
.
logger
.
error
(
"
HTTP %s | Error while pushing health state to Engine API: %s
"
%
(
r
.
status_code
,
str
(
r
.
json
())))
try
:
response
=
requests
.
post
(
url
,
data
=
json_data
,
headers
=
headers
)
if
response
.
status_code
==
204
:
self
.
logger
.
info
(
"
Successfully posted healthy=%s state to Engine API!
"
%
is_healthy
)
else
:
msg
=
SU
.
red
(
f
"
HTTP
{
response
.
status_code
}
| Error while pushing health state to Engine API:
{
response
.
json
()
}
"
)
self
.
logger
.
error
(
msg
)
except
requests
.
exceptions
.
ConnectionError
:
self
.
logger
.
error
(
SU
.
red
(
f
"
Bad Request when posting health-status to
{
url
}
"
))
return
response
except
requests
.
exceptions
.
Timeout
:
self
.
logger
.
error
(
SU
.
red
(
f
"
Timeout when posting health-status to
{
url
}
"
))
return
response
except
:
self
.
logger
.
error
(
SU
.
red
(
f
"
Unknown Exception when posting health-status to
{
url
}
"
))
return
response
def
update_status
(
self
):
...
...
This diff is collapsed.
Click to expand it.
src/plugins/trackservice.py
+
36
−
9
View file @
13efab7f
...
...
@@ -162,16 +162,30 @@ class TrackServiceHandler():
Posts the given `PlaylistEntry` to the Engine API Playlog.
"""
data
=
SU
.
clean_dictionary
(
data
)
self
.
logger
.
info
(
"
Posting playlog to Engine API...
"
)
url
=
self
.
config
.
get
(
"
api_engine_store_playlog
"
)
headers
=
{
'
content-type
'
:
'
application/json
'
}
body
=
json
.
dumps
(
data
,
indent
=
4
,
sort_keys
=
True
,
default
=
str
)
self
.
logger
.
debug
(
"
Playlog Data:
"
+
body
)
response
=
requests
.
post
(
url
,
data
=
body
,
headers
=
headers
)
if
response
.
status_code
!=
204
or
response
.
status_code
!=
204
:
msg
=
f
"
Error while posting playlog to Engine API:
{
response
.
reason
}
(Error
{
response
.
status_code
}
)
\n
"
self
.
logger
.
info
(
SU
.
red
(
msg
)
+
response
.
content
.
decode
(
"
utf-8
"
))
response
=
requests
.
Response
()
response
.
status_code
=
404
try
:
response
=
requests
.
post
(
url
,
data
=
body
,
headers
=
headers
)
if
response
.
status_code
!=
204
:
msg
=
f
"
Error while posting playlog to Engine API:
{
response
.
reason
}
(Error
{
response
.
status_code
}
)
\n
"
self
.
logger
.
info
(
SU
.
red
(
msg
)
+
response
.
content
.
decode
(
"
utf-8
"
))
except
requests
.
exceptions
.
ConnectionError
:
self
.
logger
.
error
(
SU
.
red
(
f
"
Bad Request when posting playlog to
{
url
}
"
))
return
response
except
requests
.
exceptions
.
Timeout
:
self
.
logger
.
error
(
SU
.
red
(
f
"
Timeout when posting playlog to
{
url
}
"
))
return
response
except
:
self
.
logger
.
error
(
SU
.
red
(
f
"
Unknown Exception when posting playlog to
{
url
}
"
))
return
response
def
store_clock_info
(
self
,
data
):
...
...
@@ -218,10 +232,23 @@ class TrackServiceHandler():
headers
=
{
'
content-type
'
:
'
application/json
'
}
body
=
json
.
dumps
(
data
,
indent
=
4
,
sort_keys
=
True
,
default
=
str
)
self
.
logger
.
debug
(
"
Clock Data:
"
+
body
)
response
=
requests
.
put
(
url
,
data
=
body
,
headers
=
headers
)
if
response
.
status_code
!=
204
or
response
.
status_code
!=
204
:
msg
=
f
"
Error while posting clock-info to Engine API:
{
response
.
reason
}
(Error
{
response
.
status_code
}
)
\n
"
self
.
logger
.
info
(
SU
.
red
(
msg
)
+
response
.
content
.
decode
(
"
utf-8
"
))
response
=
requests
.
Response
()
response
.
status_code
=
404
try
:
response
=
requests
.
put
(
url
,
data
=
body
,
headers
=
headers
)
if
response
.
status_code
!=
204
:
msg
=
f
"
Error while posting clock-info to Engine API:
{
response
.
reason
}
(Error
{
response
.
status_code
}
)
\n
"
self
.
logger
.
info
(
SU
.
red
(
msg
)
+
response
.
content
.
decode
(
"
utf-8
"
))
except
requests
.
exceptions
.
ConnectionError
:
self
.
logger
.
error
(
SU
.
red
(
f
"
Bad Request when posting clock-info to
{
url
}
"
))
return
response
except
requests
.
exceptions
.
Timeout
:
self
.
logger
.
error
(
SU
.
red
(
f
"
Timeout when posting clock-info to
{
url
}
"
))
return
response
except
:
self
.
logger
.
error
(
SU
.
red
(
f
"
Unknown Exception when posting clock-info to
{
url
}
"
))
return
response
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment