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
Pump, Cedric
lab-tracing
Commits
cca2a0a2
Commit
cca2a0a2
authored
Dec 27, 2020
by
Nane Kratzke
Browse files
get rid off implicit flask tracing
parent
90b089bd
Changes
1
Hide whitespace changes
Inline
Side-by-side
hiphop/service.py
View file @
cca2a0a2
from
flask
import
Flask
,
redirect
,
request
from
jaeger_client
import
Config
from
flask_opentracing
import
FlaskTracer
#, FlaskTracing
import
opentracing
from
opentracing.propagation
import
Format
import
requests
...
...
@@ -20,9 +19,7 @@ config = Config(config = {
'reporter_batch_size'
:
1
},
service_name
=
service
)
#tracer = config.initialize_tracer()
tracer
=
FlaskTracer
(
config
.
initialize_tracer
(),
True
,
app
)
#tracing = FlaskTracing(tracer, True, app)
tracer
=
config
.
initialize_tracer
()
@
app
.
route
(
'/'
)
def
index
():
...
...
@@ -30,13 +27,13 @@ def index():
@
app
.
route
(
'/hip'
)
def
hip
():
print
(
request
.
headers
)
print
(
request
.
headers
)
r
=
""
parent_span
=
tracer
.
extract
(
Format
.
HTTP_HEADERS
,
request
.
headers
)
if
tier
>
1
else
tracer
.
start_span
(
operation_name
=
"hip hop"
)
try
:
parent_span
=
tracer
.
extract
(
Format
.
HTTP_HEADERS
,
request
.
headers
)
if
tier
>
1
else
tracer
.
get_span
()
print
(
f
"
{
parent_span
}
"
)
url
=
f
"http://
{
service
}
-
{
tier
+
1
}
/hip"
with
opentracing
.
tracer
.
start_span
(
operation_name
=
url
,
child_of
=
parent_span
)
as
span
:
with
tracer
.
start_span
(
operation_name
=
url
,
child_of
=
parent_span
)
as
span
:
print
(
f
"
{
span
}
"
)
span
.
set_tag
(
"http.url"
,
url
)
headers
=
dict
(
request
.
headers
)
...
...
@@ -50,6 +47,7 @@ def hip():
print
(
ex
)
traceback
.
print_exc
()
r
=
"END"
parent_span
.
finish
()
return
f
"hop-
{
tier
}
->
{
r
}
"
app
.
run
(
host
=
"0.0.0.0"
,
port
=
80
)
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