Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
cloud-native
lab-tracing
Commits
99446daf
Commit
99446daf
authored
Mar 06, 2021
by
Nane Kratzke
Browse files
Improved hiphop service
parent
e24f2186
Pipeline
#29731
passed with stages
in 30 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
hiphop/service.py
View file @
99446daf
from
flask
import
Flask
,
redirect
,
request
import
requests
,
traceback
,
os
import
requests
,
os
,
logging
from
elasticapm.contrib.flask
import
ElasticAPM
# A very boring and basic hip-hop-service to demonstrate
# observability via tracing.
# observability via tracing
across multiple services
.
service
=
os
.
environ
.
get
(
'HIPHOP'
,
'hiphop'
)
tier
=
int
(
os
.
environ
.
get
(
'TIER'
,
'1'
))
app
=
Flask
(
__name__
)
apm
=
ElasticAPM
(
app
,
service_name
=
os
.
environ
.
get
(
'HIPHOP'
,
'hiphop'
),
)
apm
=
ElasticAPM
(
app
,
service_name
=
service
)
@
app
.
route
(
'/'
)
def
index
():
...
...
@@ -17,15 +16,13 @@ def index():
@
app
.
route
(
'/hip'
)
def
hip
():
print
(
request
.
headers
)
r
=
""
url
=
f
"http://
{
service
}
-
{
tier
+
1
}
/hip"
try
:
url
=
f
"http://
{
service
}
-
{
tier
+
1
}
/hip"
r
=
requests
.
get
(
url
)
r
=
r
.
content
.
decode
(
'utf-8'
)
except
Exception
as
ex
:
print
(
ex
)
traceback
.
print_exc
()
logging
.
error
(
f
"Fetching
{
url
}
failed (
{
ex
}
)"
)
r
=
"END"
hip
=
"hip "
if
tier
==
1
else
""
...
...
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