Commit cca2a0a2 authored by Nane Kratzke's avatar Nane Kratzke
Browse files

get rid off implicit flask tracing

parent 90b089bd
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)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment