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 flask import Flask, redirect, request
from jaeger_client import Config from jaeger_client import Config
from flask_opentracing import FlaskTracer #, FlaskTracing
import opentracing import opentracing
from opentracing.propagation import Format from opentracing.propagation import Format
import requests import requests
...@@ -20,9 +19,7 @@ config = Config(config = { ...@@ -20,9 +19,7 @@ config = Config(config = {
'reporter_batch_size': 1 'reporter_batch_size': 1
}, service_name=service) }, service_name=service)
#tracer = config.initialize_tracer() tracer = config.initialize_tracer()
tracer = FlaskTracer(config.initialize_tracer(), True, app)
#tracing = FlaskTracing(tracer, True, app)
@app.route('/') @app.route('/')
def index(): def index():
...@@ -30,13 +27,13 @@ def index(): ...@@ -30,13 +27,13 @@ def index():
@app.route('/hip') @app.route('/hip')
def hip(): def hip():
print(request.headers) print(request.headers)
r = "" r = ""
parent_span = tracer.extract(Format.HTTP_HEADERS, request.headers) if tier > 1 else tracer.start_span(operation_name="hip hop")
try: try:
parent_span = tracer.extract(Format.HTTP_HEADERS, request.headers) if tier > 1 else tracer.get_span()
print(f"{parent_span}") print(f"{parent_span}")
url = f"http://{service}-{tier + 1}/hip" 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}") print(f"{span}")
span.set_tag("http.url", url) span.set_tag("http.url", url)
headers = dict(request.headers) headers = dict(request.headers)
...@@ -50,6 +47,7 @@ def hip(): ...@@ -50,6 +47,7 @@ def hip():
print(ex) print(ex)
traceback.print_exc() traceback.print_exc()
r = "END" r = "END"
parent_span.finish()
return f"hop-{ tier } -> { r }" return f"hop-{ tier } -> { r }"
app.run(host="0.0.0.0", port=80) app.run(host="0.0.0.0", port=80)
Markdown is supported
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